Linuix users? any idea on why i cant save stdout to file?

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rizla420
 
Posts: 332
Joined: Thu Feb 05, 2009 9:03 pm

Linuix users? any idea on why i cant save stdout to file?

Post by rizla420 »

Im trying to log serial data coming from the arduino and saving it to a file after i use grep to remove empty lines with this expression

cat /dev/ttyUSB0 | grep .

Typically if you want to write to a file you'd simply use the '>' character and specify the file to save to, like so:

cat /dev/ttyUSB0 | grep . > log.txt

for some reason, nothing is being written to the file. Any ideas on the proper way to pipe the grep output to a file?

There def is data coming from the serial port, just not being saved when piped to file..

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Linuix users? any idea on why i cant save stdout to file?

Post by mtbf0 »

you getting the data on your console with cat /dev/ttyUSB0 | grep .?

User avatar
rizla420
 
Posts: 332
Joined: Thu Feb 05, 2009 9:03 pm

Re: Linuix users? any idea on why i cant save stdout to file?

Post by rizla420 »

mtbf0 wrote:you getting the data on your console with cat /dev/ttyUSB0 | grep .?

yup, i've broken it up into steps to debug it.

so, cat /dev/ttyUSB0 basically shows all the data streaming realtime with the extra blank lines i'm trying to strip with grep.

next when i through the grep into the chain

cat /dev/ttyUSB0 | grep .

the output still streams as it should, but in the new format that i want. I just cant save the output to a log file for whatever reason.

I though it was the . after grep but i put it in "." and it still works, but didnt allow me to save.

cat /dev/ttyUSB0 | grep "."

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Linuix users? any idea on why i cant save stdout to file?

Post by mtbf0 »

how are you stopping the command? is the arduino sending an eof? you killing it with a ^c?

User avatar
rizla420
 
Posts: 332
Joined: Thu Feb 05, 2009 9:03 pm

Re: Linuix users? any idea on why i cant save stdout to file?

Post by rizla420 »

mtbf0 wrote:how are you stopping the command? is the arduino sending an eof? you killing it with a ^c?
i'm killing it with control-c . I thought using cat would have been the best because it will read it the whole time.

mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: Linuix users? any idea on why i cant save stdout to file?

Post by mtbf0 »

might let it run for awhile so the buffers can fill up and get dumped to disk.

mwr
 
Posts: 47
Joined: Sun Jun 07, 2009 3:08 pm

Re: Linuix users? any idea on why i cant save stdout to file?

Post by mwr »

This post at Arduino.cc may help with buffering.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”