⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 write_seri.c

📁 Linux 下 C 库及常用 系统调用的使用事例
💻 C
字号:
/*写串口程序*/#include <stdio.h>#include <string.h>#include <sys/types.h>#include <errno.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <termios.h>#include <stdlib.h>/*读串口程序*/int main(void) {	int fd;	int nread,i;	char buff[]="Hello\n";	if((fd=open_port(fd,1))<0){//打开串口		perror("open_port error");		return;	}	if((i=set_opt(fd,115200,8,'N',1))<0){//设置串口		perror("set_opt error");		return;	}	printf("fd=%d\n",fd);	nread=read(fd,buff,8);//读串口	printf("nread=%d,%s\n",nread,buff);	close(fd);	return;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -