FDO2 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
fdo2::Driver< UartT > Class Template Reference

FDO2-G2 UART client. More...

#include <fdo2_driver.hpp>

Public Member Functions

 Driver (UartT &uart) noexcept
 
void SetLineTimeoutMs (uint32_t ms) noexcept
 
void SetMeasureTimeoutMs (uint32_t ms) noexcept
 
void SetSlowCommandTimeoutMs (uint32_t ms) noexcept
 Timeout for commands the module answers only after a long task (default 12000 ms).
 
uint32_t GetSlowCommandTimeoutMs () const noexcept
 
void SetCrcRequired (bool required) noexcept
 Require the #CRCE 1 checksum on every reply (data sheet §4.2).
 
bool IsCrcRequired () const noexcept
 
uint32_t GetLineTimeoutMs () const noexcept
 
uint32_t GetMeasureTimeoutMs () const noexcept
 
int32_t LastDeviceErrorCode () const noexcept
 
DriverResult< VersionInfo > ReadVersion () noexcept
 
DriverResult< uint64_t > ReadUniqueId () noexcept
 
DriverResult< MoxyReading > MeasureMoxy (uint32_t timeout_ms=0U) noexcept
 Single oxygen + temperature + status round-trip (typically < ~150 ms for M=2).
 
DriverResult< MrawReading > MeasureMraw (uint32_t timeout_ms=0U) noexcept
 Same measurement plus raw optics / vent-path pressure / internal RH.
 
DriverResult< void > FlashLogo () noexcept
 

Split exchange — send now, parse the reply later

For a caller that serves other devices while the probe measures (~150 ms): SendMeasure writes the command and returns; when the transport reports a complete line, TryReadReplyLine takes it without waiting and ParseMoxyLine / ParseMrawLine decode it. The caller owns the reply timeout. Same wire protocol as MeasureMoxy.

