I'm debugging a binary stream that is coming from a device file. I would like to have the output printed out in real time as hex values.
So far I've used tail -f /dev/ttyAPP2 | hexdump -C
but after I started missing some bytes in the output I understood that this could be a bad choice because it doesn't flush the data until a newline character is found.
There is an unofficial binary tail but I currently can't use that approach and am looking for a suggestion how to achieve this with other means?
Example
First the tty is set to raw mode.
stty -F /dev/ttyAPP2 raw
Here is what I get when listening to the device (this is real output)
root@Vdevice:/dev# hexdump -C < /dev/ttyAPP2
00000000 55 00 21 00 02 26 00 02 0b 00 09 02 06 01 00 01
00000010 99 0c ec 45 4f 01 03 47 41 54 45 57 41 59 43 54
However, the expected package should be (this isn't a real output):
root@Vdevice:/dev# hexdump -C < /dev/ttyAPP2
00000000 55 00 21 00 02 26 00 02 0b 00 09 02 06 01 00 01
00000010 99 0c ec 45 4f 01 03 47 41 54 45 57 41 59 43 54
00000020 52 4c 00 00 00 00 00 8b
The other part of the package gets printed out on arrival of the second package (this is real output)
root@Vdevice:/dev# hexdump -C < /dev/ttyAPP2
00000000 55 00 21 00 02 26 00 02 0b 00 09 02 06 01 00 01
00000010 99 0c ec 45 4f 01 03 47 41 54 45 57 41 59 43 54
00000020 52 4c 00 00 00 00 00 8b 55 00 21 00 02 26 00 02
00000030 0b 00 09 02 06 01 00 01 99 0c ec 45 4f 01 03 47
00000040 41 54 45 57 41 59 43 54 52 4c 00 00 00 00 00 8b
od -x < /dev/ttyAPP2
have the right format?xxd /dev/ttyAPP2
might be what you're looking fortail -f
is rarely useful for files other than regular files. Why aren't you using</dev/ttyAPP2 hexdump -C
?