Carriage returns and line feeds

I had a problem with using a very basic SLIP protocol on an Arduino-XBee based device, and getting the data into Linux.

What was happening was that the byte 13 disappeared, which is logical as it turns out to be the carriage return.
But when I escaped the byte 13, with byte 92, it came out as 92 10, instead of the expected 92 13.

Apparently the default setting, at least in my version of linux, of the tty-interface (through which all serial devices have to go) is to translate carriage returns into new lines.

You can change it by doing

$ stty -F /dev/ttyUSB0 -icrnl

and that fixes the problem!

Apparently you can also set it from the C-code, which I might add as a fix in the SC code…

Leave a Reply