_1wire.h
Go to the documentation of this file.
#ifndef __utl_com_1wire_h__
#define __utl_com_1wire_h__
#include <utl/core/impl.h>
#include <utl/core/crtp.h>
#include <utl/com/_1wire_id.h>
#include <utl/meta/meta.h>
namespace utl {
namespace _1wire_i_det {
template <typename _T> byte_t _touch (_T& obj, byte_t out, typename _T::Speed s);
template <typename _T> void _match (_T& obj, _1wire_id_t& id, typename _T::Speed s);
template <typename _T> void _match_n_ovdr (_T& obj, _1wire_id_t& id);
template <typename _T> void _skip (_T& obj, typename _T::Speed s);
template <typename _T> void _skip_n_ovdr (_T& obj);
template <typename _T> _1wire_id_t _first (_T& obj, typename _T::Speed s, bool alarm);
template <typename _T> _1wire_id_t _next (_T& obj, typename _T::Speed s, bool alarm);
}
template <typename impl_t>
class _1wire_i {
_CRTP_IMPL(impl_t);
public:
using type = _1wire_i;
enum class Speed { STD =0, OVDR };
protected:
_1wire_i () = default;
~_1wire_i () = default;
_1wire_i (const _1wire_i&) = delete;
_1wire_i& operator= (const _1wire_i&) = delete;
private:
Speed speed () const { return impl().speed(); }
void speed (Speed s) { return impl().speed(s); }
bool bit (bool b) { return impl().bit(b); }
bool _reset (Speed s){ return impl()._reset(s); }
private:
enum Command {
CMD_READ_ROM = 0x33,
CMD_OVDR_SKIP = 0x3C,
CMD_MATCH = 0x55,
CMD_OVDR_MATCH = 0x69,
CMD_SKIP = 0xCC,
CMD_ALARM_SEARCH = 0xEC,
CMD_SEARCH_ROM = 0xF0
};
template <typename _T> friend byte_t _1wire_i_det::_touch (_T&, byte_t, typename _T::Speed);
template <typename _T> friend void _1wire_i_det::_match (_T& obj, _1wire_id_t& id, typename _T::Speed s);
template <typename _T> friend void _1wire_i_det::_match_n_ovdr (_T& obj, _1wire_id_t& id);
template <typename _T> friend void _1wire_i_det::_skip (_T& obj, typename _T::Speed s);
template <typename _T> friend void _1wire_i_det::_skip_n_ovdr (_T& obj);
template <typename _T> friend _1wire_id_t _1wire_i_det::_first (_T&, typename _T::Speed, bool);
template <typename _T> friend _1wire_id_t _1wire_i_det::_next (_T&, typename _T::Speed, bool);
public:
bool reset (Speed s = Speed::STD) {
return _reset (s);
}
byte_t tx_data (byte_t out, Speed s = Speed::STD) {
return _1wire_i_det::_touch (*this, out, s);
}
size_t tx_data (const byte_t *out, byte_t *in, size_t n, Speed s = Speed::STD);
byte_t rx_data (Speed s = Speed::STD) {
return _1wire_i_det::_touch (*this, 0xFF, s);
}
size_t rx_data (byte_t *in, size_t n, Speed s = Speed::STD);
void match (_1wire_id_t& id, Speed s = Speed::STD) {
_1wire_i_det::_match (*this, id, s);
}
void match_n_ovdr (_1wire_id_t& id) {
_1wire_i_det::_match_n_ovdr (*this, id);
}
void skip (Speed s = Speed::STD) {
_1wire_i_det::_skip (*this, s);
}
void skip_n_ovdr () {
_1wire_i_det::_skip_n_ovdr (*this);
}
_1wire_id_t first (Speed s = Speed::STD, bool alarm =false) {
return _1wire_i_det::_first (*this, s, alarm);
}
_1wire_id_t next (Speed s = Speed::STD, bool alarm =false) {
return _1wire_i_det::_next (*this, s, alarm);
}
private:
_1wire_id_t dec_ {_1wire_id_t::nullDev()};
_1wire_id_t pos_ {_1wire_id_t::nullDev()};
_1wire_id_t cur_ {_1wire_id_t::nullDev()};
};
template <typename _I>
size_t _1wire_i<_I>::tx_data (const byte_t *out, byte_t *in, size_t n, Speed s){
for (size_t nn {n} ; nn ; --nn)
*in++ = tx_data (*out++, s);
return n;
}
template <typename _I>
size_t _1wire_i<_I>::rx_data(byte_t *in, size_t n, Speed s) {
for (size_t nn {n} ; nn ; --nn)
*in++ = tx_data (0xFF, s);
return n;
}
template <>
class _1wire_i <virtual_tag> {
public:
using type = _1wire_i<virtual_tag>;
enum class Speed { STD =0, OVDR };
protected:
_1wire_i () = default;
_1wire_i (const type&) = delete;
type& operator= (const type&) = delete;
public:
virtual ~_1wire_i () = default;
private:
virtual Speed speed () const =0;
virtual void speed (Speed) =0;
virtual bool bit () =0;
virtual bool bit (bool) =0;
virtual bool _reset (Speed) =0;
private:
enum Command {
CMD_READ_ROM = 0x33,
CMD_OVDR_SKIP = 0x3C,
CMD_MATCH = 0x55,
CMD_OVDR_MATCH = 0x69,
CMD_SKIP = 0xCC,
CMD_ALARM_SEARCH = 0xEC,
CMD_SEARCH_ROM = 0xF0
};
template <typename _T> friend byte_t _1wire_i_det::_touch (_T&, byte_t, typename _T::Speed);
template <typename _T> friend void _1wire_i_det::_match (_T& obj, _1wire_id_t& id, typename _T::Speed s);
template <typename _T> friend void _1wire_i_det::_match_n_ovdr (_T& obj, _1wire_id_t& id);
template <typename _T> friend void _1wire_i_det::_skip (_T& obj, typename _T::Speed s);
template <typename _T> friend void _1wire_i_det::_skip_n_ovdr (_T& obj);
template <typename _T> friend _1wire_id_t _1wire_i_det::_first (_T&, typename _T::Speed, bool);
template <typename _T> friend _1wire_id_t _1wire_i_det::_next (_T&, typename _T::Speed, bool);
public:
bool reset (Speed s = Speed::STD) {
return _reset (s);
}
byte_t tx_data (byte_t out, Speed s = Speed::STD) {
return _1wire_i_det::_touch (*this, out, s);
}
size_t tx_data (const byte_t *out, byte_t *in, size_t n, Speed s = Speed::STD);
byte_t rx_data (Speed s = Speed::STD) {
return _1wire_i_det::_touch (*this, 0xFF, s);
}
size_t rx_data (byte_t *in, size_t n, Speed s = Speed::STD);
void match (_1wire_id_t& id, Speed s = Speed::STD) {
_1wire_i_det::_match (*this, id, s);
}
void match_n_ovdr (_1wire_id_t& id) {
_1wire_i_det::_match_n_ovdr (*this, id);
}
void skip (Speed s = Speed::STD) {
_1wire_i_det::_skip (*this, s);
}
void skip_n_ovdr () {
_1wire_i_det::_skip_n_ovdr (*this);
}
_1wire_id_t first (Speed s = Speed::STD, bool alarm =false) {
return _1wire_i_det::_first (*this, s, alarm);
}
_1wire_id_t next (Speed s = Speed::STD, bool alarm =false) {
return _1wire_i_det::_next (*this, s, alarm);
}
private:
_1wire_id_t dec_ {_1wire_id_t::nullDev()};
_1wire_id_t pos_ {_1wire_id_t::nullDev()};
_1wire_id_t cur_ {_1wire_id_t::nullDev()};
};
size_t _1wire_i<virtual_tag>::tx_data (const byte_t *out, byte_t *in, size_t n, Speed s){
for (size_t nn {n} ; nn ; --nn)
*in++ = tx_data (*out++, s);
return n;
}
size_t _1wire_i<virtual_tag>::rx_data(byte_t *in, size_t n, Speed s) {
for (size_t nn {n} ; nn ; --nn)
*in++ = tx_data (0xFF, s);
return n;
}
namespace _1wire_i_det {
template <typename _T>
byte_t _touch (_T& obj, byte_t out, typename _T::Speed s) {
byte_t ret {0};
// Select speed once
if (obj.speed () != s)
obj.speed (s);
for (uint8_t i =8; i>0 ; --i) {
ret >>= 1;
ret |= (obj.bit (out & 0x01)) ? 0x80 : 0x00;
out >>= 1;
/*^
* We shift bits to right as LSB comes first and mask it to MSB
* If we need to read we have to write 1
*/
}
return ret;
}
template <typename _T>
void _match (_T& obj, _1wire_id_t& id, typename _T::Speed s) {
_touch (obj, (s == _T::Speed::STD) ? _T::CMD_MATCH : _T::CMD_OVDR_MATCH, s);
for (uint8_t& b : id)
_touch (obj, b, s);
}
template <typename _T>
void _match_n_ovdr (_T& obj, _1wire_id_t& id) {
_touch (obj, _T::CMD_MATCH, _T::Speed::STD);
for (uint8_t& b : id)
_touch (obj, b, _T::Speed::OVDR);
}
template <typename _T>
void _skip (_T& obj, typename _T::Speed s) {
_touch (obj, (s == _T::Speed::STD) ? _T::CMD_SKIP : _T::CMD_SKIP, s);
}
template <typename _T>
void _skip_n_ovdr (_T& obj) {
_touch (obj, _T::CMD_OVDR_SKIP, _T::Speed::STD);
}
template <typename _T>
_1wire_id_t _first (_T& obj, typename _T::Speed s, bool alarm) {
obj.dec_ = obj.pos_ = obj.cur_ = _1wire_id_t::nullDev();
return _next (obj, s, alarm);
}
template <typename _T>
_1wire_id_t _next (_T& obj, typename _T::Speed s, bool alarm) {
uint8_t b, bxx; // bit helper vars
uint8_t i;
_1wire_id_t ID;
do {
if ((obj.pos_ != _1wire_id_t::nullDev()) && (obj.dec_ >= obj.pos_)) {
// dec_ == pos_: We have found all the leafs, already
// dec_ > pos_ : Error
ID = _1wire_id_t::nullDev();
break;
}
if (!obj.reset (s)) {
ID = _1wire_id_t::nullDev();
break;
}
// Issue search command
if (alarm) obj.tx_data (_T::CMD_ALARM_SEARCH, s);
else obj.tx_data (_T::CMD_SEARCH_ROM, s);
// Select speed once
if (obj.speed () != s)
obj.speed (s);
// traverse entire RomID from LSB to MSB
for (i =0 ; i<64 ; ++i) {
// Get response pair bits
bxx = obj.bit (1); // bit
bxx <<= 1;
bxx |= obj.bit (1); // complementary bit
if (bxx == 0x00) {
// 00 - We have discrepancy
obj.cur_.bit (i, 1);
switch (_1wire_id_t::compare (obj.pos_, obj.cur_)) {
default:
case -1:
// pos_ < cur_: This discrepancy is the most far for now. Mark position and select 0.
b = 0;
//dec_.bit (i, (b = 0)); //<-- Its already 0
obj.pos_.bit (i, 1);
break;
case 0:
// pos_ == cur_: This was the last discrepancy in the last pass.
// Select the other branch this time (1)
obj.dec_.bit (i, (b = 1));
break;
case 1:
// pos_ > cur_: We had a discrepancy in a MSB than that, in a previous pass.
// Continue with the last pass decision.
b = obj.dec_.bit (i);
break;
}
// Send selection and update romid
obj.bit (b);
ID.bit (i, b);
}
else if (bxx == 0x01) {
// 01 - All bits of all ROMs are 0s
obj.bit (0);
ID.bit (i, 0);
}
else if (bxx == 0x02) {
// 10 - All bits of all ROMs are 1s
obj.bit (1);
ID.bit (i, 1);
}
else {
// 11 - No device on the bus
ID = _1wire_id_t::nullDev();
break;
}
} // for
if (i == 64 && obj.pos_ == _1wire_id_t::nullDev()) {
// Mark done with only one device
obj.pos_.bit (0, 1);
obj.dec_.bit (0, 1);
}
} while (0);
return ID;
}
} // namespace _1wire_i_det
#if defined _utl_have_concepts
template <typename T>
concept bool _1Wire_i = requires (T t, typename T::Speed s, _1wire_id_t id) {
// Object type
requires not_<std::is_copy_constructible<T>::value>::value;
requires not_<std::is_copy_assignable<T>::value>::value;
// Members
// typename T::Speed;
// typename T::Command;
// Methods
{t.reset(s)} -> bool;
{t.tx_data(1)} -> byte_t;
{t.rx_data(s)} -> byte_t;
t.match(id, s);
t.match_n_ovdr(id);
t.skip(s);
t.skip_n_ovdr();
{t.first(s)} -> _1wire_id_t;
{t.next(s)} -> _1wire_id_t;
};
#else
namespace _1wire_i_det {
using std::declval;
template <class _Tp> using try_reset_t = decltype (declval<_Tp>().reset (declval<typename _Tp::Speed>()));
template <class _Tp> using try_rx1_t = decltype (declval<_Tp>().rx_data (declval<typename _Tp::Speed>()));
template <class _Tp> using try_tx1_t = decltype (declval<_Tp>().tx_data (declval<byte_t>(), declval<typename _Tp::Speed>()));
template <class _Tp> using try_match_t = decltype (declval<_Tp>().match (declval<_1wire_id_t&>(), declval<typename _Tp::Speed>()));
template <class _Tp> using try_match_n_ovdr_t = decltype (declval<_Tp>().match_n_ovdr (declval<_1wire_id_t&>()));
template <class _Tp> using try_skip_t = decltype (declval<_Tp>().skip (declval<typename _Tp::Speed>()));
template <class _Tp> using try_skip_n_ovdr_t = decltype (declval<_Tp>().skip_n_ovdr ());
template <class _Tp> using try_first_t = decltype (declval<_Tp>().first (declval<typename _Tp::Speed>()));
template <class _Tp> using try_next_t = decltype (declval<_Tp>().next (declval<typename _Tp::Speed>()));
template <typename _Tp, typename =void>
struct is_1wire_ : meta::false_ {};
template <typename _Tp>
struct is_1wire_ <_Tp,
meta::void_t <
// typename _Tp::Speed,
// typename _Tp::Command,
// meta::use_if_same_t <try_reset_t <_Tp>, bool>,
// meta::use_if_same_t <try_rx1_t <_Tp>, byte_t>,
// //meta::use_if_same_t <try_rx2_t <_Tp>, size_t>,
// meta::use_if_same_t <try_tx1_t <_Tp>, byte_t>,
// //meta::use_if_same_t <try_tx2_t <_Tp>, size_t>,
// meta::use_if_same_t <try_match_t<_Tp>, void>,
// meta::use_if_same_t <try_match_n_ovdr_t<_Tp>, void>,
// meta::use_if_same_t <try_skip_t<_Tp>, void>,
// meta::use_if_same_t <try_skip_n_ovdr_t<_Tp>, void>,
// meta::use_if_same_t <try_first_t <_Tp>, _1wire_id_t>,
// meta::use_if_same_t <try_next_t <_Tp>, _1wire_id_t>
void
>
> : meta::true_ {};
} // namespace _1wire_i_det
// template <typename _Tp>
// constexpr bool _1Wire_i = _1wire_i_det::is_1wire_<_Tp>::value;
#endif
} //namespace utl
#endif /* __utl_com_1wire_h__ */
utl::_1wire_i::first
_1wire_id_t first(Speed s=Speed::STD, bool alarm=false)
&#39;first&#39; operation, to search on the 1-Wire for the first device. This is performed by setting dec_...
Definition: _1wire.h:207
utl::_1wire_i::CMD_ALARM_SEARCH
Definition: _1wire.h:103
utl::_1wire_i::CMD_READ_ROM
Definition: _1wire.h:98
meta.h
Include all meta library.
utl::_1wire_i::bit
bool bit(bool b)
Write a bit to the 1-Wire bus, return response/write status and provide the recovery time...
Definition: _1wire.h:88
utl::meta::void_t
void void_t
void_t type alias
Definition: detection.h:55
utl::_1wire_i::match_n_ovdr
void match_n_ovdr(_1wire_id_t &id)
Definition: _1wire.h:181
utl::_1wire_i_det::try_match_n_ovdr_t
decltype(declval< _Tp >().match_n_ovdr(declval< _1wire_id_t & >())) try_match_n_ovdr_t
Definition: _1wire.h:676
utl::_1wire_i_det::is_1wire_
Primary template to catch any non 1-wire interface types.
Definition: _1wire.h:684
utl::_1wire_i::match
void match(_1wire_id_t &id, Speed s=Speed::STD)
Definition: _1wire.h:173
utl::_1wire_i::_reset
bool _reset(Speed s)
Definition: _1wire.h:89
utl::meta::true_
bool_< true > true_
The type used as a compile-time boolean with true value.
Definition: integral.h:68
utl::_1wire_id_t::compare
static int compare(const _1wire_id_t &lhs, const _1wire_id_t &rhs) noexcept
Full compare two dev_ids.
Definition: _1wire_id.h:72
crtp.h
utl::_1wire_i::CMD_MATCH
Definition: _1wire.h:100
utl::_1wire_i::Speed::OVDR
utl::_1wire_i_det::try_match_t
decltype(declval< _Tp >().match(declval< _1wire_id_t & >(), declval< typename _Tp::Speed >())) try_match_t
Definition: _1wire.h:675
utl::_1wire_i< virtual_tag >::match
void match(_1wire_id_t &id, Speed s=Speed::STD)
Definition: _1wire.h:372
utl::_1wire_i::speed
void speed(Speed s)
Definition: _1wire.h:86
utl::_1wire_i_det::_match_n_ovdr
void _match_n_ovdr(_T &obj, _1wire_id_t &id)
Definition: _1wire.h:505
utl::_1wire_i< type >::Speed
Speed
1-wire bus speed
Definition: _1wire.h:64
utl::_1wire_i::tx_data
byte_t tx_data(byte_t out, Speed s=Speed::STD)
Definition: _1wire.h:138
utl::_1wire_i::rx_data
byte_t rx_data(Speed s=Speed::STD)
Definition: _1wire.h:156
utl::_1wire_i_det::_first
_1wire_id_t _first(_T &obj, typename _T::Speed s, bool alarm)
&#39;first&#39; operation, to search on the 1-Wire for the first device. This is performed by setting dec_...
Definition: _1wire.h:540
utl::_1wire_i::CMD_OVDR_MATCH
Definition: _1wire.h:101
utl::_1wire_i::reset
bool reset(Speed s=Speed::STD)
Generate a 1-wire reset.
Definition: _1wire.h:128
utl::_1wire_i::_CRTP_IMPL
_CRTP_IMPL(impl_t)
utl::_1wire_id_t
Definition: _1wire_id.h:32
utl::_1wire_i_det::_next
_1wire_id_t _next(_T &obj, typename _T::Speed s, bool alarm)
&#39;next&#39; operation, to search on the 1-Wire for the next device. This search is usually performed after...
Definition: _1wire.h:556
utl::_1wire_i< virtual_tag >::next
_1wire_id_t next(Speed s=Speed::STD, bool alarm=false)
&#39;next&#39; operation, to search on the 1-Wire for the next device. This search is usually performed after...
Definition: _1wire.h:419
utl::meta::false_
bool_< false > false_
The type used as a compile-time boolean with false value.
Definition: integral.h:69
_1wire_id.h
An 1-wire Rom ID type.
utl::_1wire_i< virtual_tag >
A virtual base class implementation.
Definition: _1wire.h:260
utl::_1wire_i< virtual_tag >::reset
bool reset(Speed s=Speed::STD)
Generate a 1-wire reset.
Definition: _1wire.h:327
utl::_1wire_i< virtual_tag >::first
_1wire_id_t first(Speed s=Speed::STD, bool alarm=false)
&#39;first&#39; operation, to search on the 1-Wire for the first device. This is performed by setting dec_...
Definition: _1wire.h:406
utl
STL&#39;s core language concepts.
Definition: _1wire.h:30
utl::_1wire_i< virtual_tag >::skip_n_ovdr
void skip_n_ovdr()
Definition: _1wire.h:393
utl::_1wire_i_det::try_skip_t
decltype(declval< _Tp >().skip(declval< typename _Tp::Speed >())) try_skip_t
Definition: _1wire.h:677
utl::_1wire_i< virtual_tag >::match_n_ovdr
void match_n_ovdr(_1wire_id_t &id)
Definition: _1wire.h:380
utl::_1wire_i::pos_
_1wire_id_t pos_
Definition: _1wire.h:232
utl::_1wire_i< virtual_tag >::rx_data
byte_t rx_data(Speed s=Speed::STD)
Definition: _1wire.h:355
utl::_1wire_i_det::try_tx1_t
decltype(declval< _Tp >().tx_data(declval< byte_t >(), declval< typename _Tp::Speed >())) try_tx1_t
Definition: _1wire.h:673
utl::_1wire_i_det::_skip_n_ovdr
void _skip_n_ovdr(_T &obj)
Definition: _1wire.h:526
utl::_1wire_i::type
_1wire_i type
Export type as identity meta-function.
Definition: _1wire.h:61
utl::_1wire_i::skip
void skip(Speed s=Speed::STD)
Definition: _1wire.h:188
utl::_1wire_i_det::try_skip_n_ovdr_t
decltype(declval< _Tp >().skip_n_ovdr()) try_skip_n_ovdr_t
Definition: _1wire.h:678
utl::_1wire_i::speed
Speed speed() const
Get the 1-wire bus speed.
Definition: _1wire.h:85
utl::_1wire_i_det::try_first_t
decltype(declval< _Tp >().first(declval< typename _Tp::Speed >())) try_first_t
Definition: _1wire.h:679
utl::_1wire_i< virtual_tag >::tx_data
byte_t tx_data(byte_t out, Speed s=Speed::STD)
Definition: _1wire.h:337
utl::_1wire_i::operator=
_1wire_i & operator=(const _1wire_i &)=delete
utl::_1wire_i< virtual_tag >::skip
void skip(Speed s=Speed::STD)
Definition: _1wire.h:387
utl::_1wire_id_t::nullDev
static constexpr const _1wire_id_t & nullDev()
Return nullDev reference.
Definition: _1wire_id.h:50
utl::_1wire_i::~_1wire_i
~_1wire_i()=default
Allow destructor from derived only.
utl::_1wire_i::CMD_SKIP
Definition: _1wire.h:102
utl::_1wire_i::next
_1wire_id_t next(Speed s=Speed::STD, bool alarm=false)
&#39;next&#39; operation, to search on the 1-Wire for the next device. This search is usually performed after...
Definition: _1wire.h:220
utl::_1wire_i::Speed::STD
utl::_1wire_i< type >::Command
Command
Definition: _1wire.h:97
utl::_1wire_i::CMD_OVDR_SKIP
Definition: _1wire.h:99
utl::_1wire_i_det::try_rx1_t
decltype(declval< _Tp >().rx_data(declval< typename _Tp::Speed >())) try_rx1_t
Definition: _1wire.h:672
utl::_1wire_i
Template base class for 1-wire communication interface using CRTP.
Definition: _1wire.h:57
utl::byte_t
uint8_t byte_t
8 bits wide
Definition: types.h:31
utl::virtual_tag
virtual support tag type
Definition: crtp.h:40
utl::_1wire_i::skip_n_ovdr
void skip_n_ovdr()
Definition: _1wire.h:194
utl::_1wire_i_det::try_reset_t
decltype(declval< _Tp >().reset(declval< typename _Tp::Speed >())) try_reset_t
Definition: _1wire.h:671
utl::_1wire_i_det::_skip
void _skip(_T &obj, typename _T::Speed s)
Definition: _1wire.h:517
utl::_1wire_i< virtual_tag >::Command
Command
Definition: _1wire.h:296
utl::_1wire_i_det::try_next_t
decltype(declval< _Tp >().next(declval< typename _Tp::Speed >())) try_next_t
Definition: _1wire.h:680
utl::_1wire_i::CMD_SEARCH_ROM
Definition: _1wire.h:104
impl.h
Implementation detail main forward header.
utl::_1wire_i::cur_
_1wire_id_t cur_
Definition: _1wire.h:237
utl::_1wire_i_det::_match
void _match(_T &obj, _1wire_id_t &id, typename _T::Speed s)
Definition: _1wire.h:493
utl::_1wire_i::dec_
_1wire_id_t dec_
Definition: _1wire.h:226
utl::_1wire_i< virtual_tag >::Speed
Speed
1-wire bus speed
Definition: _1wire.h:265
utl::_1wire_i::_1wire_i
_1wire_i()=default
Allow constructor from derived only.
utl::id_t::bit
constexpr bool bit(uint8_t bit) const noexcept
Definition: id.h:159
utl::_1wire_i_det::_touch
byte_t _touch(_T &obj, byte_t out, typename _T::Speed s)
Write a byte to 1-Wire bus and read the response.
Definition: _1wire.h:467