Hi All,
I want to connect the TS-7200 to my TJ-Pro Robot through the COM2
port. i do the following
1. I disabled the getty ob COM2
2.i gave the follwoing preivladge "chmod a+rw /dev/ttyAM1"
3.I used the following C Code(note this code is okay on my FEDORA
Linux Desktop"
--------------------------------------
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
int main()
{
int fd,res;
struct termios options;
char buf[255];
fd = open("/dev/ttyAM1", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
fprintf(stderr, "open_port: Unable to open
/dev/ttyAM1 - %s\n",
strerror(errno));
}
bzero(&options, sizeof(options)); /* clear struct for new port
settings */
options.c_cflag = B9600 | ~CRTSCTS | CS8 | CLOCAL | CREAD;
/*
IGNPAR : ignore bytes with parity errors
ICRNL : map CR to NL (otherwise a CR input on the other
computer
will not terminate input)
otherwise make device raw (no other input processing)
*/
options.c_iflag = IGNPAR | ICRNL;
/*
Raw output.
*/
options.c_oflag = 0;
/*
ICANON : enable canonical input
disable all echo functionality, and don't send signals to
calling program
*/
options.c_lflag = ICANON;
printf("The File Discriptor is %d \n",fd);
tcflush(fd, TCIFLUSH);
tcsetattr(fd,TCSANOW,&options);
while (1)
{
res = read(fd,buf,255);
buf[res]=0; /* set end of string, so we can printf */
if(res==-1)
continue;
printf(":%s:%d\n", buf, res);
if (buf[0]=='z')
break;
buf[0]='L';
buf[1]='i';
buf[2]='n';
buf[3]='U';
buf[4]='x';
buf[5]=0;
write(fd,buf,4);
}
close(fd);
printf("The File Discriptor is %d \n",fd);
return 0;
}
--------------------------------------
the problem is on the write part. because when i connect the KIT to a
PC running hyper terminal the kit can read the
chracters stroked on the PC but it can not write anything to the hyper
terminal.
Note= if i connect my Fedora 3 desktop to the other PC and i ran the
same code(replace ttyAM1 by ttyS1 every thing is okay
even the wirite part!!!!!!!!!
Please any one has any idea.
------------------------ Yahoo! Groups Sponsor --------------------~-->
1.2 million kids a year are victims of human trafficking. Stop slavery.
http://us.click.yahoo.com/WpTY2A/izNLAA/yQLSAA/CFFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|