win32 ver

This commit is contained in:
xinyang
2019-05-14 20:03:03 +08:00
parent 601bf2a510
commit 6980145e83
28 changed files with 13037 additions and 395 deletions

View File

@@ -0,0 +1,30 @@
#ifndef _SERIAL_H_
#define _SERIAL_H_
#include <Windows.h>
class Serial
{
public:
Serial(UINT portNo = 1, UINT baud = CBR_9600, char parity = 'N', UINT databits = 8, UINT stopsbits = 1, DWORD dwCommEvents = EV_RXCHAR);
~Serial();
bool InitPort(UINT portNo = 1, UINT baud = CBR_9600, char parity = 'N', UINT databits = 8, UINT stopsbits = 1, DWORD dwCommEvents = EV_RXCHAR);
UINT GetBytesInCOM() const ;
bool WriteData(const unsigned char* pData, unsigned int length);
bool ReadData(unsigned char* buffer, unsigned int length);
private:
bool openPort(UINT portNo);
void ClosePort();
void ErrorHandler();
private:
HANDLE hComm;
UINT portNo;
UINT baud;
char parity;
UINT databits;
UINT stopsbits;
DWORD dwCommEvents;
};
#endif /* _SERIAL_H_ */