code: public int writeMultipleRegisters(int unitId, int ref, Register[] registers) throws ModbusException {
          checkTransaction();
          if (writeMultipleRegistersRequest == null) {
              writeMultipleRegistersRequest = new WriteMultipleRegistersRequest();
          }
          writeMultipleRegistersRequest.setUnitID(unitId);
          writeMultipleRegistersRequest.setReference(ref);
          writeMultipleRegistersRequest.setRegisters(registers);
          transaction.setRequest(writeMultipleRegistersRequest);
          transaction.execute();
          return ((WriteMultipleRegistersResponse) transaction.getResponse()).getWordCount();
      }
docs: Writes a number of registers to the slave.
  
  @param unitId    the slave unit id.
  @param ref       the offset of the register to start writing to.
  @param registers a <tt>Register[]</tt> holding the values of
  the registers to be written.
  
  @return the number of registers that have been written.
  
  @throws ModbusException if an I/O error, a slave exception or
  a transaction error occurs.