Skip to content

Commit

Permalink
Support conditional search
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Dec 6, 2015
1 parent 27a383b commit 6af6338
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions OneWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void OneWire::target_search(uint8_t family_code)
// Return TRUE : device found, ROM number in ROM_NO buffer
// FALSE : device not found, end of search
//
uint8_t OneWire::search(uint8_t *newAddr)
uint8_t OneWire::search(uint8_t *newAddr, bool search_mode /* = true */)
{
uint8_t id_bit_number;
uint8_t last_zero, rom_byte_number, search_result;
Expand Down Expand Up @@ -373,7 +373,11 @@ uint8_t OneWire::search(uint8_t *newAddr)
}

// issue the search command
write(0xF0);
if (search_mode == true) {
write(0xF0); // NORMAL SEARCH
} else {
write(0xEC); // CONDITIONAL SEARCH
}

// loop to do the search
do
Expand Down
2 changes: 1 addition & 1 deletion OneWire.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class OneWire
// might be a good idea to check the CRC to make sure you didn't
// get garbage. The order is deterministic. You will always get
// the same devices in the same order.
uint8_t search(uint8_t *newAddr);
uint8_t search(uint8_t *newAddr, bool search_mode = true);
#endif

#if ONEWIRE_CRC
Expand Down

0 comments on commit 6af6338

Please sign in to comment.