Different output data USB-RS232 with Pyserial in windows and Ubuntu

45 Views Asked by At

I'll let you know in advance that I'm not a programmer, but I'm developing an application to automatically collect weights with a scale. The issue I've encountered is that with the same Python source code, when reading data from the serial port in Windows, I correctly read the data even if it's in a binary string. However, on the Jetson Nano running Ubuntu, it returns the following value. Same source code.

CODE:

`
import serial

ser = serial.Serial(
    port='COM4',  # in Jetson nano '/dev/ttyUSB0'
    baudrate=9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
)

while True:
    x=ser.readline()    
    print(x)
`

OUTPUT WINDOWS:

b'\\x0cN:         3.344g  \\r\\n'

OUTPUT JETSON NANO:

b'\\x08\\x01\\x0c\\x0e\\t\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x02\\x1a\\x12\\t\\x13\\x13\\x16\\x02\\n

How can I convert output jetson nano in a output windows?

0

There are 0 best solutions below