📄 emscom.h
字号:
#ifndef __EMSCOM_H__
#define __EMSCOM_H__
#include <stdio.h> /*标准输入输出定义*/
#include <stdlib.h> /*标准函数库定义*/
#include <unistd.h> /*Unix 标准函数定义*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> /*文件控制定义*/
#include <termios.h> /*PPSIX 终端控制定义*/
#include <errno.h> /*错误号定义*/
#include <string>
#define INVALID_HANDLE_VALUE 0
class EmsCom
{
private:
int m_PortHandle; //串口文件句柄
string m_ComName;
int m_BaudRate; //Current baud rate
short int m_DataBits; //Current Data bits per byts
short int m_StopBits ; //Current Stop bits per byte
short int m_Parity;//Current Parity (No/Odd/Even/Mark/Space = 0-4)
bool m_Inuse:Boolean;
string m_EndChar; //Response terminator string
unsigned int m_IntervalOut;
public:
EmsCom();
~EmsCom();
bool ToOpenCom(void);
int ToCloseCom(void);
bool ToWriteCom(char *_pByteData,int _wLen);
int ToSetBaud(int _BaudRate);// Procedure to set the baud rate
int ToSetData(short int _DataBits); // Procedure to set the Data bits
int ToSetStop(short int _StopBits);// Procedure to set the stop bits
int ToSetParity(short int _Parity);//Procedure to set the Parity
bool IsOpened(void)
{
if(m_PortHandle==INVALID_HANDLE_VALUE)
return false;
return true;
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -