chaim-zax / gq-gmc-control

Control tool for the GQ GMC Geiger Counters.
GNU General Public License v3.0
55 stars 18 forks source link

Python3 fixes #11

Open timstr opened 5 months ago

timstr commented 5 months ago

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.