examples/contrib/explain.py
leveraging Rapid SCADA
#1665
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 alogging.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 apymodbus
log file:explain_with_rapid_scada
: explain one line using Rapid SCADAannotate_pymodbus_logs
: loop over a file, explaining all lines withexplain_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