This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Process received data
#1
Hi~, I am connecting another brand of RS485 air conditioner panel via LM. Each time it is triggered, this panel will send out 16 bytes of data.
  It can be polished from the picture, I read 16-bit data from the 485 bus every time. But there are other panel devices on the bus. These devices transmit different amounts of data after being triggered.
  As a result, some of the 16 bytes of data I received may not be commands from the air conditioner panel, so I cannot make a judgment.
  For the data received by the LM, I need to input the data in (AD BD 0D 1A 06 03 05 42 20 01 28) to make a judgment. For example, the value of 20. How to extract 20 and then judge and execute the corresponding operation?

(18.11.2020, 09:11)Rick Wrote: Hi~, I am connecting another brand of RS485 air conditioner panel via LM. Each time it is triggered, this panel will send out 16 bytes of data.
  It can be polished from the picture, I read 16-bit data from the 485 bus every time. But there are other panel devices on the bus. These devices transmit different amounts of data after being triggered.
  As a result, some of the 16 bytes of data I received may not be commands from the air conditioner panel, so I cannot make a judgment.
  For the data received by the LM, I need to input the data in (AD BD 0D 1A 06 03 05 42 20 01 28) to make a judgment. For example, the value of 20. How to extract 20 and then judge and execute the corresponding operation?
Reply
#2
The best would be to contact the AC manufacture and ask for protocol documentation.
------------------------------
Ctrl+F5
Reply
#3
(18.11.2020, 09:27)Daniel. Wrote: The best would be to contact the AC manufacture and ask for protocol documentation.
Yes, I have obtained the protocol documentation. But because there are other devices on the 485 bus, LM will also receive data that I don’t need when reading data. I don’t know how to filter out the data I need. How can I parse or process the data I received?

(18.11.2020, 09:27)Daniel. Wrote: The best would be to contact the AC manufacture and ask for protocol documentation.
尊宝 07.10.2020 01:21:46
* hexstring [16]: 02 00 38 64 AD BD 0D 1A 06 03 06 16 21 09 27 28


尊宝 07.10.2020 01:22:57
* hexstring [16]: 02 00 3A 6E AD BD 0D 1A 06 03 06 17 21 09 27 28


尊宝 07.10.2020 01:24:11
* hexstring [16]: 02 00 3B 73 AD BD 0D 1A 06 03 06 18 21 09 27 28


尊宝 07.10.2020 01:25:30
* hexstring [16]: 02 00 3C 78 AD BD 0D 1A 06 03 06 20 21 09 27 28


尊宝 07.10.2020 01:26:53
* hexstring [16]: 02 00 44 20 AD BD 0D 1A 06 03 06 21 21 09 27 28


尊宝 07.10.2020 01:28:32
* hexstring [16]: 00 45 25 AD BD 0D 1A 06 03 06 23 21 09 27 28 02


尊宝 07.10.2020 01:29:34
* hexstring [16]: 47 2F AD BD 0D 1A 06 03 06 24 21 09 27 28 02 00
Reply
#4
Each product must have a address which is one of the byte in the string, probably the first.
------------------------------
Ctrl+F5
Reply
#5
Are you sure that each frame has a fixed length of 16 bytes? From your logs it seems that the length can be different.
Reply
#6
(18.11.2020, 09:41)Daniel. Wrote: Each product must have a address which is one of the byte in the string, probably the first.
YES, for example, when LM receives a string of 20 bytes of data, I only need the consecutive 16 bytes. How can I extract these 16 bytes?

(18.11.2020, 09:46)admin Wrote: Are you sure that each frame has a fixed length of 16 bytes? From your logs it seems that the length can be different.
YES,the air conditioner panel I need to receive is 16 bytes each time. But sometimes this panel will actively report more than 16 bytes of data, and I will ignore this data.

(18.11.2020, 09:49)Rick Wrote:
(18.11.2020, 09:41)Daniel. Wrote: Each product must have a address which is one of the byte in the string, probably the first.
YES, for example, when LM receives a string of 20 bytes of data, I only need the consecutive 16 bytes. How can I extract these 16 bytes?

