Pages: [1]   Go Down
Author Topic: Serial to file?  (Read 3232 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone have any suggestions for an application that can log serial inputs to file?  For linux or windows, I don't mind.

I've got my arduino reading temperatures and printing them to the serial monitor - now I just want to be able to log these readings to file so I can report on them later.
Logged

California
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Ciao a tutti.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check out screen on your linux computer. Usage should be something like: screen /device/.... BAUDRATE


You can use the -X tag to create a hardcopy of the output.


Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

in windows you can use the Hyperterminal app. that comes with all windows versions
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 137
Posts: 6805
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use "minicom" which is a pretty standard linux/unix app.
You'll find that most programs aimed at serial communications will have some sort of log-to-file capability.  If you're looking for something that runs invisibly in the background, or generates timestamps, or stuff like that, it might be more difficult.  You could look at the things aimed at "console management" (of server farms) like "conserver"...
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you enjoy programming, another approach is to write a simple sketch in Processing that monitors the serial port and writes incoming data to a file. You could add a graph of the most recent readings if you wanted to display something like that.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using linux you can try
Code:
tail -f /dev/ttyUSB0 > filename
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 116
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried the tail command, it created the file but never wrote to it. I'm not to deep into unix, so maybe it's something simple.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 9
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just digging up an old thread I started a while ago to see if anyone has any new ideas?

I have a sketch that prints values to serial - I would love to be able to save these to file and then report on them later.

Any tips?
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

depends on OS /software , what are you using?
« Last Edit: January 03, 2011, 01:50:49 am by Osgeld » Logged


Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 227
Posts: 14048
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

mini serial capture in python
Code:
import sys, os, serial, threading

def monitor():

    ser = serial.Serial(COMPORT, BAUDRATE, timeout=0)

    while (1):
        line = ser.readline()
        if (line != ""):
            #print line[:-1]         # strip \n
            fields = line[:-1].split('; ');
            // ID = fields[0]
                  // TIME = int(fields[1])
            # print fields
            print "device ID: ", ID
            # write to file
            text_file = open("Pdata.log", "w")
            text_file.write(line)
            text_file.close()

        # do some other things here

    print "Stop Monitoring"


""" -------------------------------------------
MAIN APPLICATION
"""  

print "Start Serial Monitor"
print

COMPORT = 4;
BAUDRATE = 115200

monitor()

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using a Windows PC, GoBetwino can log data from Arduino to a txt file. It's even possible to make CSV files that can be imported to databases or spreadsheet programs.

If needed GoBetwino will allow you to send data directly into Excell cells.

http://www.mikmo.dk/gobetwino.html
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The tail suggestion for linux doesn't stop reading and doesn't close the file until you stop it yourself. I program the arduino to send the stuff over and over, and use

 
Code:
cat /dev/ttyUSB0|head -n 5 > fred.txt

It reads 5 lines of output and saves it  to a file fred.txt and stops.

You may need to use stty to set the port to the correct baudrate etc beforehand

Code:
stty -F /dev/ttyUSB0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts -clocal

If you're using a new fangled arduino /dev/ttyACM0 is the 'standard' port name rather than /dev/ttyUSB0

« Last Edit: January 03, 2011, 03:17:49 am by stephen_t » Logged


Pages: [1]   Go Up
Jump to: