I want convert input from QLineEdit and send to serial as Hex bytes.
Example:
QlineEdit input
is 03040506
Write to serial as 0x03 0x04 0x05 0x06
Thanks,
I want convert input from QLineEdit and send to serial as Hex bytes.
Example:
QlineEdit input
is 03040506
Write to serial as 0x03 0x04 0x05 0x06
Thanks,
You can easily do this using bytes.fromhex
data = "03040506"
out = bytes.fromhex(data)
print(out)
output
b'\x03\x04\x05\x06'
To send those bytes to the serial port, just do something like ser.write(out)
, where ser
is an open serial port.