	bool CommonSendRead(int i_iAddr, 
						int i_iFun,
						int i_iStartIndex,
						int i_iTotalPoint);
	bool CommonRecvRead(unsigned char o_szData[], int *o_iTotalByte);


	void HexToRTU(char *i_szHexCmd, unsigned char *o_szRTUCmd);
	void RTUToHex(unsigned char *i_szRTUCmd, int i_RTULen, char *o_szHexCmd);

	// function : 01 (HEX 01)
	// i_iAddr      : Slave address, decimal number
	// i_iStartIndex : start from 1, not 0
	// i_iTotal     : total bytes to read
	bool SendReadCoilStatus(int i_iAddr,
							int i_iStartIndex,
							int i_iTotalPoint);
	bool RecvReadCoilStatus(unsigned char o_szData[], int *o_iTotalByte);

	// function : 02 (HEX 02)
	bool SendReadInputStatus(int i_iAddr, 
							 int i_iStartIndex,
							 int i_iTotalPoint);
	bool RecvReadInputStatus(unsigned char o_szData[], int *o_iTotalByte);

	// function : 03 (HEX 03)
	bool SendReadHoldingRegs(int i_iAddr, 
							 int i_iStartIndex,
							 int i_iTotalPoint);
	bool RecvReadHoldingRegs(unsigned char o_szData[], int *o_iTotalByte);

	// function : 04 (HEX 04)
	bool SendReadInputRegs( int i_iAddr, 
							int i_iStartIndex,
							int i_iTotalPoint);
	bool RecvReadInputRegs(unsigned char o_szData[], int *o_iTotalByte);

	// function : 05 (HEX 05)
	bool SendForceSingleCoil(int i_iAddr,
							 int i_iCoilIndex,
							 int i_iData); // 0: OFF; otherwise: ON
	bool RecvForceSingleCoil();

	// function : 06 (HEX 06)
	bool SendPresetSingleReg(int i_iAddr, 
							 int i_iRegIndex,
							 int i_iData);
	bool RecvPresetSingleReg();

	// function : 15 (HEX 0F)
	bool SendForceMultiCoils(int i_iAddr, 
							 int i_iCoilIndex,
							 int i_iTotalPoint,
							 int i_iTotalByte,
							 unsigned char i_szData[]);
	bool RecvForceMultiCoils();

	// function : 16 (HEX 10)
	// i_iStartReg : start from 1
	bool SendPresetMultiRegs(int i_iAddr, 
							 int i_iStartReg,
							 int i_iTotalReg,
							 int i_iTotalByte,
							 unsigned char i_szData[]);
	bool RecvPresetMultiRegs();

	// extra
	bool ReadTransaction(char *i_szTwoHexAddr,
						 int  i_regLen,
                         char *i_szCmd,
                         char *o_szRecv,
                         char *o_szSendHex, // if NULL, no value assign
                         char *o_szRecvHex); // if NULL, no value assign


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head><title>

</title></head>
<body>
    <form name="form1" method="post" action="DownloadSr.aspx?file_id=1-RAQCU" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZLNNJP85KggLvxsiTV7YApHD8b4/" />
</div>

    <div>
    
    </div>
    </form>
</body>
</html>
