After updating modbus_tk to the latest version I noticed that my script stopped working due to the following issue:
After pull request #148 the response (variable data) of my instrument is evaluated like:
data.decode()
producing errors or wrong outputs.
instead of:
struct.unpack(data_format, data)
if (re.match("[>]?[sp]?",data_format)):
result = data.decode()
else:
result = struct.unpack(data_format, data)
In my case, I do not pass any argument to data_format, but some of the examples of pairs of data and data_format before reaching this if condition are:
data = bytearray(b'F\n\xe0\x00')
data_format = >HH
or
data = bytearray(b'\x00\x00')
data_format = >H
I believe that the problem here is that the evaluation re.match("[>]?[sp]?",data_format) is not accurate? Or should I use something else in the parameter data_format?
I have no idea about modbus, regex... Hopefully someone can shed some light. Personally I have made a work-around locally modifying this condition.
Hi!
After updating modbus_tk to the latest version I noticed that my script stopped working due to the following issue:
After pull request #148 the response (variable
data
) of my instrument is evaluated like:data.decode()
producing errors or wrong outputs. instead of:struct.unpack(data_format, data)
due to the following condition in this file:
In my case, I do not pass any argument to
data_format
, but some of the examples of pairs ofdata
anddata_format
before reaching this if condition are:or
I believe that the problem here is that the evaluation
re.match("[>]?[sp]?",data_format)
is not accurate? Or should I use something else in the parameterdata_format
?I have no idea about modbus, regex... Hopefully someone can shed some light. Personally I have made a work-around locally modifying this condition.
Thanks a lot!