0

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.

1
  • Anybody have any idea why this problem occur? Or do I have a buggy "od" binary or something?
    – GeneCode
    Jul 11, 2019 at 10:16

1 Answer 1

1

od shows that you are just receiving 254 Decimal here, the left par is the "line number".

I think the problem here is how you send the data, or your /dev/ttyS1 permissions, could you develop more on that part ?

Also what do you see if you use xxd -r ?

6
  • Hi. I am aware that left part is "index" or "line number". what I don't get is why I get 00fe, when I am sending a "Hexadecimal packet" of value \x00\x11\x22 from my Windows PC. Also i updated the stty that i used in my question.
    – GeneCode
    Jul 10, 2019 at 3:11
  • Also, if I am sending "\x00", nothing is printed by od.
    – GeneCode
    Jul 10, 2019 at 3:13
  • My unix distro (busybox) dont have xxd installed.
    – GeneCode
    Jul 10, 2019 at 3:30
  • Strange then, how do you exactly send the data ?
    – Ayato_k
    Jul 10, 2019 at 7:18
  • I make my own software using Qt (C++). Where I have a text input so I can type hex value as text "001122" then i convert this string to UTF8 and convert to QByteArray and write it to the serialport object.
    – GeneCode
    Jul 10, 2019 at 7:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .