//---------------------------------------------------------------------------
#include <Classes.hpp>

#ifndef SerialCommH
#define SerialCommH
//---------------------------------------------------------------------------

enum {NONE=0x00, ODD=0x08, EVEN=0x18} ;
enum {_B2400=0x09, _B4800=0x0a, _B9600=0x0c, _B19200=0x0d, _B38400=0x0e} ;
enum {_DATA5=0x00, _DATA6=0x01, _DATA7=0x02, _DATA8=0x03} ;
enum {_STOP1=0x00, _STOP2=0x04} ;

class SerialComm
{
private :
    USHORT m_usPortNum ;
    int m_iCommMode ;

public :
    SerialComm(USHORT PortNum) ;
    ~SerialComm() ;

    BOOL __fastcall PortIOCtrl(int nBaud, int nData, int nStop, int nParity) ;
    BOOL __fastcall Write(AnsiString Data) ;
    BOOL __fastcall Write(char* Data, int Length) ;
    BOOL __fastcall Read(char* pData, int& Length) ;
    BOOL __fastcall Read(AnsiString& Data) ;

    USHORT __fastcall CRC16(USHORT *pData, short Length) ;
} ;
#endif
