From f61579211546226ca322b3b80d9481a330ff7a18 Mon Sep 17 00:00:00 2001 From: schlotzz Date: Fri, 14 May 2021 09:03:53 +0200 Subject: [PATCH] Fixed wrong order of address/id in frame decode The frame order has been defined by RCT as followed: start | command | length | address (if plant modificator bit set) | id | data | crc The encoding method uses the right order of fields (address before id), but the decoding method swapped the order. --- src/rctclient/frame.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rctclient/frame.py b/src/rctclient/frame.py index d3354b5..0fee4b5 100644 --- a/src/rctclient/frame.py +++ b/src/rctclient/frame.py @@ -370,13 +370,13 @@ def decode(self): data_length -= self._frame_type - self._id = struct.unpack('>I', self._buffer[idx:idx + 4])[0] - # self._id_obj = find_by_id(self._id) - idx += 4 - if self._frame_type == FrameType.PLANT: self._address = struct.unpack('>I', self._buffer[idx:idx + 4])[0] idx += 4 + + self._id = struct.unpack('>I', self._buffer[idx:idx + 4])[0] + # self._id_obj = find_by_id(self._id) + idx += 4 self._data = self._buffer[idx:idx + data_length] idx += data_length