[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Reading data from serial port into pipe?



Hello all,

I have Debian running on a Linksys NSLU2:

slug:~# uname -a
Linux slug 2.6.18-5-ixp4xx #1 Sun Dec 23 05:17:39 UTC 2007 armv5tel GNU/Linux

With this nifty little machine, I want to log data from my solar heating
controller. The controller send data over a serial line attached to a
USB-to-Serial converter on the slug's USB2 port. I can read data from this
port just fine with "cat /dev/ttyUSB0" and also write these data into a
file using "cat /dev/ttyUSB0 > filename". So far so good.

However, I want to process these data in "real time" by piping them into a
script that uses sed and awk to format the data for being stored into a
rrdtool database. This does not work, however. Even a simple "cat
/dev/ttyUSB0 | sed 's/\x0/\n/g'" to replace the nullbytes used as record
separators by the controller with newlines does not output anything. Using
this simple sed script on the file filled with data from the serial port
works just fine! I also tried using a named pipe, but reading from that
pipe results in many characters being lost.

Any idea why the serial port behaves in such a way and any solutions for
my problem?

Regards, Richard


Reply to: