zsh-users
 help / color / mirror / code / Atom feed
From: Ian Petts <ipetts@gmail.com>
To: zsh-users@zsh.org
Subject: Problem with redirecting from serial device
Date: Thu, 18 Jul 2013 15:59:32 +1000	[thread overview]
Message-ID: <20130718055932.GA9525@kvm1.pettsie.net> (raw)

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.


             reply	other threads:[~2013-07-18  5:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18  5:59 Ian Petts [this message]
2013-07-18 22:11 ` Phil Pennock
2013-07-19  7:34   ` Ian Petts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130718055932.GA9525@kvm1.pettsie.net \
    --to=ipetts@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).