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

📄 exp2_write.c

📁 《嵌入式Linux应用程序开发详解》一书的源代码之第六章
💻 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>
#include "serial.h"

int main(void) 
{
	int fd;
	int nwrite,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);
	nwrite=write(fd,buff,8);
	printf("nwrite=%d\n",nwrite);
	close(fd);
	return;
}

⌨️ 快捷键说明

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