Logging serial port data to file

Rob Landley rob at landley.net
Fri Apr 2 23:32:40 UTC 2010


On Friday 02 April 2010 01:17:43 Denys Vlasenko wrote:
> On Tuesday 30 March 2010 04:35, Rob Landley wrote:
> > On Wednesday 24 March 2010 11:16:59 Michael Hagedorn wrote:
> > > Hi
> > > I am quite new to the busybox and need some help. I am trying to modify
> > > an embedded system on a NAS based on a STR8100 series hardware
> > > platform. I have the SDK. Busybox is installed on it and I can build it
> > > successfully.
> > >
> > > I want to log data arriving on the serial port (I am using a USB to
> > > serial device) to a file.
> >
> > netcat -f /dev/ttyS0 > file.txt
>
> If you are sure you have nc which understands -f. Standard one does not.

I made the busybox one do so in 2006 (in response to Lamont Yaroll needing 
that functionality), and he asked the question on the busybox mailing list.

 The netcat help also shows how to use busybox netcat as a minicom replacement 
via stty and netcat -f on the serial device.  I never understood why an entire 
applet was later added to replicate that function.

> > > Ideally with time stamps.
> >
> > netcat -f /dev/ttyS0 | while read i; do echo $(date +%s) "$i"; done >
> > file.txt
>
> Or: something | svlogd -tt LOGDIR
>
> svlogd has all typical things for logger tools like log rotation, see
> http://man.cx/svlogd%288%29

You can use a C program to replicate a one line shell script, sure.

Rob
-- 
Latency is more important than throughput. It's that simple. - Linus Torvalds


More information about the busybox mailing list