первый
This commit is contained in:
56
devices/ComPort.h
Normal file
56
devices/ComPort.h
Normal file
@ -0,0 +1,56 @@
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef ComPortH
|
||||
#define ComPortH
|
||||
//---------------------------------------------------------------------------
|
||||
#if defined( _BORLAND )
|
||||
#include <vcl.h>
|
||||
#endif
|
||||
|
||||
//#include <WinNt.h>
|
||||
#include <string>
|
||||
|
||||
#include "Port.h"
|
||||
//---------------------------------------------------------------------------
|
||||
//typedef void *HANDLE;
|
||||
//---------------------------------------------------------------------------
|
||||
std::string getComName(int num);
|
||||
//---------------------------------------------------------------------------
|
||||
class ComPort: public Port
|
||||
{ private:
|
||||
void CheckBaudRate();
|
||||
protected:
|
||||
bool bOpen; //Состояние порта
|
||||
public:
|
||||
#if defined(_WIN32) || defined(_WINDOWS) || defined(_BORLAND) || defined(__BORLANDC__)
|
||||
void * hCom;
|
||||
#else
|
||||
int hCom;
|
||||
#endif
|
||||
std::string ComNumber; //Номер ком порта
|
||||
int BaudRate; //Скорость ком порта DWORD
|
||||
|
||||
ComPort();
|
||||
virtual ~ComPort();
|
||||
bool Open(std::string ComNumber);
|
||||
bool Open(std::wstring ComNumber);
|
||||
//bool setBaudRate();
|
||||
bool SetTimeout(unsigned long time); //Сколько ждать данных (Для чтения и запииси)
|
||||
bool isOpen(){ return bOpen; };
|
||||
|
||||
bool Close(); //Разорвать связь
|
||||
bool Setup(int num = -1); //Настройка параметров ком порта
|
||||
bool SetupDCB(int BaudRate,int ByteSize);
|
||||
unsigned long Write(const void* lpBuffer,unsigned long nNumberOfBytesToWrite);
|
||||
unsigned long WriteString(std::string str);
|
||||
unsigned char WriteChar(signed char ch);
|
||||
unsigned char WriteUChar(unsigned char ch);
|
||||
unsigned char WriteUInt(unsigned int val);
|
||||
int Read(void* lpBuffer,unsigned long nNumberOfBytesToRead);
|
||||
int ReadAll(void* lpBuffer, unsigned long nNumberOfBytesToRead); //Так как может выдавать инфу порциями
|
||||
int ReadUntilChar(void* lpBuffer, unsigned long maxLen, char suffix,bool* error); //Читать до символа
|
||||
|
||||
unsigned char ReadUInt1(bool* b);
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
#endif
|
||||
Reference in New Issue
Block a user