|
楼主 |
发表于 2006-6-19 10:49:49
|
显示全部楼层
把程序贴上
int retv;
char fname[16],hd[16],*sbuf;
struct termios oldtio,newtio;
fd=open("/dev/ttyS1",O_RDWR|O_NOCTTY);
perror("open /dev/ttys1");
if(fd<0)
{
perror("open failed");
return -1;
}
tcgetattr(fd,&oldtio);
cfmakeraw(&oldtio);
cfsetispeed(&oldtio,B19200);
cfsetospeed(&oldtio,B19200);
tcsetattr(fd,TCSANOW,&oldtio);
fname[0]='1';
fname[1]='2';
fname[2]='3';
fname[3]='\0';
sbuf=(char *)malloc(4);
strncpy(sbuf,fname,4);
retv=write(fd,sbuf,4);
retv=write(fd,sbuf,4);
if(retv==-1) perror("write");
close(fd);
return 0; |
|