📄 chuankoufa.c
字号:
#include<stdio.h>#include<sys/ioctl.h>#include<termios.h>#include<stdlib.h>#include<sys/types.h>#include<sys/socket.h>#include<netinet/in.h>#include<arpa/inet.h>#include<unistd.h>#include<netdb.h>#include<sys/stat.h>#include<fcntl.h>#include<signal.h>#include<sys/time.h>#include<pthread.h>struct termios tio;int fd;void main(){ if((fd = open("/dev/ttyS0",O_RDWR |O_NDELAY |O_NOCTTY))<0) { printf("Couldn't open\n"); exit(1); } else { printf("comm open success!\n"); } tio.c_cflag = B115200 |CS8 |CREAD | CLOCAL; tio.c_cflag &=~HUPCL; tio.c_lflag = 0; tio.c_iflag = IGNPAR; tio.c_oflag = 0; tio.c_cc[VTIME] = 0; tio.c_cc[VMIN] = 0; tcflush(fd,TCIFLUSH); tcsetattr(fd,TCSANOW,&tio); fcntl(fd,F_SETFL,FNDELAY); while(1) { write(fd,"$R4C10$",7); sleep(1); } printf("serial init\n");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -