ljean / modbus-tk

Create Modbus app easily with Python
Other
557 stars 211 forks source link

feat(logging): support logging of telegrams in hex format #182

Open sebastian-bantel opened 1 year ago

sebastian-bantel commented 1 year ago

modbus telegrams are often better readable in hex format.

An application can enable hex logging of telegrams by calling the print_telegrams_in_hex function

modbusClient = OpenClient(config)
modbusClient.print_telegrams_in_hex(True)

example log in hex:

DEBUG:modbus_tk:-> 00-01-00-00-00-06-01-04-fa-01-00-1b
DEBUG:modbus_tk:<- 00-01-00-00-00-39-01-04-36-00-2a-37-4b-4d-33-32-32-30-2d-31-42-41-30-31-2d-31-4a-41-30-20-20-4c-51-4e-2f-32-32-30-35-33-31-38-38-30-30-30-38-00-01-44-03-03-00-00-00-f6-00-00-00-01-01-00-1e