|
LInux下面我写了一个写串口的函数,一直往串口写字符串“this is a test”,然后通过串口调试工具看输出的内容,开始还是正确的,可是后来就不对了,请大哥给予小弟指点,谢谢!
代码如下:
open_port(const char *port_p)
{
int fd;
fd=open(port_p,O_RDWR|O_NONBLOCK);
if(fd==-1){
perror("Open port: Unable to open the serial port\n");
return 0;
}
return fd;
}
int fdcom2;
fdcom2=open_port("/dev/ttyS1");
while(1){
write(fdcom2, "this is a test\n",strlen("this is a test\n") );
}
|
|