树莓派串口
串口的初始化常用函数
int tcgetattr(int fd , struct termios * termios_p)
int cfsetispeed(struct termios * termios_p, speed_t speed)
句柄 speed B115200 8位数据位 无奇偶校验 一位停止位 一共5个参数!
int cfsetospeed(struct termios * termios_p, speed_t speed)
int tcflush(int fd, int queue_selector)
- 由于树莓派3B+ 和 4B版本的硬件没有直接配置uart,需要写配置文件,使能相应的引脚!
- vim 查找字符串 /***
- 在文件夹 /boot/overlays 中找到 pi3-miniuart-bt
- 使得 serial 0 指向 GPIO 串口,serial 1 指向 ttys0
- 关闭控制台