Convert the code to run as Python3, since Python2 has been unsupported for over 4 years.
Most of the fixes involve serial.Serial.read and struct.pack now returning a bytes object instead of a string. I've tested a few of the commands on my GMC-500+ and in a Python3 interpreter with the -b flag which additionally warns about comparing str to bytes (an easy pitfall otherwise).
I also went ahead and simplified many cases of e.g.:
if s == '' and len(s) < 7:
to just:
if len(s) < 7:
I have not tested all the available commands, but I can confirm that reading data off the device and into a CSV file is working. I do notice some artifacts at the tail end of the flash memory dump, there's a long run of CPS=255 which I assume is from a parsing error. I don't know if this behaviour is present before these Python3 fixes.
Convert the code to run as Python3, since Python2 has been unsupported for over 4 years.
Most of the fixes involve
serial.Serial.read
andstruct.pack
now returning abytes
object instead of a string. I've tested a few of the commands on my GMC-500+ and in a Python3 interpreter with the-b
flag which additionally warns about comparingstr
tobytes
(an easy pitfall otherwise).I also went ahead and simplified many cases of e.g.:
to just:
I have not tested all the available commands, but I can confirm that reading data off the device and into a CSV file is working. I do notice some artifacts at the tail end of the flash memory dump, there's a long run of CPS=255 which I assume is from a parsing error. I don't know if this behaviour is present before these Python3 fixes.