Alicat BASIS-2 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
alicat_basis2::UartInterface< Derived > Class Template Reference

CRTP base for the BASIS-2 serial transport. More...

#include <alicat_basis2_uart_interface.hpp>

Public Member Functions

void write (const uint8_t *data, std::size_t length) noexcept
 Send length bytes synchronously.
 
std::size_t read (uint8_t *out, std::size_t max, uint32_t timeout_ms) noexcept
 Read up to max bytes into out with a per-call timeout.
 
void flush_rx () noexcept
 Drop any unread bytes from the RX path.
 
void delay_ms (uint32_t ms) noexcept
 Sleep at least ms milliseconds.
 
template<typename... Args>
void log (const char *tag, const char *fmt, Args... args) noexcept
 Optional logging hook, printf-style.
 

Detailed Description

template<typename Derived>
class alicat_basis2::UartInterface< Derived >

CRTP base for the BASIS-2 serial transport.

Template Parameters
DerivedThe concrete adapter (e.g. AlicatUartEspAdapter).

The driver dispatches every byte through static_cast<Derived*>(this), so there is zero virtual-call overhead. The compiler can fully inline the adapter calls into the driver's read/write loops.

Member Function Documentation

◆ delay_ms()

template<typename Derived >
void alicat_basis2::UartInterface< Derived >::delay_ms ( uint32_t  ms)
inlinenoexcept

Sleep at least ms milliseconds.

Calls Derived::delay_ms_impl(ms) when the adapter has one (public, or private with friend class UartInterface<Derived>; any cv/ref qualifier). Otherwise a no-op: there is no portable time base to busy-wait on.

◆ flush_rx()

template<typename Derived >
void alicat_basis2::UartInterface< Derived >::flush_rx ( )
inlinenoexcept

Drop any unread bytes from the RX path.

◆ log()

template<typename Derived >
template<typename... Args>
void alicat_basis2::UartInterface< Derived >::log ( const char *  tag,
const char *  fmt,
Args...  args 
)
inlinenoexcept

Optional logging hook, printf-style.

Forwards tag, fmt and the arguments unchanged to Derived::log_impl(tag, fmt, args...) when the adapter has one; otherwise a no-op. The driver logs every failed transaction here with the tag "alicat_basis2"; fmt is always a string literal.

◆ read()

template<typename Derived >
std::size_t alicat_basis2::UartInterface< Derived >::read ( uint8_t *  out,
std::size_t  max,
uint32_t  timeout_ms 
)
inlinenoexcept

Read up to max bytes into out with a per-call timeout.

Returns
Number of bytes actually written into out.

◆ write()

template<typename Derived >
void alicat_basis2::UartInterface< Derived >::write ( const uint8_t *  data,
std::size_t  length 
)
inlinenoexcept

Send length bytes synchronously.

Must block until all bytes are accepted by the underlying serial driver.


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