// // Created by matrixai on 3/26/24. // #ifndef TRAIN_RFID_LINUX_BASECOMPORT_H #define TRAIN_RFID_LINUX_BASECOMPORT_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include "AppCommon.h" #define SOCKET_TIME_OUT_SETTING 10 class BaseComPort { public: BaseComPort(); ~BaseComPort(); //打开comport通信 int32_t ttyOpen(std::string strName); //关闭comport通信 int32_t ttyClose(); //设定波特率 int32_t ttySetBaud(int nbaud, int ndatabits, std::string nparitybits, int nstopbits); //读取comport数据 int32_t ttyRead(); //写入comport数据 int32_t ttyWrite(char *buf, int32_t count); //是否运行 bool bRuning(); //获取Buffer信息 int32_t vGetBuffer(char *chOutBuff, int32_t nSize); int32_t vGetMaxBufferSize(); private: int32_t fd = -1; //运行状态 bool bRun = false; char chbuffer[AEI_COMM_BUFFER_SIZE] = {0}; struct termios ntm; //串口设备选项 std::map m_map_parity; }; #endif //TRAIN_RFID_LINUX_BASECOMPORT_H