User Tools

Site Tools

한국어

moacon:rtu_readinregs:index

RTU_readInRegs

short RTU_readInRegs(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)

Performs the same operation as RTU_readRegs but uses Modbus function code 4. The MOACON does not distinguish between function codes 3 and 4, but some PLCs do. This function is provided so the MOACON can interface properly with those PLCs that distinguish between function codes 3 and 4.

u8 registerBuffer[100];
res = RTU_readInRegs(0,1,registerBuffer,0,2);

About MODBUS

go MOACON home

moacon/rtu_readinregs/index.txt · Last modified: 2016/04/14 11:07 (external edit)