📄 ttytestold.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "rs232.h"//#define DEBUGint main(int argc, char *argv[]){ int ret1; int ret,portno,nWritten,nRead; char buf[256]; portno=0; //while(1) //{ ret=OpenCom(portno,"/dev/ttyS0",115200);//open the com 1 portno=1; ret1=OpenCom(portno,"/dev/ttyS1",115200);//open the com 2 if(ret==-1) { perror("The /dev/ttyS0 open error."); exit(1); }//------------------------------------------------------------ if(ret1==-1) { perror("The /dev/ttyS1 open error."); exit(1); }//------------------------------------------------------------ // nWritten=ComWrt(portn1,"please input:",12); // printf("/dev/ttyS0 has send %d chars!\n",nWritten); printf("\nRecieving data!**"); fflush(stdout); nRead=ComRd(1,buf,256,30000);//receive the data from the com 2 printf("nread=%d\n",nRead); if(nRead>0) { printf("ok*****OK\n"); } else { printf("Timeout\n"); ret=CloseCom(portno);//close the com 2 } ret=CloseCom(portno); if((ret=CloseCom(portno)==-1)) { perror("Close com"); exit(1); } printf("ok*****************end\n"); //}//end while 1 printf("Exit now.\n"); return;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -