Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pymodbus/framer/rtu_framer.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, decoder, client=None):
:param decoder: The decoder factory implementation to use
"""
self._buffer = b''
self._header = {'uid': 0x00, 'len': 0, 'crc': '0000'}
self._header = {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests in test/test_framers.py have to be changed as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like isFrameReady() can still work incorrectly in some conditions.

If framer instance receives incomplete frame with only first byte of some frame,
populateHeader() properly sets self._header['uid'] and then raises IndexError when trying to read second byte from buffer. After that isFrameReady() will not call populateHeader because self._header is not empty, but instead will fail on line return self._header and len(self._buffer) >= self._header['len'], as len key was not added to self._header

self._hsize = 0x01
self._end = b'\x0d\x0a'
self._min_frame_size = 4
Expand Down