read various length data with rs485 - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: read various length data with rs485 (/showthread.php?tid=4798) |
read various length data with rs485 - Hadeel - 02.06.2023 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 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! RE: read various length data with rs485 - admin - 02.06.2023 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. RE: read various length data with rs485 - Hadeel - 02.06.2023 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 ? (: RE: read various length data with rs485 - admin - 02.06.2023 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/showthread.php?tid=3131&pid=20339#pid20339 RE: read various length data with rs485 - Hadeel - 25.02.2024 Thank you admin 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 ? RE: read various length data with rs485 - admin - 26.02.2024 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. |