ts-7000
[Top] [All Lists]

Re: [ts-7000] Com2 Problem TS-7250

To:
Subject: Re: [ts-7000] Com2 Problem TS-7250
From:
Date: Tue, 06 Feb 2007 01:42:33 -0500
>I get $GPSRMC and a 
>few other messages and then it pauses for a while and then just 
>keeps outputing "buff= ". I would like to read the stream 
>continuosly. Any idea what is screwed up?

>  while (1)
>    {
>    read(fd,buf,512);
>    printf("buf = %s\n" ,buf);
>    }

read() does not return a C string in the buffer.  It fills the array
with the bytes that were read, and doesn't modify any of the other bytes.
The %s format expects an array of non-zero bytes, followed by a 0x00.

Since the data you are reading is inconsistent with the way you are
printing it, something funny might be happening.  To get a better view
of the data coming across the line, try:

while (1)
        {
        int x,n;
        n = read(fd, buf, 512);
        if (n < 0)
                {
                perror("read error");
                break;
                }
        printf("%d bytes: ",n);
        for (x=0; x<n; x++)
                printf("%02x ",buf[x]);
        printf("\n");
        }

I use %02x because it is usually easier to understand serial communication
problems if you can see ALL the characters involved.  You could use %c,
but then a backspace would move the cursor left instead of displaying
something you can see, ^G would make the terminal beep, etc.  You can
also use something like
        printf("%c", isprint(buf[x])?buf[x]:'.');

There might be some other problems, but you might as well try this to
get a better idea what is really going on.

Mark S.


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<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