enum class  Measure : uint8_t { Moxy , Mraw , Version }
 Which command SendMeasure starts (Version = the #VERS identity handshake). More...
 
DriverError SendMeasure (Measure m) noexcept
 Drop stale input, then send #MOXY / #MRAW. Does not wait for the reply.
 
DriverError TryReadReplyLine (char *line, std::size_t line_cap) noexcept
 Take one complete reply line if the transport already has it.
 
static DriverResult< VersionInfo > ParseVersionLine (const char *line, int32_t *device_error) noexcept
 Decode a #VERS reply line. device_error receives the #ERRO code (may be null).
 
static DriverResult< MoxyReading > ParseMoxyLine (const char *line, int32_t *device_error) noexcept
 Decode a #MOXY reply line. device_error receives the #ERRO code (may be null).
 
static DriverResult< MrawReading > ParseMrawLine (const char *line, int32_t *device_error) noexcept
 Decode a #MRAW reply line. device_error receives the #ERRO code (may be null).
 

Detailed Description

template<typename UartT>
class fdo2::Driver< UartT >

FDO2-G2 UART client.

Template Parameters
UartTConcrete type inheriting UartInterface<UartT>.

Member Enumeration Documentation

◆ Measure

template<typename UartT >
enum class fdo2::Driver::Measure : uint8_t
strong

Which command SendMeasure starts (Version = the #VERS identity handshake).

Enumerator
Moxy 
Mraw 
Version 

Constructor & Destructor Documentation

◆ Driver()

template<typename UartT >
fdo2::Driver< UartT >::Driver ( UartT &  uart)
inlineexplicitnoexcept

Member Function Documentation

◆ FlashLogo()

template<typename UartT >
DriverResult< void > fdo2::Driver< UartT >::FlashLogo ( )
inlinenoexcept

Flash the status LED (identification). The echo comes after the ~1 s flash sequence, so this waits up to the slow-command timeout (SetSlowCommandTimeoutMs).

◆ GetLineTimeoutMs()

template<typename UartT >
uint32_t fdo2::Driver< UartT >::GetLineTimeoutMs ( ) const
inlinenoexcept

◆ GetMeasureTimeoutMs()

template<typename UartT >
uint32_t fdo2::Driver< UartT >::GetMeasureTimeoutMs ( ) const
inlinenoexcept

◆ GetSlowCommandTimeoutMs()

template<typename UartT >
uint32_t fdo2::Driver< UartT >::GetSlowCommandTimeoutMs ( ) const
inlinenoexcept

◆ IsCrcRequired()

template<typename UartT >
bool fdo2::Driver< UartT >::IsCrcRequired ( ) const
inlinenoexcept

◆ LastDeviceErrorCode()

template<typename UartT >
int32_t fdo2::Driver< UartT >::LastDeviceErrorCode ( ) const
inlinenoexcept

◆ MeasureMoxy()

template<typename UartT >
DriverResult< MoxyReading > fdo2::Driver< UartT >::MeasureMoxy ( uint32_t  timeout_ms = 0U)
inlinenoexcept

Single oxygen + temperature + status round-trip (typically < ~150 ms for M=2).

◆ MeasureMraw()

template<typename UartT >
DriverResult< MrawReading > fdo2::Driver< UartT >::MeasureMraw ( uint32_t  timeout_ms = 0U)
inlinenoexcept

Same measurement plus raw optics / vent-path pressure / internal RH.

◆ ParseMoxyLine()

template<typename UartT >
static DriverResult< MoxyReading > fdo2::Driver< UartT >::ParseMoxyLine ( const char *  line,
int32_t *  device_error 
)
inlinestaticnoexcept

Decode a #MOXY reply line. device_error receives the #ERRO code (may be null).

◆ ParseMrawLine()

template<typename UartT >
static DriverResult< MrawReading > fdo2::Driver< UartT >::ParseMrawLine ( const char *  line,
int32_t *  device_error 
)
inlinestaticnoexcept

Decode a #MRAW reply line. device_error receives the #ERRO code (may be null).

◆ ParseVersionLine()

template<typename UartT >
static DriverResult< VersionInfo > fdo2::Driver< UartT >::ParseVersionLine ( const char *  line,
int32_t *  device_error 
)
inlinestaticnoexcept

Decode a #VERS reply line. device_error receives the #ERRO code (may be null).

◆ ReadUniqueId()

template<typename UartT >
DriverResult< uint64_t > fdo2::Driver< UartT >::ReadUniqueId ( )
inlinenoexcept

◆ ReadVersion()

template<typename UartT >
DriverResult< VersionInfo > fdo2::Driver< UartT >::ReadVersion ( )
inlinenoexcept

◆ SendMeasure()

template<typename UartT >
DriverError fdo2::Driver< UartT >::SendMeasure ( Measure  m)
inlinenoexcept

Drop stale input, then send #MOXY / #MRAW. Does not wait for the reply.

◆ SetCrcRequired()

template<typename UartT >
void fdo2::Driver< UartT >::SetCrcRequired ( bool  required)
inlinenoexcept

Require the #CRCE 1 checksum on every reply (data sheet §4.2).

A reply that carries the suffix is always verified. With this set, a reply without it is rejected too (CrcMismatch), so a corrupted : cannot hide a bad reply. Set it only for a module whose CRC is enabled; the driver never sends #CRCE.

◆ SetLineTimeoutMs()

template<typename UartT >
void fdo2::Driver< UartT >::SetLineTimeoutMs ( uint32_t  ms)
inlinenoexcept

◆ SetMeasureTimeoutMs()

template<typename UartT >
void fdo2::Driver< UartT >::SetMeasureTimeoutMs ( uint32_t  ms)
inlinenoexcept

◆ SetSlowCommandTimeoutMs()

template<typename UartT >
void fdo2::Driver< UartT >::SetSlowCommandTimeoutMs ( uint32_t  ms)
inlinenoexcept

Timeout for commands the module answers only after a long task (default 12000 ms).

Data sheet §4.1: the echo comes "after completion of the requested task". Used by FlashLogo (#LOGO: the LED flashes for about 1 s, §4.3); also sized for #CALO / #CAHI, which take up to 10 s. A port that returns at the CR still returns as soon as the echo arrives.

◆ TryReadReplyLine()

template<typename UartT >
DriverError fdo2::Driver< UartT >::TryReadReplyLine ( char *  line,
std::size_t  line_cap 
)
inlinenoexcept

Take one complete reply line if the transport already has it.

Returns
None with line filled; Timeout when no complete line is waiting.

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