Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Problem with redirecting from serial device



I have been playing around with weather station receiver software on the
Arduino. The Arduino outputs serial data over USB on device ttyACM0.

The incoming data is not timestamped, so I have a small awk script to add this
as the data is received:

#!/usr/bin/awk -f

{
    dt = strftime("%Y-%m-%d %H:%M:%S", systime(), 0)
    print dt " " $0
}

When I run the script with output going to the terminal, everything looks to
be working just fine:

ian@nibbler[1568]~% ./dt-add.awk < /dev/ttyACM0
2013-07-18 15:34:18 [OS V3 Sensor Capture/Decode]
2013-07-18 15:35:16 Wind Gust: 2.33    Wind Avg: 2.42    Dir: NW
2013-07-18 15:36:02 Temp: 17.11   Humidity: 61
2013-07-18 15:36:55 Temp: 17.01   Humidity: 61

As soon as I add a redirect or pipe to the above (to save the data to a file
or for further processing) no data appears:

ian@nibbler[1570]~% ./dt-add.awk < /dev/ttyACM0 > weather.out
# A few minutes later
^C
ian@nibbler[1571]~% ls -lh weather.out
-rw-rw-r-- 1 ian ian 0 Jul 18 15:47 weather.out

I don't think it's a file buffering issue, I've left it go for several hours
with the same results. Even if I try 'more'ing the data I seem to get no
output.

Dumping the raw data to a file seems to be fine.
< /dev/ttyACM0 > foo
works as expected.

Can anyone please explain where the issue is?

-- 
All computers run at the same speed...with the power off.



Messages sorted by: Reverse Date, Date, Thread, Author