(18.11.2020, 09:46)admin Wrote: Are you sure that each frame has a fixed length of 16 bytes? From your logs it seems that the length can be different.
YES,the air conditioner panel I need to receive is 16 bytes each time. But sometimes this panel will actively report more than 16 bytes of data, and I will ignore this data.
And I need 16 data starting with AD BD OD to make judgment logic.
Reply
#7
Can you provide documentation on the protocol? From your logs ab bd is not in same place.
Reply
#8
(18.11.2020, 10:58)admin Wrote: Can you provide documentation on the protocol? From your logs ab bd is not in same place.
Yes, because there are data sent by other devices on the bus, the location of the data AD BD received by LM will be different each time.
Documentation may not be of much use to you, because the data sent by the actual device is different from that documentation.
Reply
#9
How often is data sent on the bus? Can there be long delays between packets?
Reply
#10
(18.11.2020, 11:20)admin Wrote: How often is data sent on the bus? Can there be long delays between packets?
The sending of data is uncertain, and I cannot guarantee the interval time. The other equipment is a light panel, which will send data to the bus when triggered by someone.
Reply
#11
Try this as a resident script. Edit serial.open with correct port name and settings.
Code:
if not port then
  require('serial')

  port = serial.open(...)

  function read()
    local buf = {}

    while true do
      local timeout = #buf > 0 and 0.5 or 15
      local char = port:read(1, timeout)
      
      if char then
        buf[ #buf + 1 ] = char:byte()
      else
        return buf
      end
    end
  end
end

res = read()
log(res)
if #res == 16 then
  -- process 16 bytes of data
end
Return value for read function is a table containing bytes that have been read converted to numbers. It assumes that there's at least 0.5 seconds between consecutive messages. You can edit the timeout value to suit your needs.
Reply
#12
(19.11.2020, 07:44)admin Wrote: Try this as a resident script. Edit serial.open with correct port name and settings.
Code:
if not port then
  require('serial')

  port = serial.open(...)

  function read()
    local buf = {}

    while true do
      local timeout = #buf > 0 and 0.5 or 15
      local char = port:read(1, timeout)
     
      if char then
        buf[ #buf + 1 ] = char:byte()
      else
        return buf
      end
    end
  end
end

res = read()
log(res)
if #res == 16 then
  -- process 16 bytes of data
end
Return value for read function is a table containing bytes that have been read converted to numbers. It assumes that there's at least 0.5 seconds between consecutive messages. You can edit the timeout value to suit your needs.
THANKS,I will try this.

(19.11.2020, 09:32)Rick Wrote:
(19.11.2020, 07:44)admin Wrote: Try this as a resident script. Edit serial.open with correct port name and settings.
Code:
if not port then
  require('serial')

  port = serial.open(...)

  function read()
    local buf = {}

    while true do
      local timeout = #buf > 0 and 0.5 or 15
      local char = port:read(1, timeout)
     
      if char then
        buf[ #buf + 1 ] = char:byte()
      else
        return buf
      end
    end
  end
end

res = read()
log(res)
if #res == 16 then
  -- process 16 bytes of data
end
Return value for read function is a table containing bytes that have been read converted to numbers. It assumes that there's at least 0.5 seconds between consecutive messages. You can edit the timeout value to suit your needs.
THANKS,I will try this.
In addition, I found that LM sometimes cannot be accessed through Google browser, and it is normal after waiting for about 30s. When it is not accessible, the logic function inside LM cannot be realized either.
Reply
#13
Your device mots likely is overloaded and it keeps rebooting.
------------------------------
Ctrl+F5
Reply
#14
(19.11.2020, 09:36)Daniel. Wrote: Your device mots likely is overloaded and it keeps rebooting.
I used a new device, and there were not many internal programs. How can I avoid this problem?
Reply
#15
Install the System Load app and see what process is eating your LM
------------------------------
Ctrl+F5
Reply
#16
(19.11.2020, 09:56)Daniel. Wrote: Install the System Load app and see what process is eating your LM
Sorry,what is System Load app?
Reply
#17
In the app store there is app to monitor ruining processes on LM.
------------------------------
Ctrl+F5
Reply
#18
(19.11.2020, 10:03)Daniel. Wrote: In the app store there is app to monitor ruining processes on LM.
Got it!

(19.11.2020, 10:03)Rick Wrote:
(19.11.2020, 10:03)Daniel. Wrote: In the app store there is app to monitor ruining processes on LM.
Got it!
It does not seem to occupy a lot, or may occupy a lot at a certain point in time.In the total, only about 30% is occupied.The most occupied is [b]/usr/bin/eibd[/b]-e 15.15.255 -q 100 -L 1 -Q 0 -f eth0 -D -R -T -S224.0.23.12 -F n,n,n,n,0,0 tpuarts:/dev/ttymxc5. 
Reply
#19
(19.11.2020, 07:44)admin Wrote: Try this as a resident script. Edit serial.open with correct port name and settings.
Code:
if not port then
  require('serial')

  port = serial.open(...)

  function read()
    local buf = {}

    while true do
      local timeout = #buf > 0 and 0.5 or 15
      local char = port:read(1, timeout)
     
      if char then
        buf[ #buf + 1 ] = char:byte()
      else
        return buf
      end
    end
  end
end

res = read()
log(res)
if #res == 16 then
  -- process 16 bytes of data
end
Return value for read function is a table containing bytes that have been read converted to numbers. It assumes that there's at least 0.5 seconds between consecutive messages. You can edit the timeout value to suit your needs.
How can I extract the 12th or 13th data separately from the 16 reads?
Reply
#20
Like this, keep in mind that table indexes start at 1, not 0.
Code:
if #res == 16 then
  b12 = res[ 12 ]
  b13 = res[ 13 ]
  log(b12, b13)
end
Reply


Forum Jump: