fix(onewire): fix search fails for devices with different bit 0#494
Open
Kainarx wants to merge 1 commit intoespressif:masterfrom
Open
fix(onewire): fix search fails for devices with different bit 0#494Kainarx wants to merge 1 commit intoespressif:masterfrom
Kainarx wants to merge 1 commit intoespressif:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the device search issue on the onewire bus by adjusting the bit iteration logic.
- Adjusts the loop start and end conditions to correctly handle bit indexing for device addresses
- Updates bit mask and byte index calculations to account for the modified iteration indexing
| @@ -66,9 +66,9 @@ esp_err_t onewire_device_iter_get_next(onewire_device_iter_handle_t iter, onewir | |||
| }, 1), TAG, "send ONEWIRE_CMD_SEARCH_NORMAL failed"); | |||
|
|
|||
| uint8_t last_zero = 0; | |||
There was a problem hiding this comment.
[nitpick] Consider adding a comment to explain why the loop index now starts at 1 and goes through (sizeof(onewire_device_address_t) * 8) + 1. This will improve code clarity for future maintainers regarding the off-by-one adjustment in bit indexing.
Suggested change
| uint8_t last_zero = 0; | |
| uint8_t last_zero = 0; | |
| // The loop index starts at 1 and goes through (sizeof(onewire_device_address_t) * 8) + 1 | |
| // because bit indexing in the 1-Wire protocol starts from 1. The logic inside the loop | |
| // adjusts for this by subtracting 1 when calculating rom_byte_index and rom_bit_mask. |
This file contains hidden or 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
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.
#298