SFM Flow Meter Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions | Variables
sfm Namespace Reference

Namespaces

namespace  addr
 7-bit I2C addresses (data sheet §4.1 / ADDR pin strapping on SFM4300).
 
namespace  cmd
 16-bit command codes (data sheet §4.3, Tables 3–12).
 
namespace  timing
 Timing (data sheet §2.4 / §4.3).
 

Classes

class  Driver
 SF06 flow-meter client. More...
 
struct  DriverResult
 
struct  DriverResult< void >
 
class  I2cInterface
 CRTP base for the SF06 I2C transport. More...
 
struct  Measurement
 One continuous-mode sample (data sheet §4.3.1 read frame). More...
 
struct  ProductInfo
 Product identifier + 8-byte serial number (data sheet §4.3.9). More...
 
struct  Scaling
 Scale factor / offset / unit for one gas lookup table (data sheet §4.3.6). More...
 
struct  StatusWord
 Decoded status word (data sheet §4.3.2, Table 5). More...
 

Enumerations

enum class  DriverError : uint8_t {
  None = 0 , InvalidParameter , NotInitialized , BusWrite ,
  BusRead , NoData , Crc , UnsupportedGas ,
  NotSupported , UnexpectedUnit , VariantUnknown
}
 Driver-level error codes (stable for logging / telemetry). More...
 
enum class  Family : uint8_t { Sf06 = 0 , Sfx6000 }
 Part family: decides command meaning, frame layout and optional features. More...
 
enum class  Gas : uint8_t {
  O2 = 0 , Air , N2O , CO2 ,
  AirO2Mix , N2OO2Mix , CO2O2Mix , Ar ,
  HeOx , HeOxO2Mix
}
 Calibrated gas / gas-mixture lookup table selector (family-neutral). More...
 
enum class  Variant : uint8_t {
  Unknown = 0 , Sfm4300_20_B , Sfm4300_20_O , Sfm4300_20_P ,
  Sfm4300_50_B , Sfm4300_50_O , Sfm4300_50_P , Sfm6000D_50 ,
  Sfm6000D_20 , Sfm6000D_5 , Sfm3003_300_CL , Sfm3003_300_CE ,
  Sfm3013_300_CL , Sfm3013_300_CLM , Sfm3019_240 , Sfm3119_240_CL
}
 Part variant decoded from the product identifier. More...
 

Functions

const char * GetDriverVersion () noexcept
 Driver version string (from generated sfm_version.h).
 
constexpr uint8_t Crc8 (const uint8_t *data, std::size_t len) noexcept
 CRC-8 per Sensirion SF06 (poly 0x31, init 0xFF, no reflection/xorout).
 
constexpr uint8_t Crc8Word (uint16_t word) noexcept
 CRC-8 of one big-endian 16-bit word.
 
constexpr std::string_view ToString (DriverError e) noexcept
 
constexpr std::string_view ToString (Family f) noexcept
 
constexpr std::string_view ToString (Gas g) noexcept
 
constexpr uint16_t StartCommandFor (Family family, Gas g) noexcept
 Start-measurement command code for g on family.
 
constexpr bool IsMixture (Gas g) noexcept
 
constexpr std::string_view ToString (Variant v) noexcept
 
