-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
I think there is a typo in https://github.com/rscada/python-mbus/blob/master/mbus/MBusFrame.py#L21
the field stop is a duplicate and the second instance probably should be type, according to https://github.com/rscada/libmbus/blob/master/mbus/mbus-protocol.h#L91.
I tried redefining the field as:
diff --git a/mbus/MBusFrame.py b/mbus/MBusFrame.py
index 36358e8..1b9c677 100644
--- a/mbus/MBusFrame.py
+++ b/mbus/MBusFrame.py
@@ -1,4 +1,4 @@
-from ctypes import Structure, c_uint8, c_long, c_size_t, POINTER
+from ctypes import Structure, c_int, c_uint8, c_long, c_size_t, POINTER
c_time_t = c_long
@@ -18,7 +18,7 @@ MBusFrame._fields_ = [
("stop", c_uint8),
("data", c_uint8 * 252),
("data_size", c_size_t),
- ("stop", c_uint8),
+ ("type", c_int),
("timestamp", c_time_t),
("next", POINTER(MBusFrame))
]However, even with this change, I wasn't able to read the type of the MBusFrame (also tried c_uint8 for the type). I'm not that familiar with ctypes, so maybe there is another place where the C struct is mapped to the Python object MBusFrame?
For testing I called the function frame_type from the C library directly and it returned 4 while queryting the type attribute in Python always returned 0.
Metadata
Metadata
Assignees
Labels
No labels