Convert received data bytes in serial to hex text
0
votes
1
answer
4944
views
Hi now I write bytes data (for eg, **
\x00\x11\x22
**) from my PC to serial port of my device running unix at the ttyS1 port. I am able to print the data using either
cat /dev/ttyS1
od -x < /dev/ttyS1
both works,
but with cat I get "▒▒" printed.
With od, i see some data bytes:
0000000 00fe
0000001
Which is not what i sent (001122Hex).
How can I get the correct hex display?
**EDIT**:
tty permission set:
stty -F /dev/ttyS1 speed 115200 cs8 -cstopb -parenb -echo time 3 min 0
**EDIT2**:
Something weird is happening I am not sure why. I tried to send different data:
"1049" which my program then sends as "\x10\x49". od returns:
0000000 4910
0000002
Seems it reversed the bytes. But what I don't get now is if I have repeated number like "\x11\x49" at once the data becomes corrupted. Seems like all repeated value like x11, x00, x22, are translated wrongly for some reason. And,
any value over 8 also wrongly translated. Any idea why? Use either hexdump or od give same result.
Asked by GeneCode
(157 rep)
Jul 10, 2019, 02:32 AM
Last activity: Jul 10, 2019, 07:59 AM
Last activity: Jul 10, 2019, 07:59 AM