FDO2 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Functions
fdo2_driver.hpp File Reference

FDO2-G2 UART command client (PyroScience data sheet v5, §4). More...

#include "fdo2_types.hpp"
#include "fdo2_uart_interface.hpp"
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string_view>
Include dependency graph for fdo2_driver.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fdo2::Driver< UartT >
 FDO2-G2 UART client. More...
 

Namespaces

namespace  fdo2
 
namespace  fdo2::detail
 

Functions

bool fdo2::detail::AppendCmd (char *buf, std::size_t cap, std::string_view cmd) noexcept
 
uint16_t fdo2::detail::Crc16Modbus (const char *data, std::size_t len) noexcept
 CRC-16/MODBUS (CRC-16-IBM, reflected polynomial 0xA001, initial value 0xFFFF, no final XOR).
 
DriverError fdo2::detail::VerifyAndStripCrc (char *line, bool require) noexcept
 Verify and remove the optional CRC suffix of a reply line (CR already removed).
 
void fdo2::detail::StripOptionalModbusCrcSuffix (char *line) noexcept
 
template<typename UartT >
DriverError fdo2::detail::ReadAsciiLine (UartT &uart, char *buf, std::size_t cap, uint32_t timeout_ms, bool require_crc=false) noexcept
 
const char * fdo2::detail::SkipWs (const char *p) noexcept
 
DriverError fdo2::detail::Tokenize (const char *line, char *store, std::size_t store_cap, const char *tokens[], std::size_t max_tokens, std::size_t *out_count) noexcept
 
bool fdo2::detail::IsDecimalToken (const char *s, bool allow_minus) noexcept
 True when s is an optional '-' followed by one or more decimal digits and nothing else.
 
int32_t fdo2::detail::ParseI32 (const char *s, bool *ok) noexcept
 Parse a signed 32-bit decimal (data sheet §4.1 value range). ok is set (not accumulated).
 
uint32_t fdo2::detail::ParseU32 (const char *s, bool *ok) noexcept
 Parse an unsigned 32-bit decimal (no sign). ok is set (not accumulated).
 
uint64_t fdo2::detail::ParseU64 (const char *s, bool *ok) noexcept
 Parse an unsigned 64-bit decimal (no sign; #IDNR). ok is set (not accumulated).
 
int32_t fdo2::detail::FieldI32 (const char *s, bool &all_ok) noexcept
 Parse one field of a reply; all_ok is cleared if it is invalid and never set back to true.
 
uint32_t fdo2::detail::FieldU32 (const char *s, bool &all_ok) noexcept
 Parse one field of a reply; all_ok is cleared if it is invalid and never set back to true.
 
bool fdo2::detail::IsErroHeader (const char *tok0) noexcept
 

Detailed Description

FDO2-G2 UART command client (PyroScience data sheet v5, §4).

Implements the FDO2-G2 command set: #VERS, #IDNR, #MOXY, #MRAW, #LOGO. Lines are ASCII, terminated with \\r (optional \\n after \\r per §4.1). If optional CRC is enabled (#CRCE 1), responses end with : C before \\r (§4.2), C being the CRC-16/MODBUS of every byte before the : in decimal; the driver verifies it and rejects a mismatch with DriverError::CrcMismatch.

Default UART is 19200 8N1 after power-up; allow ~1 s settle time before the first transaction.