File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def getFrame(self):
9696
9797 :returns: The next full frame buffer
9898 """
99- length = self ._hsize + self ._header ["len" ] - 1
99+ length = self ._hsize + self ._header ["len" ]
100100 return self ._buffer [self ._hsize : length ]
101101
102102 # ----------------------------------------------------------------------- #
Original file line number Diff line number Diff line change @@ -341,7 +341,6 @@ def test_recv_packet(rtu_framer):
341341 rtu_framer .client = client
342342 assert rtu_framer .recvPacket (len (message )) == message
343343
344-
345344def test_process (rtu_framer ):
346345 """Test process."""
347346 rtu_framer ._buffer = TEST_MESSAGE # pylint: disable=protected-access
@@ -387,3 +386,19 @@ def _handle_response(_reply):
387386 assert not response_ok , "Response should not be accepted"
388387 framer .processIncomingPacket (part2 , _handle_response , slave = 0 )
389388 assert response_ok , "Response is valid, but not accepted"
389+
390+
391+ def test_recv_socket_exception_packet ():
392+ """Test receive packet."""
393+ response_ok = False
394+
395+ def _handle_response (_reply ):
396+ """Handle response."""
397+ nonlocal response_ok
398+ response_ok = True
399+
400+ message = bytearray (b"\x00 \x02 \x00 \x00 \x00 \x02 \x01 \x84 \x02 " )
401+ response_ok = False
402+ framer = ModbusSocketFramer (ClientDecoder ())
403+ framer .processIncomingPacket (message , _handle_response , slave = 0 )
404+ assert response_ok , "Response is valid, but not accepted"
You can’t perform that action at this time.
0 commit comments