Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/contrib/explain.py leveraging Rapid SCADA #1665

Merged
merged 6 commits into from
Jul 19, 2023
Merged

examples/contrib/explain.py leveraging Rapid SCADA #1665

merged 6 commits into from
Jul 19, 2023

Conversation

jamesbraza
Copy link
Contributor

Motivation

I have a third party Modbus RTU motor that I talk with at ≥10 transactions/sec. It seems I continually discover more motor firmware bugs as time goes on. To enable posthumous root causing, I save all pymodbus transactions in a log file (via a logging.FileHandler).

During root causing, I have to decode 10's of Modbus RTU packets by hand, which can be quite tedious. I discovered https://rapidscada.net/modbus/ that decodes the packets, so I decided to create a function annotate_pymodbus_logs that automates the decoding process for me.

Implementation

Creates examples/contrib/explain.py that uses https://rapidscada.net/modbus/ to explain a pymodbus log file:

  • explain_with_rapid_scada: explain one line using Rapid SCADA
  • annotate_pymodbus_logs: loop over a file, explaining all lines with explain_with_rapid_scada

NOTE: this could probably be entirely done without Rapid SCADA, but as I am not intimately familiar with pymodbus nor Modbus itself, so this was actually easier for me to comprehend/implement

Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

A nice one for examples/contrib, but needs some small adjustments

Could also be moved to examples, with additional review comments.

requirements.txt Outdated Show resolved Hide resolved
test/sub_examples/fixtures/rapid_scada_post_recv.html Outdated Show resolved Hide resolved
test/sub_examples/fixtures/rapid_scada_post_send.html Outdated Show resolved Hide resolved
test/sub_examples/fixtures/raw_pymodbus.log Outdated Show resolved Hide resolved
test/sub_examples/test_examples.py Outdated Show resolved Hide resolved
…om requirements.txt), and updated docstring to detail versions tested against
@jamesbraza jamesbraza requested a review from janiversen July 19, 2023 07:12
Copy link
Collaborator

@janiversen janiversen left a comment

Choose a reason for hiding this comment

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

Thanks.

@janiversen janiversen merged commit 4d9075f into pymodbus-dev:dev Jul 19, 2023
@jamesbraza jamesbraza deleted the rapid-scada-explain branch July 19, 2023 17:11
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants