User Tools

Site Tools

한국어

moacon:rtu_writereg:index

RTU_writeReg

short RTU_writeReg(u8 comCh, u8 slaveAdr, u16 targetAdr, u16 value)

comCh: The RS-232 channel to use
slaveAdr: The Modbus slave address of the device to read from
targetAdr: The address of the data to read
value: Word value to write
returns the status of this function call (-1=Success, 0=Timeout, 1=Data Error)

Writes a word value value to slave device slaveAdr, at address targetAdr, on RS-232 channel comCh. Returns a number indicating whether or not the function call was successful.

res = RTU_writeCoil(0,1,0x0000,0x1234);      //Write word 0x1234 to slave device
                                             //1, address 0x0000

About MODBUS

go MOACON home

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