Logging serial port data to file

Michael Hagedorn michael at hagedorn.co.nz
Thu Mar 25 08:59:36 UTC 2010


On 25.03.10 21:30, Peter Korsgaard wrote:
>>>>>> "Michael" == Michael Hagedorn<michael at hagedorn.co.nz>  writes:
>>>>>>              
>   Michael>  Is there an easy way to disregard lines that contain only control
>   Michael>  characters or filter the text?
>
> Sure, just use sed on the output from the serial port.
>
> Busybox sed doesn't seem to handle escape characters so you cannot just
> do sed 's/\r//', but you can use printf:
>
> sed "s/$(printf '\r')//"
>
>    

Hi

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'.

Any advise?




More information about the busybox mailing list