short RTU_readRegs(u8 comCh, u8 slaveAdr, u8* result, u16 targetAdr, u8 numOfRegs)
comCh: The RS-232 channel to use |
slaveAdr: The Modbus slave address of the device to read from |
result: Buffer to store coil (bit) data to |
targetAdr: The address of the data to read |
numOfRegss: Number of registers (words) to read |
returns the status of this function call (-1=Success, 0=Timeout, 1=Data Error) |
Reads numOfRegs words from slave device slaveAdr, at address targetAdr, on RS-232 channel comCh and stores the data in result. Returns a number indicating whether or not the function call was successful. This function used Modbus function code 3.
u8 registerBuffer[100]; res = RTU_readRegs(0,1,registerBuffer,0,2);