woodc
Posts: 7
Joined: Sun Nov 25, 2012 11:12 pm

Redirect serial output to file

Sun Nov 25, 2012 11:23 pm

I have an Arduino connected to my Pi and it seems to be working as expected. If I run the Arduino IDE and use the serial monitor pointed to /dev/ttyACM0 I see the data expected.

If I try to cat /dev/ttyACM0 I also see some data however it immediately returns to the command prompt instead of staying open and showing continued serial data.

This brings me to my question: How can I redirect the serial output to a file? On the beaglebone and other linux boxes I simply cat /dev/ttyACM0 >> /home/blah/serial.log then I can use tail to get the most recent data for use by scripts/posting to Cosm, etc from the serial.log file. On the Pi this does not work...it creates the file but immediately closes.

Thanks all

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Redirect serial output to file

Mon Nov 26, 2012 12:14 am

I use minicom capturing to a file

Code: Select all

minicom -C /root/capture >> /dev/null
I run it from rc.local. Then I cat and tail the capture file. I also make a copy periodically and tail the copy back to the capture file to keep it from growing indefinitely.

On another arm linux box I just cat and tail the device as you described. The above is a Pi workaround.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

woodc
Posts: 7
Joined: Sun Nov 25, 2012 11:12 pm

Re: Redirect serial output to file

Wed Nov 28, 2012 2:32 am

Thanks for the reply :) I will try that again but I am fairly certain this was also dying/quitting instead of running nonstop....

User avatar
lindymood
Posts: 10
Joined: Wed Feb 06, 2013 6:43 pm

Re: Redirect serial output to file

Thu Feb 07, 2013 4:13 pm

Check out my recent post. Perhaps this may help?

http://www.raspberrypi.org/phpBB3/viewt ... 37&t=26285

Return to “General discussion”