Using Windows 10 with Python 3.7.1 and Spyder IDE.
This code segment imports serial and reads from the COM1 port.
ser = serial.Serial('COM1')
print (ser.name)
ser.baudrate = 115200
s = ser.read(100)
print (s)
I’m expecting to receive a string that looks something like this, straight hex bytes.
FA 01 08 00 0E A7 C0 C2 68 47 13 BF DD 2F 3E BD 4C B9 FA 01 08 00 DD A6 C0 C2 2D 25 12 BF 21 18 29 BD F3 47 FA 01 08 00 20 A7 C0 C2 55 D1 11 BF E8 B0 3B BD AF 81
But I get this displayed from the print(s)
COM1 b'\xfa\x01\x08\x00\xfc\xb0#\xc1\x05\x83\xc1=\x0e\x07\xb2\xbe|\xec\xfa\x01\x08\x00{\x92#\xc10\x14\xca=\xff\xf6\xb6\xbem\x96\xfa\x01\x08\x00G\x9d#\xc1\xd5\xab\xc4=\xa6\x89\xb8\xbe8\xea\xfa\x01\x08\x00\xc2\xba#\xc1\x88\x7f\xca=\x9d\x89\xb5\xbe\xc6\x8c\xfa\x01\x08\x00C\xcd#\xc1\xdc\xa6\xcc=\x8c\x1e\xb6\xbe\x1b\xd4\xfa\x01\x08\x00g\xcb#\xc1\xb5\xbc'
Is this just a function of how Python print on a Windows laptop displays hex bytes in a stream read off the COM port? Is it really just those HEX bytes on the wire?
Thanks
print(s.hex())
– Chris Doyle