public int writeSingleRegister ( int unitId , int ref , Register register ) throws ModbusException { checkTransaction ( ) ; if ( writeSingleRegisterRequest == null ) { writeSingleRegisterRequest = new WriteSingleRegisterRequest ( ) ; } writeSingleRegisterRequest . setUnitID ( unitId ) ; writeSingleRegisterRequest . setReference ( ref ) ; writeSingleRegisterRequest . setRegister ( register ) ; transaction . setRequest ( writeSingleRegisterRequest ) ; transaction . execute ( ) ; return ( ( WriteSingleRegisterResponse ) getAndCheckResponse ( ) ) . getRegisterValue ( ) ; }
Writes a single register to the slave .