ts-7000
[Top] [All Lists]

Re: [ts-7000] set com2 to receive data from GPS board.

To:
Subject: Re: [ts-7000] set com2 to receive data from GPS board.
From: "Don W. Carr" <>
Date: Fri, 17 Nov 2006 12:17:54 -0600
You have the device name hard-coded, so you do not need the command line argument. Take out the following if statement, or correctly use the command line argument passed:

if(argc <2)
{
printf("serial_tester<device>\n");
return 0;
}



On 11/17/06, soniathakur3 <> wrote:


Hi,

I have to connect com2 on TS200 with aGPS module. The code that i am
using is :

#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include<fcntl.h>
#include <assert.h>
#include <termios.h>
#include <sys/stat.h>

int open_port(char* device_name)
{
int file_id;
file_id = open("/dev/ttyAM1", 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, 512);
lines ++;
/* Add terminator and print if non-zero */
if(count > 0)
{
buffer[count] = '0\n';
printf("line %d characters %d\n", lines, count);
printf("%s\n",buffer);
}
else
{
printf("Zero characters read\n");
}
}
return 0;
}

void port_configuration(int file_id)
{
struct termios options;

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);

options.c_cflag=CLOCAL|CREAD|CS8;
options.c_lflag = ICANON;
options.c_iflag = 0;
options.c_oflag = 0;
cfsetispeed(&options,B4800);
cfsetospeed(&options,B4800);
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 blocking and read the port */
read_port(file_id);
close((file_id));
return 0;
}

but the output i keep on getting is:
serial_tester<device>

what is wrong with this code?

thanks
Sonia




--
Dr. Don W. Carr
J. G. Montenegro 2258
Guadalajara, Mexico
+52-333-630-0704
+52-333-836-4500 ext 2930 __._,_.___


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