diff --git a/examples/message_parser.py b/examples/message_parser.py index c822e9206..e95c4a29e 100755 --- a/examples/message_parser.py +++ b/examples/message_parser.py @@ -11,6 +11,7 @@ import logging import textwrap +from pymodbus import pymodbus_apply_logging_config from pymodbus.factory import ClientDecoder, ServerDecoder from pymodbus.transaction import ( ModbusAsciiFramer, @@ -80,15 +81,10 @@ def decode(self, message): print(f"{decoder.decoder.__class__.__name__}") print("-" * 80) try: - decoder.addToFrame(message) - if decoder.checkFrame(): - slave = decoder._header.get( # pylint: disable=protected-access - "uid", 0x00 - ) - decoder.advanceFrame() - decoder.processIncomingPacket(message, self.report, slave) - else: - self.check_errors(decoder, message) + slave = decoder._header.get( # pylint: disable=protected-access + "uid", 0x00 + ) + decoder.processIncomingPacket(message, self.report, slave) except Exception: # pylint: disable=broad-except self.check_errors(decoder, message) @@ -144,6 +140,7 @@ def report(self, message): def parse_messages(cmdline=None): """Do a helper method to generate the messages to parse.""" args = get_commandline(cmdline=cmdline) + pymodbus_apply_logging_config(args.log.upper()) _logger.setLevel(args.log.upper()) if not args.message: _logger.error("Missing --message.")