code: 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();
      }
docs: Writes a single register to the slave.
  
  @param unitId   the slave unit id.
  @param ref      the offset of the register to be written.
  @param register a <tt>Register</tt> holding the value of the register
  to be written.
  
  @return the value of the register as returned from the slave.
  
  @throws ModbusException if an I/O error, a slave exception or
  a transaction error occurs.