// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // + // + FileName: CommsDevice.h Author: S.Hammond // + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // + // + Defines and class definition for the CommsDevice class, // + see CommsDevice.cpp for more infomation // + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #ifndef _COMMSDEVICE_H_ #define _COMMSDEVICE_H_ #include "ModBus.h" // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #define _PARITY_NONE 0 #define _PARITY_EVEN 1 #define _PARITY_ODD 2 typedef struct sCommsSetup COMMSSETUP; typedef struct sCommsSetup *PCOMMSSETUP; struct sCommsSetup { char Device[64]; WORD Baud; WORD Parity; }; class CCommsDevice { public: CCommsDevice(); ~CCommsDevice(); void OpenComms(PCOMMSSETUP pSetup); BOOL CheckComms(void); BOOL CheckBaud(BYTE bBaud); BOOL WriteDevice(BYTE *Buffer,DWORD dwLen,DWORD *dwWritten); BOOL ReadDevice(BYTE *Buffer,DWORD *dwRead); void CloseComms(void); protected: // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // + Handle to current communications device // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ HANDLE ComHandle; WORD CurrentBaud; }; #ifdef _COMMSDEVICE_C_ class CCommsDevice CommsDevice; #else extern class CCommsDevice CommsDevice; #endif // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endif /* _COMMSDEVICE_H_ */