@@ -387,8 +387,8 @@ impl Request<'_> {
387387 | Self :: WriteSingleRegister ( _, _)
388388 | Self :: WriteSingleCoil ( _, _) => 5 ,
389389 Self :: WriteMultipleCoils ( _, coils) => 6 + coils. packed_len ( ) ,
390- Self :: WriteMultipleRegisters ( _, words ) => 6 + words . data . len ( ) ,
391- Self :: ReadWriteMultipleRegisters ( _, _, _, words ) => 10 + words . data . len ( ) ,
390+ Self :: WriteMultipleRegisters ( _, data ) => 6 + data. len ( ) * 2 ,
391+ Self :: ReadWriteMultipleRegisters ( _, _, _, data ) => 10 + data. len ( ) * 2 ,
392392 Self :: Custom ( _, data) => 1 + data. len ( ) ,
393393 #[ cfg( feature = "rtu" ) ]
394394 _ => todo ! ( ) , // TODO
@@ -406,9 +406,9 @@ impl Response<'_> {
406406 Self :: WriteMultipleCoils ( _, _)
407407 | Self :: WriteMultipleRegisters ( _, _)
408408 | Self :: WriteSingleRegister ( _, _) => 5 ,
409- Self :: ReadInputRegisters ( words )
410- | Self :: ReadHoldingRegisters ( words )
411- | Self :: ReadWriteMultipleRegisters ( words ) => 2 + words . len ( ) * 2 ,
409+ Self :: ReadInputRegisters ( data )
410+ | Self :: ReadHoldingRegisters ( data )
411+ | Self :: ReadWriteMultipleRegisters ( data ) => 2 + data . len ( ) * 2 ,
412412 Self :: Custom ( _, data) => 1 + data. len ( ) ,
413413 #[ cfg( feature = "rtu" ) ]
414414 Self :: ReadExceptionStatus ( _) => 2 ,
@@ -548,6 +548,25 @@ mod tests {
548548 . pdu_len( ) ,
549549 7
550550 ) ;
551+ let mut big_buffer = [ 0 ; 200 ] ;
552+ assert_eq ! (
553+ Request :: WriteMultipleRegisters (
554+ 0 ,
555+ Data :: from_words( & [ 0x23 , 0x24 ] , & mut big_buffer) . unwrap( )
556+ )
557+ . pdu_len( ) ,
558+ 10
559+ ) ;
560+ assert_eq ! (
561+ Request :: ReadWriteMultipleRegisters (
562+ 0 ,
563+ 3 ,
564+ 2 ,
565+ Data :: from_words( & [ 0x23 , 0x24 ] , & mut big_buffer) . unwrap( )
566+ )
567+ . pdu_len( ) ,
568+ 14
569+ ) ;
551570 // TODO: extend test
552571 }
553572
0 commit comments