Linux-串口配置,初始化及使用

【查看串口】4412采用 ttySAC*系列串口设备节点 ,即 ttySAC0 , ttySAC1 , ttySAC2 , ttySAC3【打开串口设备节点】“/dev/ttySAC3”形成fd 与 设备节点的/dev/ttySAC3链接【初始化配置串口】#include <termios.h>#include <unistd.h>struct termio { unsig...
摘要由CSDN通过智能技术生成
【查看串口】
4412采用 ttySAC*系列串口设备节点 ,即 ttySAC0 , ttySAC1 , ttySAC2 , ttySAC3


【打开串口设备节点】
“/dev/ttySAC3”
形成fd 与 设备节点的/dev/ttySAC3链接


【初始化配置串口】
#include <termios.h>
#include <unistd.h>
struct termio {
unsigned short c_iflag; /* 输入模式标志 */
unsigned short c_oflag; /* 输出模式标志 */
unsigned short c_cflag; /* 控制模式标志 */
unsigned short c_lflag; /* 本地模式标志 */
unsigned char c_line; /* line discipline */
unsigned char c_cc[NCC]; /* control characters */
};
int tcgetattr(int fd, struct termios *termios_p); //获取fd所代表的串口的 termios 结构体值
int cfsetispeed(struct termios *termios_p, speed_t speed);
//设置termios_p B2400,B4800,B9600,B115200,B460800 


speed_t cfgetispeed(const struct termios *termios_p)
//获取 termios_p 的波特率


int tcflush(int fd, int queue_selector);
/*清除串口中没有完成输入或输出的数据
TCIFLUSH  清除正收到的数据,且不会读取出来
TCOFLUSH  清除正写入的数据,且不会发送至终端
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值