#ifdef __cplusplus
     #define EXPORTS extern "C" __declspec (dllimport)
#else
     #define EXPORTS
#endif


#define  DATEBITS_4       4
#define  DATEBITS_5       5
#define  DATEBITS_6       6
#define  DATEBITS_7       7
#define  DATEBITS_8       8

#define  ADAMRTU_PARITY_NO        0
#define  ADAMRTU_PARITY_ODD       1
#define  ADAMRTU_PARITY_EVEN      2
#define  ADAMRTU_PARITY_MARK      3
#define  ADAMRTU_PARITY_SPACE     4

#define  STOPBIT_1        0
#define  STOPBIT_1POINT5  1
#define  STOPBIT_2        2  

#define  MODBUS_ASCII     0
#define  MODBUS_RTU       1  

//--------------- Error Code --------------------
#define   ADAMRTU_OK                           0 
#define   ADAMRTU_PortNotOpen                (-1)
#define   ADAMRTU_CannotOpen                 (-2)
#define   ADAMRTU_CannotClose                (-3)
#define   ADAMRTU_InvalidModbusProtocol      (-4)
#define   ADAMRTU_InvalidParity              (-5)
#define   ADAMRTU_ComPortReadFailure         (-6)
#define   ADAMRTU_ComPortWriteFailure        (-7)
#define   ADAMRTU_TimeoutOccur               (-8)
#define   ADAMRTU_InvalidPortHandle          (-9)
#define   ADAMRTU_InvalidPortNumber          (-10)
		

EXPORTS  int  CALLBACK  ADAMRTU_GetDLLVersion(void);
EXPORTS  long CALLBACK  ADAMRTU_Open(int PortNumber);
EXPORTS  int  CALLBACK	ADAMRTU_Close(long PortHandle);
EXPORTS  int  CALLBACK  ADAMRTU_SetCommState(long PortHandle, int iBaudRate, int iParity, int iDataBits, int iStopBits);
EXPORTS  int  CALLBACK  ADAMRTU_AdamCommand(long PortHandle, wchar_t* szwSend, wchar_t* szwReceive, int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_ComPortWrite (long PortHandle, BYTE *ucData, int nLength, int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_ComPortRead(long PortHandle, BYTE *ucData, int *nLength, int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_ReadHoldingRegister(long PortHandle, WORD wID, WORD wStartAddress, WORD wCount, WORD wData[], int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_WriteHoldingRegister(long PortHandle, WORD wID, WORD wStartAddress, WORD wCount, WORD wData[], int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_ReadCoil(long PortHandle, WORD wID, WORD wStartAddress, WORD wCount, WORD  wData[], int iTimeout);
EXPORTS  int  CALLBACK  ADAMRTU_WriteCoil(long PortHandle, WORD wID, WORD wStartAddress, WORD wCount, WORD wData[], int iTimeout);
