pub struct OneWireSearch<'a, T> { /* private fields */ }Expand description
A structure for searching devices on a 1-Wire bus. This structure implements the search algorithm for discovering devices on the 1-Wire bus. It maintains the state of the search.
Implementations§
Source§impl<'a, T> OneWireSearch<'a, T>
impl<'a, T> OneWireSearch<'a, T>
Sourcepub fn new(onewire: &'a mut T, cmd: OneWireSearchKind) -> Self
pub fn new(onewire: &'a mut T, cmd: OneWireSearchKind) -> Self
Creates a new OneWireSearch instance.
§Arguments
onewire- A mutable reference to a type that implements theOneWiretrait.cmd- The command to use for the search operation (e.g.,0xf0for normal search,0xecfor search in alarm state).
Sourcepub fn with_family(
onewire: &'a mut T,
cmd: OneWireSearchKind,
family: u8,
) -> Self
pub fn with_family( onewire: &'a mut T, cmd: OneWireSearchKind, family: u8, ) -> Self
Creates a new OneWireSearch instance with a specific family code.
§Arguments
onewire- A mutable reference to a type that implements theOneWiretrait.cmd- The command to use for the search operation (e.g.,0xf0for normal search,0xecfor search in alarm state).family- The family code of the devices to search for.
Source§impl<T: OneWire> OneWireSearch<'_, T>
impl<T: OneWire> OneWireSearch<'_, T>
Sourcepub fn next(&mut self) -> Result<Option<u64>, OneWireError<T::BusError>>
pub fn next(&mut self) -> Result<Option<u64>, OneWireError<T::BusError>>
Searches for devices on the 1-Wire bus.
This method implements the 1-Wire search algorithm to discover devices connected to the bus.
The next method can be called repeatedly to find all devices on the bus.
At the end of the search, calling this method will return None to indicate that no more devices are present.
At that point, the search state becomes unusable and should be dropped.
The search state is reset if the verify method is called.
§Returns
A result containing the ROM code of the found device as a u64 value.
| Bit | Description |
|---|---|
| 0-7 | Family code (e.g., 0x28 for DS18B20) |
| 8-15 | Serial number (first byte) |
| 16-23 | Serial number (second byte) |
| 24-31 | Serial number (third byte) |
| 32-39 | Serial number (fourth byte) |
| 40-47 | Serial number (fifth byte) |
| 48-55 | Serial number (sixth byte) |
| 56-63 | CRC-8 (0b1_0001_1001 poly) |