57 constexpr explicit operator bool() const noexcept {
return ok(); }
67 constexpr explicit operator bool() const noexcept {
return ok(); }
87 return static_cast<double>(r) * 0.01;
125namespace moxy_status {
147 m.p_o2_hpa =
static_cast<double>(o_raw) * 1e-3;
148 m.temp_c =
static_cast<double>(t_raw) * 1e-3;
153 int32_t i_raw, int32_t a_raw, int32_t p_raw,
154 int32_t h_raw)
noexcept {
162 r.dphi_deg =
static_cast<double>(d_raw) * 1e-3;
163 r.signal_intensity_mv =
static_cast<double>(i_raw) * 1e-3;
164 r.ambient_light_mv =
static_cast<double>(a_raw) * 1e-3;
165 r.pressure_mbar =
static_cast<double>(p_raw) * 1e-3;
166 r.rh_in_housing_pct =
static_cast<double>(h_raw) * 1e-3;
178 if (p_air_mbar <= 0.0 || !std::isfinite(p_air_mbar) || !std::isfinite(p_o2_hpa)) {
181 return 100.0 * p_o2_hpa / p_air_mbar;
constexpr uint32_t kFatalRefTooHigh
Definition fdo2_types.hpp:131
constexpr uint32_t kWarnHumidityHigh
Definition fdo2_types.hpp:133
constexpr uint32_t kErrHumiditySensor
Definition fdo2_types.hpp:135
constexpr uint32_t kFatalRefTooLow
Definition fdo2_types.hpp:130
constexpr uint32_t kWarnAutoAmpReduced
Definition fdo2_types.hpp:127
constexpr uint32_t kFatalSignalTooHigh
Definition fdo2_types.hpp:129
constexpr uint32_t kFatalSignalTooLow
Definition fdo2_types.hpp:128
constexpr uint32_t kErrPressureSensor
Definition fdo2_types.hpp:134
constexpr uint32_t kFatalTempSensor
Definition fdo2_types.hpp:132
constexpr double FirmwareRevisionToDouble(int32_t r) noexcept
Definition fdo2_types.hpp:86
constexpr bool MoxyStatusOkForOxygen(uint32_t s) noexcept
Data sheet: normal operation implies S is 0 or 1 only.
Definition fdo2_types.hpp:140
MrawReading DecodeMraw(int32_t o_raw, int32_t t_raw, uint32_t s, int32_t d_raw, int32_t i_raw, int32_t a_raw, int32_t p_raw, int32_t h_raw) noexcept
Definition fdo2_types.hpp:152
constexpr std::string_view ToString(DriverError e) noexcept
Definition fdo2_types.hpp:38
constexpr uint32_t kFdo2G2DefaultBaud
Default UART speed after power-up per FDO2-G2 data sheet §4.
Definition fdo2_types.hpp:22
DriverError
Driver-level error codes (stable for logging / telemetry).
Definition fdo2_types.hpp:28
@ CrcMismatch
#CRCE 1 checksum suffix did not match the reply, or was required and missing.
double VolumePercentO2(double p_o2_hpa, double p_air_mbar) noexcept
Volume % O₂ when p_air at the sensing membrane equals back-side pressure P.
Definition fdo2_types.hpp:177
MoxyReading DecodeMoxy(int32_t o_raw, int32_t t_raw, uint32_t s) noexcept
Definition fdo2_types.hpp:142
constexpr uint32_t kFdo2G2PowerUpSettleMs
Typical boot delay before the module accepts commands (data sheet: ~1 s).
Definition fdo2_types.hpp:25
static constexpr DriverResult success() noexcept
Definition fdo2_types.hpp:68
static constexpr DriverResult failure(DriverError e) noexcept
Definition fdo2_types.hpp:69
constexpr bool ok() const noexcept
Definition fdo2_types.hpp:66
Definition fdo2_types.hpp:52
constexpr bool ok() const noexcept
Definition fdo2_types.hpp:56
static constexpr DriverResult success(T v) noexcept
Definition fdo2_types.hpp:59
T value
Definition fdo2_types.hpp:53
static constexpr DriverResult failure(DriverError e) noexcept
Definition fdo2_types.hpp:60
DriverError error
Definition fdo2_types.hpp:54
Decoded #MOXY O T S sample (data sheet §4.3).
Definition fdo2_types.hpp:96
double p_o2_hpa
Partial pressure O₂ [hPa] = O × 10⁻³.
Definition fdo2_types.hpp:101
uint32_t status_u32
S as received.
Definition fdo2_types.hpp:99
int32_t t_raw
T as received (m°C).
Definition fdo2_types.hpp:98
int32_t o_raw
O as received (1e-3 hPa).
Definition fdo2_types.hpp:97
double temp_c
Temperature [°C] = T × 10⁻³.
Definition fdo2_types.hpp:102
Decoded #MRAW O T S D I A P H (data sheet §4.3).
Definition fdo2_types.hpp:111
int32_t i_raw
I (µV).
Definition fdo2_types.hpp:113
int32_t h_raw
H (mRH).
Definition fdo2_types.hpp:116
double dphi_deg
D × 10⁻³ degrees.
Definition fdo2_types.hpp:118
double rh_in_housing_pct
H × 10⁻³ RH.
Definition fdo2_types.hpp:122
double signal_intensity_mv
I × 10⁻³ mV.
Definition fdo2_types.hpp:119
double ambient_light_mv
A × 10⁻³ mV.
Definition fdo2_types.hpp:120
int32_t a_raw
A (µV).
Definition fdo2_types.hpp:114
int32_t d_raw
D (m°).
Definition fdo2_types.hpp:112
int32_t p_raw
P (µbar at connector / back side).
Definition fdo2_types.hpp:115
double pressure_mbar
P × 10⁻³ mbar (≈ hPa).
Definition fdo2_types.hpp:121
#VERS D N R S fields (FDO2-G2 data sheet §4.3).
Definition fdo2_types.hpp:78
int32_t num_channels
N (1 for FDO2-G2).
Definition fdo2_types.hpp:80
int32_t device_id
D (8 for FDO2-G2).
Definition fdo2_types.hpp:79
int32_t sensor_types
S bit mask: bit0 O2, bit1 temp housing, bit2 pressure, bit3 RH.
Definition fdo2_types.hpp:82
int32_t firmware_revision
R (e.g. 328 → 3.28).
Definition fdo2_types.hpp:81