File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ def check_frame(self):
8686 self ._header ["len" ],
8787 self ._header ["uid" ],
8888 ) = struct .unpack (">HHHB" , self ._buffer [0 : self ._hsize ])
89+ if self ._header ["len" ] == 2 and len (self ._buffer ) >= self ._hsize + 2 :
90+ self ._header ["len" ] = 3
8991 if self ._header ["len" ] < 2 :
9092 length = self ._hsize + self ._header ["len" ] - 1
9193 self ._buffer = self ._buffer [length :]
Original file line number Diff line number Diff line change @@ -448,6 +448,21 @@ def _handle_response(_reply):
448448 framer .processIncomingPacket (message , _handle_response , slave = 0 )
449449 assert response_ok , "Response is valid, but not accepted"
450450
451+ def test_recv_socket_exception_faulty (self ):
452+ """Test receive packet."""
453+ response_ok = False
454+
455+ def _handle_response (_reply ):
456+ """Handle response."""
457+ nonlocal response_ok
458+ response_ok = True
459+
460+ message = bytearray (b"\x00 \x02 \x00 \x00 \x00 \x02 \x01 \x84 \x02 " )
461+ response_ok = False
462+ framer = ModbusSocketFramer (ClientDecoder ())
463+ framer .processIncomingPacket (message , _handle_response , slave = 0 )
464+ assert response_ok , "Response is valid, but not accepted"
465+
451466 # ---- 100% coverage
452467 @pytest .mark .parametrize (
453468 ("framer" , "message" ),
You can’t perform that action at this time.
0 commit comments