constexpr Family FamilyOf (Variant v) noexcept
 Family of a known variant (Sf06 for Unknown — the caller's assumption).
 
constexpr Variant VariantFromProductId (uint32_t product_id) noexcept
 Decode a 32-bit product identifier.
 
constexpr float FullScaleSlm (Variant v) noexcept
 Full-scale Air / O2 flow [slm] for a known variant (0 when unknown).
 
constexpr bool SupportsGas (Variant v, Gas g) noexcept
 Whether a variant carries a factory calibration for g.
 
constexpr bool GasNeedsKnownFamily (Gas g) noexcept
 True when g's start code differs between families (needs a known variant).
 
constexpr bool StatusNibbleIsKnown (Family family, uint8_t nibble) noexcept
 Whether nibble (status bits 15:12) names a start command of family.
 
constexpr Gas GasFromStatusNibble (Family family, uint8_t nibble) noexcept
 Map the status command nibble back onto a gas selector (per family).
 
constexpr Gas GasFromStatusNibble (Variant variant, uint8_t nibble) noexcept
 Variant-aware status decode: as the family overload, except that on the SFM3013-300-CLM nibble 2 is HeOx and 7 is HeOx/O2.
 

Variables

constexpr uint16_t kFlowUnitSlm20C = 0x0148
 Fixed flow-unit code returned by the SFM4300 (slm at 20 °C, 1013.25 mbar).
 
constexpr float kTemperatureScalePerC = 200.0f
 Temperature scale (data sheet Tables 15/16: scale 200 per °C, offset 0).
 
constexpr uint16_t kStatusPureGasFraction = 0x3FF
 Status-word gas fraction value for a pure calibration gas (bits 9:0).
 

Enumeration Type Documentation

◆ DriverError

enum class sfm::DriverError : uint8_t
strong

Driver-level error codes (stable for logging / telemetry).

Enumerator
None 
InvalidParameter 

bad argument (e.g. averaging window > 128)

NotInitialized 

transport EnsureInitialized() failed

BusWrite 

command write NACKed / bus error

BusRead 

command reply (identifier, scaling) NACKed / bus error

NoData 

result-buffer read NACKed — no fresh sample yet / not measuring

Crc 

CRC-8 mismatch on a received word.

UnsupportedGas 

gas / mixture not calibrated on this variant

NotSupported 

transport lacks the feature (e.g. general call)

UnexpectedUnit 

scaling unusable: scale 0, or unit ≠ 0x0148 on a known SF06 part

VariantUnknown 

gas needs a known part family (identity not read)

◆ Family

enum class sfm::Family : uint8_t
strong

Part family: decides command meaning, frame layout and optional features.

Enumerator
Sf06 

SFM4300, SFM3003/3013/3019/3119.

Sfx6000 

SFM6000D (SFC6000D controllers share the interface)

◆ Gas

enum class sfm::Gas : uint8_t
strong

Calibrated gas / gas-mixture lookup table selector (family-neutral).

Enumerator
O2 

SF06 Gas 0 · SFx6000 Gas 0.

Air 

SF06 Gas 1 · SFx6000 Gas 1.

N2O 

SF06 Gas 2 (SFM4300-20 only) · SFx6000 Gas 3.

CO2 

SF06 Gas 3 (SFM4300-20 only) · SFx6000 Gas 2.

AirO2Mix 

O2 in Air — argument: O2 volume fraction (‰)

N2OO2Mix 

SF06 mixture 1 — SFM4300-20 only.

CO2O2Mix 

SF06 mixture 2 — SFM4300-20 only.

Ar 

SFx6000 Gas 4 only.

HeOx 

SF06 Gas 2 on SFM3013-300-CLM only: heliox 80/20 (code 0x3615)

HeOxO2Mix 

SF06 mixture 1 on SFM3013-300-CLM only: O2 in HeOx (code 0x3639)

◆ Variant

enum class sfm::Variant : uint8_t
strong

Part variant decoded from the product identifier.

SFM4300 data sheet Table 13; SFM3003 Table 13, SFM3013 Table 13, SFM3019 Table 12, SFM3119 Table 12. New enumerators are appended, so stored values keep their meaning.

Enumerator
Unknown 
Sfm4300_20_B 

0x0403011x — 20 slm, basemount

Sfm4300_20_O 

0x0403021x — 20 slm, O-rings

Sfm4300_20_P 

0x0403031x — 20 slm, push-in fittings

Sfm4300_50_B 

0x0403091x — 50 slm, basemount

Sfm4300_50_O 

0x0403071x — 50 slm, O-rings

Sfm4300_50_P 

0x0403061x — 50 slm, push-in fittings

Sfm6000D_50 

0x060211xx — 50 slm (Air/O2; 20 slm CO2/N2O/Ar)

Sfm6000D_20 

0x060212xx — 20 slm (Air/O2; 10 slm CO2/N2O/Ar)

Sfm6000D_5 

0x060214xx — 5 slm (Air/O2; 2 slm CO2/N2O/Ar)

Sfm3003_300_CL 

0x040201xx — −30…300 slm, address 0x28

Sfm3003_300_CE 

0x040207xx — −150…300 slm, address 0x2D

Sfm3013_300_CL 

0x040205xx — −30…300 slm, address 0x2F

Sfm3013_300_CLM 

0x040202xx — −30…300 slm, also heliox, address 0x2F

Sfm3019_240 

0x040206xx — −10…240 slm, address 0x2E

Sfm3119_240_CL 

0x040401xx — −10…240 slm, address 0x29

Function Documentation

◆ Crc8()

constexpr uint8_t sfm::Crc8 ( const uint8_t *  data,
std::size_t  len 
)
constexprnoexcept

CRC-8 per Sensirion SF06 (poly 0x31, init 0xFF, no reflection/xorout).

◆ Crc8Word()

constexpr uint8_t sfm::Crc8Word ( uint16_t  word)
constexprnoexcept

CRC-8 of one big-endian 16-bit word.

◆ FamilyOf()

constexpr Family sfm::FamilyOf ( Variant  v)
constexprnoexcept

Family of a known variant (Sf06 for Unknown — the caller's assumption).

◆ FullScaleSlm()

constexpr float sfm::FullScaleSlm ( Variant  v)
constexprnoexcept

Full-scale Air / O2 flow [slm] for a known variant (0 when unknown).

◆ GasFromStatusNibble() [1/2]

constexpr Gas sfm::GasFromStatusNibble ( Family  family,
uint8_t  nibble 
)
constexprnoexcept

Map the status command nibble back onto a gas selector (per family).

See StatusNibbleIsKnown() for the tables. A reserved or unknown nibble returns Gas::Air; check StatusNibbleIsKnown() first when that matters. On SFM3013-300-CLM, nibbles 2 and 7 are HeOx and HeOx/O2 (data sheet §4.3.1 Table 2): use the Variant overload.

◆ GasFromStatusNibble() [2/2]

constexpr Gas sfm::GasFromStatusNibble ( Variant  variant,
uint8_t  nibble 
)
constexprnoexcept

Variant-aware status decode: as the family overload, except that on the SFM3013-300-CLM nibble 2 is HeOx and 7 is HeOx/O2.

◆ GasNeedsKnownFamily()

constexpr bool sfm::GasNeedsKnownFamily ( Gas  g)
constexprnoexcept

True when g's start code differs between families (needs a known variant).

◆ GetDriverVersion()

const char * sfm::GetDriverVersion ( )
inlinenoexcept

Driver version string (from generated sfm_version.h).

◆ IsMixture()

constexpr bool sfm::IsMixture ( Gas  g)
constexprnoexcept

◆ StartCommandFor()

constexpr uint16_t sfm::StartCommandFor ( Family  family,
Gas  g 
)
constexprnoexcept

Start-measurement command code for g on family.

Returns
0 when the family has no table for g.
Warning
The same code means different gases on the two families (0x3615 / 0x361E). Always pass the family the part reported.

◆ StatusNibbleIsKnown()

constexpr bool sfm::StatusNibbleIsKnown ( Family  family,
uint8_t  nibble 
)
constexprnoexcept

Whether nibble (status bits 15:12) names a start command of family.

SF06 (SFM4300 data sheet §4.3.2 Table 5): the nibble is the index of the running command in the start-command table — 0 O2, 1 Air, 2 N2O, 3 CO2, 4 and 5 reserved (0x3624, 0x362F), 6 Air/O2, 7 N2O/O2, 8 CO2/O2. SFx6000: 0 to 4 pure gases, 0xA O2 in Air.

◆ SupportsGas()

constexpr bool sfm::SupportsGas ( Variant  v,
Gas  g 
)
constexprnoexcept

Whether a variant carries a factory calibration for g.

SFM4300-50-x: O2, Air, Air/O2 mixture only (Table 16). SFM4300-20-x: the seven SF06 tables. SFM6000D-x: O2, Air, CO2, N2O, Ar and O2-in-Air. SFM3003 / SFM3013-300-CL / SFM3019 / SFM3119: O2, Air, Air/O2 (Table 2 of each data sheet); SFM3013-300-CLM adds HeOx and HeOx/O2. Unknown variants: O2 and Air only — every other start code means a different gas (or none) on the other family, so it is refused until the identity is read (see GasNeedsKnownFamily).

◆ ToString() [1/4]

constexpr std::string_view sfm::ToString ( DriverError  e)
constexprnoexcept

◆ ToString() [2/4]

constexpr std::string_view sfm::ToString ( Family  f)
constexprnoexcept

◆ ToString() [3/4]

constexpr std::string_view sfm::ToString ( Gas  g)
constexprnoexcept

◆ ToString() [4/4]

constexpr std::string_view sfm::ToString ( Variant  v)
constexprnoexcept

◆ VariantFromProductId()

constexpr Variant sfm::VariantFromProductId ( uint32_t  product_id)
constexprnoexcept

Decode a 32-bit product identifier.

SF06: low nibble = revision. SFx6000: low byte = revision (subject to change while the parts are preliminary).

Variable Documentation

◆ kFlowUnitSlm20C

constexpr uint16_t sfm::kFlowUnitSlm20C = 0x0148
constexpr

Fixed flow-unit code returned by the SFM4300 (slm at 20 °C, 1013.25 mbar).

◆ kStatusPureGasFraction

constexpr uint16_t sfm::kStatusPureGasFraction = 0x3FF
constexpr

Status-word gas fraction value for a pure calibration gas (bits 9:0).

◆ kTemperatureScalePerC

constexpr float sfm::kTemperatureScalePerC = 200.0f
constexpr

Temperature scale (data sheet Tables 15/16: scale 200 per °C, offset 0).