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
#2
Do you have a documentation on the protocol for these blinds? Usually there is either a specific delimiter byte that allows to find the message frame start/end or a length field somewhere in the data at a fixed position.
Reply
#3
Thank you admin!
Yes there is a documentation for this blind protocol but it is classified... I can send you with DM (:

I know the delimiter and can tell where the frame start and end.
How can I use this information to process data simultaneously ? (:
Reply
#4
If you can find the start/end then you can simply read a single char at a time and buffer the data until the frame end is found. Like in this example: https://forum.logicmachine.net/showthrea...9#pid20339
Reply
#5
Thank you admin Smile
The delimiter of the blind is not a single char, it's "DLE STX ID (10 02 51 in hex)" and I get them as string.
To be accurate they are not delimiter, the signal always start with DLE STX ID and that is the only way to devide the signal.
Could you help me to write script to process such signal ?
Reply
#6
There should be some kind of end character or a byte containing the message length. Otherwise you won't be able to parse the incoming message until the next message is sent.
Reply


Forum Jump: