Virtual COM port on Linux
sjansen at buscaluz.org
Mon Mar 15 12:44:09 MDT 2010
On Mon, 2010-03-15 at 12:32 -0600, Dave Smith wrote:
> Dave Smith wrote:
> > That's what I was looking for. I didn't escape the 'x' when I tried
> > initially.
> Actually, that appears to not work as I expected. The first problem is
> that echo needs -n to *not* print a newline character, which would not
> normally be a problem (but for purity's sake I added -n). The second
> problem is that the last byte (0x00) does not get written to the device,
> I assume because echo interprets it as a null-termination character.
> After it failed to turn on the relay, here's what I did to investigate:
> echo -n $'\xff\x01\x00' > /tmp/foo.txt
> hexdump -C /tmp/foo.txt
> 0000000 ff 01
> And ls -l confirms that the file is only 2 bytes in size (not 3 as I
> expected). Is it not possible to write a 0x00 byte as the final byte
> using echo?
> Any ideas why this happens?
Because echo is merely processing its argv and the '\0' is seen as
terminating the arg, not part of the arg.
"XML is like violence: if it doesn't solve your problem, you aren't
using enough of it." - Chris Maden
More information about the PLUG