unsigned short RegQuantities = 5;
bool DiData;
// Read register data from remote device
ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);
// Step 1: Parsing data for DI1
DiData = (bool)MAKEWORD(MsgBuf[4], MsgBuf[3]);
// Step 2: Repeat Step 1 for getting another DI data
}
8.3.7 Read AO Function
bool ReadAOData(void)
{
unsigned char MsgBuf[48];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 601;
unsigned short RegQuantities = 5;
unsigned short RegData;
float AoData;
// Read register data from remote device
ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);
// Because the AO expression is specific, so we need using specific // expression to convert the value
//as following:
// Step 1: Parsing data for AO1
RegData = MAKEWORD(MsgBuf[4], MsgBuf[3]);
// Step2: To do converted expression for AO1
AoData = ((RegData * 65.535)/65535)-32.768;
// Step 3: Repeat Step 1 to Step 2 for getting another AO data
}
8.3.8 Read DO Function
bool ReadDOData(void)
{
unsigned char MsgBuf[48];
unsigned char Addr = 1; /* Slave Id */
unsigned short StartRegAdd = 74;
unsigned short RegQuantities = 5;
bool DoData;
// Read register data from remote device
ReadData(Addr, StartRegAdd, RegQuantities, MsgBuf);
// Step 1: Parsing data for DO1
Page 472 of 479