📄 serialportbase.h
字号:
class CSerialPortBase
{
public:
int m_nWriteSize;
void ClosePort();
// contruction and destruction
CSerialPortBase();
virtual ~CSerialPortBase();
// port initialisation
BOOL InitPort(CWnd* pPortOwner,
UINT portnr = 1,
UINT baud = 9600,
char parity = 'N',
UINT databits = 8,
UINT stopbits = 1,
DWORD dwCommEvents = EV_RXCHAR,
UINT writebuffersize = 1024);
HANDLE m_hComm; // 串口指针
// start/stop comm watching
BOOL StartMonitoring();
BOOL RestartMonitoring();
BOOL StopMonitoring();
DWORD GetWriteBufferSize();
DWORD GetCommEvents();
DCB GetDCB();
void WriteToPort(char* string);
void WriteToPort(char* string,int n);
void WriteToPort(LPCTSTR string);
void WriteToPort(LPCTSTR string,int n);
protected:
// protected memberfunctions
void ProcessErrorMessage(char* ErrorText);
static UINT CommThread(LPVOID pParam);
static void ReceiveChar(CSerialPort* port, COMSTAT comstat);
static void WriteChar(CSerialPort* port);
// thread
CWinThread* m_Thread;
// synchronisation objects
CRITICAL_SECTION m_csCommunicationSync;
BOOL m_bThreadAlive;
// handles
HANDLE m_hWriteEvent;
HANDLE m_hShutdownEvent;
// Event array.
// One element is used for event. There are two event handles for each port.
// A Write event and a receiveeach character event which is located in the overlapped structure (m_ov.hEvent).
// There is a general shutdown when the port is closed.
HANDLE m_hEventArray[3];
// structures
OVERLAPPED m_ov;
COMMTIMEOUTS m_CommTimeouts;
DCB m_dcb;
// owner window
CWnd* m_pOwner;
// misc
UINT m_nPortNr;
char* m_szWriteBuffer;
DWORD m_dwCommEvents;
DWORD m_nWriteBufferSize;
private:
BOOL SerialPortConfig();
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -