#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include ...
int ttyWriterTester(int chan )
{
char ttyname[64];
char dbuf[128];
int ttyFd, len;
int i = 1000;
sprintf(ttyname,"/tyCo/%d", chan);
ttyFd = open (ttyname, O_RDWR, 0);
printf("Now Test Write with Port %s\n",ttyname);
ioctl(ttyFd,FIOSETOPTIONS,OPT_RAW);
ioctl(ttyFd,FIOBAUDRATE,115200);
ioctl(ttyFd,SIO_HW_OPTS_SET,(CLOCAL|CREAD|CS8)&~(HUPCL|STOPB|PARENB));
ioctl(ttyFd,FIOFLUSH,0);
sprintf(dbuf, " hello world!", ttyname);
len = strlen(dbuf);
while(1){
write(ttyFd, dbuf, len);
taskDelay(60);
}
close(ttyFd);
return 0;
}
int ttyReaderTester (int chan)
{
char ttyname[64];
char dbuf[128];
int ttyFd,len,result;
sprintf(ttyname,"/tyCo/%d", chan);
ttyFd = open (ttyname, O_RDWR, 0);
printf("Now Test Read with Port %s\n",ttyname);
len = sizeof(dbuf);
ioctl(ttyFd,FIOSETOPTIONS,OPT_RAW);
ioctl(ttyFd,FIOBAUDRATE,115200);
ioctl(ttyFd,SIO_HW_OPTS_SET,(CLOCAL|CREAD|CS8)&~(HUPCL|STOPB|PARENB));
printf("before read is called!\n");
while(1){
result= read (ttyFd, dbuf,len);
dbuf[result] = 0;
printf("read from line :%s \n",dbuf);
}
printf("after read .\n");
printf("before close is called\n");
close(ttyFd);
printf("after close\n");
return 0;
}
阅读(3092) | 评论(0) | 转发(0) |