1.编程方法
Linux下串口编程,可以使用简单的open ,read, write, close
方法,但是没有配置串口属性。所以,更多的我们是需要学习怎么配置串口的数据位、校验位等属性。
这里对串口协议,编程方法,函数参数等有极详尽的解释。
这里有对函数参数的中文解释。
这里有例程,可以帮助你快速写出测试程序。
2.例程
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <termios.h>
#define DEV_NAME "/dev/ttySP1"
int open_serial(char *serial)
{
int fd_uart;
struct termios uart_conf;
fd_uart = open(serial, O_RDWR | O_NOCTTY | O_NONBLOCK);
if(fd_uart