Logging serial port data to file
Michael Abbott
michael at araneidae.co.uk
Thu Mar 25 10:11:11 UTC 2010
On Thu, 25 Mar 2010, Michael Hagedorn wrote:
> On 25.03.10 21:30, Peter Korsgaard wrote:
> > > Is there an easy way to disregard lines that contain only control
> > > characters or filter the text?
> > Sure, just use sed on the output from the serial port.
> Thanks a lot. I tried this:
>
> cat /dev/ttyUSB0 | sed "s/$(printf '\r')/foundHere/"
>
> and this
>
> cat /dev/ttyUSB0 | sed "s/$(printf '\x0D')/foundHere/"
>
> but it didn't work (output stayed the same). I tried it with some string that
> appears in the message and that worked.
> I wonder if the printf doe something to the '\r'.
sed isn't really the tool for this job, as its line handling tends to get
in the way. Try `tr -d '\r'` instead:
# echo $'\r\n' | hd
00000000 0d 0a 0a |...|
00000003
# echo $'\r\n' | tr -d '\r' | hd
00000000 0a 0a |..|
00000002
Actually, there may be a busybox bug in sed here, because when I try
`sed 's/\r//'` with GNU sed (version 4.1.5) it works as expected:
$ echo $'\r\n' | sed 's/\r//' | hd
00000000 0a 0a |..|
00000002
More information about the busybox
mailing list