ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Capturing serial port to text

To:
Subject: Re: [ts-7000] Re: Capturing serial port to text
From: David <>
Date: Sat, 03 Mar 2007 20:43:29 -0600
Here is the code I use and to gather GPS data. Seems to work well.  The port open code (gps.h) is in the files area.
Hope that helps. David

fd = open_gpsport(); //opens the comm port for use
if(fp==NULL) printf("Can not open GPS port\n");
if (fp != NULL)
{
while (1)
{
ioctl(fd,FIONREAD,&bytes); //indicates there is data to read
if (bytes > 0)
{
read(fd,buf,512);
printf("%s\n", buf);
}


yoobb wrote:

--- In .com, "yoobb" m("...","yoobb");"><> wrote:
>
> Does anybody have any ideas on how to easily capture serial port input (either COM1 or
> COM2) to a text file? Ideally, I would like the TS-7200 to continuously direct serial port
input
> to a text file, appending to the same file (or a new file) with each restart.
>
> The only idea I have so far is to install minicom and set up a boot script that starts
minicom
> and directs it to a text file automatically.
>
> TIA!
>

Thanks to both people who've replied so far!

For now, I am successfully redirecting COM2 to a log file. The device file is /dev/ttyAM1. I
found out (on this board) that I first have to comment out the line in the file /etc/inittab
containing "getty" and "ttyAM1". Apparently, getty is a program that, by default, uses the
serial port. Commenting out this line frees up the serial port for my own use.

I then added a boot script to /etc/rc2.d, naming it "S99datarecord". The script contains:

stty -F /dev/AM1 ispeed 4800
stty -F /dev/AM1 ospeed 4800
stty -F /dev/AM1 igncr
cat /dev/AM1 >> /home/me/log

The first two lines set the desired speed. The third line says to ignore carriage returns.
Before I put in the igncr, I was getting double-spaced output. Apparently, my device uses
<CR><LF> to end a line (like DOS) and the serial port must've been converting the CR to a
second LF. igncr throws out the extraneous CR.

I also had to set executable permissions: chmod +x S99datarecord.

This is crude, but it works. The only problem is the data capture occurs midstream and
stops midstream, so the first and last lines of data are partial lines. If I were to use the
text file as is, I would have to strip out the the first and last lines of every session.

I'll explore more sophisticated methods as time permits. The previous response lists
some very promising suggestions.

Thanks to all!


-- 
David..........
You have been on the computer to long when,
You start tilting your head sideways to smile :-) 
__._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU