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.

read various length data with rs485
#1
Hi!!

I have a group of blinds to control with RS485.

I have no problem with sending commands but I'm stuck with reading the blind status.

When the blind start to move it gives me 24bits or 26bits of strings. This data indicates the blind unit number(int), move status(bool).
When the blind stop to move it gives me 30bits or 32bits of strings. This data indicates the blind unit number(int), move status(bool), height status(%) and slut status(%).

When I read like below with resident script 0 interval, I can get all necessary data but it will take 20 seconds until get the result of log(res).

Code:
if not port then
  require('serial')
  port =  serial.open('/dev/RS485-1', {
  baudrate = 9600,
  databits = 8,
  stopbits = 1,
  parity = 'even',
  duplex = 'half'
})
end
res, err = port:read(-1)

if res then
  log(res)
end

I need to reflect the blind move status to the status Group Address almost simultaneously.
When I try to read like below the process starts simultaneously but I cannnot read 30bits data properly.
Code:
res, err = port:read(24)

How can I write this when we need to read various length data with RS485?

Thank you so much in advance!
Reply


Messages In This Thread
read various length data with rs485 - by Hadeel - 02.06.2023, 09:10

Forum Jump: