I have a class with all sorts of data in it, like:
class UARTMessage:
Identification1 = int(0) #byte 0
Timestamp1 = int(0) #bytes [1:5]
Voltage1 = int(0) #bytes [6:7]
Current1 = int(0) #bytes [8:9]
Signal1= int(0) #bytes [10:11]
Identification2 = int(0) #byte 12
Timestamp2 = int(0) #bytes [13:17]
Voltage2 = int(0) #bytes [18:19]
Current2 = int(0) #bytes [20:21]
Signal = int(0) #bytes [22:23]
Identification3 = int(0) #byte 24
The data to fill this structure up will come from a serial. I need to deserialize the data coming from the serial in the shape of this structure. I am reading from serial 40 bytes data chunks and I need to split itit. I tried pickle library but it seems that it's not fitted exactly for deserializing this type of data. I found struct but I cannot understand how to use it proprely in this case.
As the comments in the struct, I need to desearilize the chunks of data like: first byte is Identificator, bytes from 1 to 5 included is the timestamp and so on....
DO you have any ideea how can I achieve this?
Thanks