tbird20d / grabserial

Grabserial - python-based serial dump and timing program - good for embedded Linux development
GNU General Public License v2.0
198 stars 79 forks source link

python3: convert bytes to str #19

Closed henning-schild closed 6 years ago

henning-schild commented 6 years ago

In python3 the read() will return "bytes" not "str", but the following write() and the comparators need the type "str". Just convert unconditionally, also works on python2.

Signed-off-by: Henning Schild henning@hennsch.de

henning-schild commented 6 years ago

Just read the other "closed" PR, yes the bytes vs str is causing a real problem!

Opening serial port /dev/ttyACM0
9600:8N1:xonxoff=0:rtscts=0
Printing timing information for each line
Matching pattern 'Reboot' to set base time
Use Control-C to stop...
Traceback (most recent call last):
  File "./grabserial", line 531, in <module>
    grab(sys.argv[1:])
  File "./grabserial", line 480, in grab
    curline += x
TypeError: Can't convert 'bytes' object to str implicitly

And testing with python2 and 3 is not really a big problem.

python3 ./grabserial ...
python2 ./grabserial ...