ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Help connecting to GPS on com2

To:
Subject: Re: [ts-7000] Re: Help connecting to GPS on com2
From: Per Öberg <>
Date: Sat, 24 Feb 2007 15:41:08 +0100
Hello, I'm not quite sure what your problem is. I can only find one
reference to "res" in your e-mail so I'm not sure what you mean by "res
returns a -1". It is quite usual to use -x to refer to an erroneous
condition (where x is some integer value) so it might mean anything
depending on what function it is returning it.

Please provide the output from a testrun and some information about what
function it is that returns -1 and someone might be able to help you. If
you are unsure of what function it is that returns -1 you can always do
some "bread crum debugging" using printf.

Per Öberg

prcarnly skrev:
> I am a newbie to the 7250 as well as to linux. I need to read a rs232
> signal from my com2 port and have tried lots of code from online
> guides with no sucess so I turned to this group and found this post
> and have used the code displayed below. I have even commented out the
> getty. I am getting a -1 read error when I run the code. The port
> opens, but res returns a -1. Can anyone help with what may be going
> on with this or what this error means? I've searched online and have
> not found this error. Thank you in advance for any help.
>
> Renee
>
>
> --- In  Jim Jackson <> wrote:
>>
>>
>>
>> On Sat, 7 Oct 2006, Rob wrote:
>>
>>> I have been trying to connect to a Garmin GPS and just echo the
> NMEA
>>> data to the console for a proof of concept.  While I think I am
> getting
>>> closer it still just shows zero for the data received.  I have
> looked at
>>> many examples here and the code is starting to look correct.
> Also if I
>>> log onto the board using COM2 it asks for a password ???
>> You say you can login to "com2". That means you have a "getty"
> running on
>> that line too. You will need to stop the getty process so your
> program has
>> sole access to the port.
>>
>> comment out the line in /etc/inittab that tells init to run getty on
>> /dev/ttyAM1, then send init a HUP signal to reread the inittab file
>> (kill -1 1)
>>
>>> Here is the code and the settings are the standard ones on the
> Debian
>>> release (using the CF card and Debian)
>>>
>>> #include <stdio.h>
>>> #include <termios.h>
>>> #include <sys/types.h>
>>> #include <sys/stat.h>
>>> #include <fcntl.h>
>>>
>>>
>>> int open_port(char* device_name)
>>> {
>>>     int file_id;
>>>
>>>     file_id = open(device_name, O_RDONLY | O_NOCTTY | O_NDELAY);
>>>     if(file_id == -1)
>>>     {
>>>       printf("Failed to open device\n");
>>>     }
>>>     return file_id;
>>> }
>>>
>>> int read_port(int file_id)
>>> {
>>>     char            buffer[512];
>>>     int             count=0;
>>>     int             lines = 0;
>>>
>>>     while(lines < 50)
>>>     {
>>>             read(file_id, buffer, count);
>>>             lines++;
>>>             /* Add terminator and print if non-zero */
>>>             if(count > 0)
>>>             {
>>>                     buffer[count] = '\0';
>>>                     printf("Line %d has %d characters\n", lines,
> count);
>>>                     printf("%s\n", buffer);
>>>             }
>>>             else
>>>             {
>>>                     printf("Zero characters read\n");
>>>             }
>>>     }
>>> }
>>>
>>> void port_configuration(int file_id)
>>> {
>>>     struct termios options;
>>>     int            x;
>>>
>>>     tcgetattr (file_id, &options);
>>>     printf("speed in %d out %d\n", options.c_ispeed,
> options.c_ospeed);
>>>     printf("mode in %d out %d\n", options.c_iflag,
> options.c_oflag);
>>>     printf("control flag %d\n", options.c_cflag);
>>>     printf("local flag %d\n", options.c_lflag);
>>>
>>>     cfsetispeed(&options, B4800);
>>>     cfsetospeed(&options, B4800);
>>>     options.c_cflag = 2096;
>>>     options.c_lflag = 4;
>>>     options.c_oflag = 0;
>>>     options.c_cflag |= (CLOCAL | CREAD);
>>>     options.c_cflag &= ~PARENB;
>>>     options.c_cflag &= ~CSTOPB;
>>>     options.c_cflag &= ~CSIZE;
>>>     options.c_cflag |= CS8;
>>>     options.c_cflag &= ~CRTSCTS;
>>>     tcsetattr (file_id, TCSANOW, &options);
>>> }
>>>
>>> int main(int argc, char* argv[])
>>> {
>>>     int file_id;
>>>
>>>     /* Check the command */
>>>     if(argc < 2)
>>>     {
>>>             printf("serial_tester <device>\n");
>>>             return 0;
>>>     }
>>>     /* Open the port */
>>>     printf("Opening device %s\n", argv[1]);
>>>     file_id = open_port(argv[1]);
>>>     /* Get port configuration */
>>>     port_configuration(file_id);
>>>     /* Set the port to non bolocking and Read the port */
>>>     read_port(file_id);
>>>     close((file_id));
>>> }
>>>
>>>
>>> Thanks for helping a newbie out.  Also I am open to any suggested
> reading that would
>>> have let me find it myself.
>>>
>>>
>>>
>>>
>>>
>>>
>
>
>
>
>
>
> Yahoo! Groups - Join or create groups, clubs, forums &amp; communities. Links
>
>
>


------------------------ Yahoo! Groups Sponsor --------------------~-->
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/lOt0.A/hOaOAA/yQLSAA/CFFolB/TM
--------------------------------------------------------------------~->


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