-------------------------------------资源来源于网络,仅供自学使用,如有侵权,联系我必删.
第一:
实验-串口接收
串口接收使用 read 函数,在文件 io 中已经介绍过了。
串口接收例程
来看一下头文件,如下图所示。
接着看一下 main 主函数
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <errno.h>
int set_opt(int,int,int,char,int);
//"/dev/ttySAC3"是con2,靠近耳机接口的串口
void main()
{
int fd,nByte;
char *uart3 = "/dev/ttySAC3";
//定义一个 buffer 接收数据
char buffer[512];
char *uart_out = &