Skip to content

Conversation

Kainarx
Copy link
Collaborator

@Kainarx Kainarx commented Apr 15, 2025

@suda-morris suda-morris requested a review from Copilot May 13, 2025 15:05
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

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

ONEWIRE_CMD_SEARCH_NORMAL
}, 1), TAG, "send ONEWIRE_CMD_SEARCH_NORMAL failed");

uint8_t last_zero = 0;
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

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

[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.

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant