- 串口配置:波特率115200、8位数据、无校验位、1个停止位
参考 https://www.arduino.cc/en/Serial/Begin
代码块
/* Open serial port /dev/ttyACM0 */
int fd; /* File descriptor for the port */
fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY);
/* Configure */
struct termios options;
/* Get the current options for the port... */
tcgetattr(fd, &options);
/* Set the baud rates to 115200... */
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
/* 8 bits, no parity, one stop bit */
options.c_cflag &= ~PARENB;
options.c_cflag |= CSTOPB;
options.c_cflag &