I was trying to send some null characters \x00 to the ap2000 using echo, but it didn't work.
The idea here was to generate a small amount of graphics with ESC * 0 (single density graphics) specifying 4 columns of graphics.
The escape codes would be ESC * 0 \x04 \x00 followed by 4 bytes of dummy graphics \xFF \x00 \xFF \x00.
I could not figure out what was wrong...until I realized that hex 00 would be interpreted as "nothing".
Why? C strings are terminated when there's a \x00 character.
bash escape codes with $'\x00' disappear:
echo $'\e*0\x01\x001234' | hexdump -C
00000000 1b 2a 30 01 0a |.*0..|
00000005
but if I use echo -e all of the characters come through.
echo -e '\e*0\x01\x001234' | hexdump -C
00000000 1b 2a 30 01 00 31 32 33 34 0a |.*0..1234.|
0000000a
I also used printf and it was happy to emit \x00.
printf '\x1b*0\x04\x00\xff\x00\xff\x00' > lp0
printf '\x1bx0TEST\x1bx1TEST\x1bx0TEST\x1bx1TEST\n' > lp0
No comments:
Post a Comment