I want to read /dev/input/mice
with hexdump. Format is described at here at StackOverflow. What I need is to read one byte (flags), print it in hex format, then read two bytes (x and y move offset) and print each in signed decimal format.
I use hexdump from util-linux 2.28 on Arch Linux.
The best I was able to put together is
hexdump /dev/input/mice -e '/1 "%03x" 2/1 " %03d" /0 "\n"'
The format string:
/1 "%03x"
reads one byte and prints it as hex number2/1 " %03d"
reads one byte and prints it as signed decimal integer, repeats two times/0 "\n"
reads zero bytes and prints end of line
The problem is that for value 0xFF the %d
specifier prints 255 instead of -1. The format is taken from C, which extends the width properly, so how to force this proper width extension here?
hexdump
from bsdmainutils (tried 9.0.3 and 9.0.5ubuntu). Which version are you using?hexdump
comes from util-linux. On Debian it comes from bsdmainutils. There seems to be an incompatibility between the two versions!