📄 cserial.h
字号:
/*********************************************
* 串口类 by jekin
* 2006.3.22
*
*********************************************/
#include <stdio.h> // 标准输入输出定义
#include <fcntl.h> // 文件控制定义
#include <string.h> // bzero
#include <stdlib.h> // exit
#include <sys/times.h> // times
#include <sys/types.h> // pid_t
#include <termios.h> // POSIX控制终端定义,termios, tcgetattr(), tcsetattr()
#include <unistd.h> // UNIX标准函数定义
#include <sys/ioctl.h> // ioctl
#define false 0#define true 1
#ifndef _CSERIAL_H
#define _CSERIAL_H
//串口信息
class PortInfo{public:
int baudrate; //波特率
char databit; //数据位, 5,6,7,8
char parity; //奇偶校验, N:none, O:odd, E: even
char stopbit; //停止位, 1,2
char tty; //tty: 0,1,2,3,4,5
char flowctl; //流控制, 0:none, 1:hardware, 2:software
};
//串口操作类
class CSerial{
public:
CSerial(int baud, char databit, char parity, char stopbit, char tty, char flowctl);
CSerial::~CSerial();
int PortOpen();
int PortSet(int fd);
int PortRead(int fd, char* buffer, int readlen);
int PortWrite(int fd, char* data, int datalen);
int PortClose(int fd);
private:
//串口信息指针
PortInfo* PPortInfo;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -