赞
踩
- int open_port(constchar* dev_path)
- {
- int fd;
-
- //open uart
- fd = open(dev_path, O_RDWR|O_NOCTTY|O_NDELAY);
- if(fd <0)
- {
- perror("open serial port");
- return-1;
- }
- if(fcntl(fd, F_SETFL,0)<0)//设置为阻塞模式,后面启动的线程会阻塞,串口有数据才读
- perror("fcntl F_SETFL\n");
- /*if(isatty(STDIN_FILENO) == 0)//再次验证是否为终端设备,我用的刷卡器,屏蔽了这个,不然会失败
- {
- perror("standard inpput is not a terminal device");
- }*/
-
- return fd;
- }

- int set_com_config(int fd,int baud_rate,int data_bits,char parity,int stop_bits)
- {
- struct termios
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。