-
Notifications
You must be signed in to change notification settings - Fork 104
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
Bugfix/values spikes #408
Merged
Merged
Bugfix/values spikes #408
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Introduced `current_sequence_number` attribute to track the sequence number. - Added `advance_sequence_number` method to generate and increment the sequence number. - Updated `write_register` and `read_holding_registers` methods to utilize the new sequence number for packet validation.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #408 +/- ##
==========================================
+ Coverage 71.00% 72.73% +1.72%
==========================================
Files 26 26
Lines 1914 1962 +48
==========================================
+ Hits 1359 1427 +68
+ Misses 555 535 -20 ☔ View full report in Codecov by Sentry. |
- Introduced `validate_modbus_crc` method to check the integrity of Modbus frames. - Added `validate_packet` method to ensure received packets conform to expected structure and CRC. - Updated `read_holding_registers` to validate response packets before returning registers. - Defined a constant `POLY` for Modbus CRC polynomial. These enhancements improve the reliability of communication with Modbus devices.
- Updated the extraction of the Modbus frame to include the CRC byte for improved validation. - Added detailed logging for extracted Modbus frames and calculated CRC values to aid in debugging. - Introduced a new `calculate_modbus_crc` function in tests to ensure accurate CRC calculations for Modbus frames. - Enhanced unit tests to validate the reading and writing of registers, ensuring proper interaction with the Modbus client. These changes improve the reliability and traceability of Modbus communication in the SolarmanSunsynk implementation.
- Introduced multiple test cases for validating Modbus packets, including checks for invalid start/stop bytes, sequence numbers, CRC, and length. - Enhanced error handling in connection and disconnection scenarios. - Improved write_register method to handle timeout and general exceptions effectively. These additions strengthen the reliability and robustness of the SolarmanSunsynk's Modbus communication and error management.
Thanks! (You should install pre-commit - helps with formatting) |
This was referenced Jan 23, 2025
kellerza
added a commit
that referenced
this pull request
Jan 23, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add sequence number management for packet validation in SolarmanSunsynk
Add Modbus packet validation methods in SolarmanSunsynk
Enhance Modbus frame handling in SolarmanSunsynk
current_sequence_number
attribute to track the sequence number.advance_sequence_number
method to generate and increment the sequence number.write_register
andread_holding_registers
methods to utilize the new sequence number for packet validation.validate_modbus_crc
method to check the integrity of Modbus frames.validate_packet
method to ensure received packets conform to expected structure and CRC.read_holding_registers
to validate response packets before returning registers.POLY
for Modbus CRC polynomial.calculate_modbus_crc
function in tests to ensure accurate CRC calculations for Modbus frames.Related PR & issues: