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 ( ) ; }
Writes a number of registers to the slave .