📄 dsa_tsjl06tasync.h
字号:
//---------------------------------------------------------------------------
#ifndef dsa_TSJL06TAsyncH
#define dsa_TSJL06TAsyncH
//---------------------------------------------------------------------------
#include <string>
using std::string;
class TRs232Async
{
public:
TRs232Async(bool Debug);
~TRs232Async();
// Open RS232 port, parameters like string("COM15"), string("9600 n 8 1");
bool Open(string &PortName, string &PortProperties, char RxEventChar=0);
// Close Port.
void Close();
bool PortIsOpened(){return PortOpened;};
// Read data from RX, return actual read bytes.
int Read(char *Buffer, int MaxBufferSize);
// Write data to TX.
int Write(char *Buffer, int BytesToWrite);
// Set message receiver.
void SetNotifyWindow(HWND WindowHandle, int ReceiverId=741, int SenderId=0);
private:
// Setting flag with true will show error messages while exceptions thrown.
bool PrintDebugInfo;
// For RS232 port.
bool PortOpened;
HANDLE PortHandle;
OVERLAPPED overlapRX, overlapTX;
// For threads.
bool ThreadRun;
HANDLE ThreadHandle;
DWORD ThreadId;
OVERLAPPED overlapWait;
// For message queue.
UINT ReceiverMessageId;
UINT SenderMessageId;
HWND NotifyWindow;
string EnumerateProvider(int ProvSubType);
void PrintException(string Caller, string &Message);
void OnReceived(int BytesToRead);
void OnSent();
static DWORD WINAPI DummyThread(LPVOID Parameters);
static DWORD WINAPI EventThread(LPVOID Parameters);
};
//---------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -