modbusreader.structutils¶
structutils.py: extends the function of the struct package
-
modbusreader.structutils.
bytes_to_datatype
(byte_list, data_type)¶ Unpacks a bytes object to the given data type
Parameters: Returns: unpacked value
Type: int, float, byte, boolean
Raises: ValueError – If size of data type is not equal to the size of the bytes object.
-
modbusreader.structutils.
calcsize
(data_type)¶ Return size in bytes of the struct described by the given data type
Parameters: data_type (str) – human readable data type. One of: int16, int32, uint32, float, byte, boolean Returns: size in bytes of the struct described by the given data type Type: int
-
modbusreader.structutils.
get_format
(data_type)¶ Get struct format type from human readable data type
Parameters: data_type (str) – human readable data type. One of: int16, int32, uint32, float, byte, boolean Returns: struct format type Type: str
-
modbusreader.structutils.
int16list_to_bytes
(int16_list)¶ Packs all given integer values into bytes object
Parameters: int16_list (list of int) – list containing unsigned 16 bit integers Returns: packed integer values Type: bytes