serial.h
来自「linux下用QT 做的串口编程工具,在linux下做串口调试有一定的参考价值」· C头文件 代码 · 共 44 行
H
44 行
#ifndef __SERIAL_H_#define __SERIAL_H_#include <stdio.h>#include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> #include <sys/file.h>#include <fcntl.h> #include <termios.h> #include <errno.h> #include <pthread.h>typedef struct tty_info_t{ int fd; pthread_mutex_t mt; char name[24]; struct termios ntm; struct termios otm; } TTY_INFO;class Serial{ public: Serial( ); ~Serial( ); bool readyTTY(int fd); int cleanTTY(); int setTTYSpeed(int speed); int setTTYParity(int databits,int parity,int stopbits); int recvnTTY(char *pbuf,int size); int sendnTTY(char *pbuf,int size); int unlockTTY(TTY_INFO *ptty); int lockTTY(); private: TTY_INFO pttyInfo; TTY_INFO *ptty;};#endif //__SERIAL_H_
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?