I am trying to read serial[hexadecimal] data using Python, but when read its showing only zeros.
I tried cross checking the data using a logic analyzer and there i can see the data properly.
If any one can give any solution it will be great.
Pasted below is the code.
import serial
ser = serial.Serial(
port='COM5',
baudrate=100, # Set baud rate to 100
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
#timeout=1 # Optional: set a timeout for read operations
)
data = ser.read(100) # Read up to 100 bytes
print(data)`
**Output: **
b’xfcx00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00x00′
Also i cross checked the port setting with the logic anlayzer, its all same but still not able to see the data.
Bipin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1