3-phase PV router
Loading...
Searching...
No Matches
RomSearch< Bus > Class Template Reference

The successive searches of a 1-Wire bus, one device each. More...

#include <onewire_search.h>

Public Member Functions

 RomSearch (Bus &bus)
 
bool next (uint8_t(&rom)[8])
 Finds the next device on the bus.
 

Private Attributes

Bus & bus
 
bool lastDevice { false }
 
uint8_t lastDiscrepancy { 0 }
 

Static Private Attributes

static constexpr uint8_t SEARCH_ROM { 0xF0 }
 

Detailed Description

template<typename Bus>
class RomSearch< Bus >

The successive searches of a 1-Wire bus, one device each.

Template Parameters
BusHas reset() (true if a device answers), write(uint8_t), read_bit() and write_bit(uint8_t), as OneWire.
RomSearch search{ oneWire };
uint8_t rom[8];
while (search.next(rom)) { ... }
RomSearch(Bus &bus)

Definition at line 45 of file onewire_search.h.

Constructor & Destructor Documentation

◆ RomSearch()

template<typename Bus>
RomSearch< Bus >::RomSearch ( Bus & bus)
inlineexplicit

Definition at line 48 of file onewire_search.h.

Member Function Documentation

◆ next()

template<typename Bus>
bool RomSearch< Bus >::next ( uint8_t(&) rom[8])
inline

Finds the next device on the bus.

Parameters
romIts ROM code: family code first, CRC last (to check by the caller). The same array at each call: a search follows the previous code up to its last conflict.
Returns
false when every device has been found, if no device answers, or if the bus does not answer as expected (the search then starts over at the next call).

Definition at line 61 of file onewire_search.h.

Member Data Documentation

◆ bus

template<typename Bus>
Bus& RomSearch< Bus >::bus
private

Definition at line 112 of file onewire_search.h.

◆ lastDevice

template<typename Bus>
bool RomSearch< Bus >::lastDevice { false }
private

the last device has been found

Definition at line 114 of file onewire_search.h.

◆ lastDiscrepancy

template<typename Bus>
uint8_t RomSearch< Bus >::lastDiscrepancy { 0 }
private

the conflict to take as 1 at the next search

Definition at line 113 of file onewire_search.h.

◆ SEARCH_ROM

template<typename Bus>
uint8_t RomSearch< Bus >::SEARCH_ROM { 0xF0 }
staticconstexprprivate

1-Wire command: search the ROM codes

Definition at line 110 of file onewire_search.h.


The documentation for this class was generated from the following file: