|
SFM_FLOW_METER Driver 0.1.0
API reference
|
The driver. More...
#include <sfm_flow_meter.hpp>
Public Member Functions | |
| SfmFlowMeter (Port &port, const Config &config=Config{}) noexcept | |
| Bind a port and a configuration. No bus traffic. | |
| SfmFlowMeter (const SfmFlowMeter &)=delete | |
| The driver is not copied: it holds a reference to the port. | |
| SfmFlowMeter & | operator= (const SfmFlowMeter &)=delete |
| The driver is not copied. | |
Lifecycle | |
| Result< Wait > | BeginInitialize () noexcept |
Start identification: wake the sensor, check the product identifier (or serial number), set the averaging. Returns the first wait; finish with Poll() or AwaitPending(). | |
| Result< void > | EnsureInitialized () noexcept |
BeginInitialize() and AwaitPending(): blocking, needs the port's DelayUs(). | |
| Result< void > | Deinitialize () noexcept |
Forget the initialisation. No bus traffic: call Stop() first if the sensor measures. | |
Operations that may wait | |
| Result< Wait > | StartMeasurement (Gas gas, uint16_t o2_permille=0) noexcept |
| Start a measurement of a gas or gas mixture; reads and checks the part's scaling first. | |
| Result< Wait > | Stop () noexcept |
Stop the measurement. A no-op when idle. Failure leaves StateUnknown. | |
| Result< Wait > | SetAveraging (uint16_t n) noexcept |
| Set the averaging while idle. | |
| Result< Wait > | ReadScaling (Gas gas) noexcept |
Read and check the sensor's scaling of a gas while idle; see GetScaling(). | |
| Result< Wait > | Sleep () noexcept |
Enter sleep mode (idle only). Failure leaves StateUnknown. | |
| Result< Wait > | WakeUp () noexcept |
| Wake from sleep and write the averaging again. | |
| Result< Wait > | SoftReset () noexcept |
Reset by the part's soft-reset command (the general call needs allow_general_call_reset). Afterwards the driver is Uninitialized: call EnsureInitialized() again. | |
| Result< Wait > | HardReset () noexcept |
| Reset by the /RES pin (SFM4200) or by cycling the supply; needs the port hook. | |
| Result< Wait > | UpdateConcentration (uint16_t o2_permille) noexcept |
| Change the oxygen fraction of a running mixture (no read in between). | |
| Result< Wait > | Poll (uint32_t elapsed_us) noexcept |
| Continue a pending operation after the wait it returned. | |
| Result< Wait > | Poll () noexcept |
Poll() using the port's NowUs(); without a clock the whole wait counts as elapsed. | |
| Result< void > | AwaitPending () noexcept |
Wait with DelayUs() until no operation is pending. Needs the port's DelayUs(). | |
Measurement | |
| Result< Sample > | ReadSample () noexcept |
| Read one sample of the running measurement. | |
| Result< RawReply > | ReadRawReply () noexcept |
One raw read of the running measurement: the CRC-checked words, with no decoding, no status check and no range check. The single-shot raw access for bring-up and diagnostics; GetLastReply() returns it again without I/O. A failed read does not count towards the SF05 error limit, and a silent sensor is never reported here (NoData for ever): only ReadSample() reports DeviceReset. | |
| Result< Wait > | ReadTemperature () noexcept |
Read the sensor temperature by a pointer sequence while measuring (parts that offer it); the SF05 family needs 5 ms between the pointer and the read, so this returns a wait. The value is GetTemperature() once the operation ended without an error. | |
State | |
| State | GetState () const noexcept |
| bool | HasPending () const noexcept |
| const ProductInfo & | GetProductInfo () const noexcept |
| int32_t | GetTemperature () const noexcept |
| const RawReply & | GetLastReply () const noexcept |
| const ScalingInfo & | GetScaling () const noexcept |
| const Stats & | GetStats () const noexcept |
| const Config & | GetConfig () const noexcept |
| const PartInfo * | GetPart () const noexcept |
| Capabilities | GetCapabilities () const noexcept |
| uint8_t | GetAddress () const noexcept |
The driver.
| Port | Your port class, derived from I2cInterface<Port>. |
| FamilyMask | The protocol families the object may drive (kFamilySf06 | ...); a configuration outside the mask is Unsupported. The default is every family. |
|
inlineexplicitnoexcept |
Bind a port and a configuration. No bus traffic.
| port | The platform port; it must outlive the driver. |
| config | The configuration; checked by EnsureInitialized() and Validate(). |
|
noexcept |
Wait with DelayUs() until no operation is pending. Needs the port's DelayUs().
Ok, the operation's error, or Timeout after an implausible number of rounds.
|
noexcept |
Start identification: wake the sensor, check the product identifier (or serial number), set the averaging. Returns the first wait; finish with Poll() or AwaitPending().
InvalidArgument, Unsupported, Bus (the port could not bring the bus up), Busy, or a plan error: NoDevice, Crc, DeviceIdMismatch, InvalidReply.
|
noexcept |
Forget the initialisation. No bus traffic: call Stop() first if the sensor measures.
Ok.
|
noexcept |
BeginInitialize() and AwaitPending(): blocking, needs the port's DelayUs().
Ok, or the error of either call. Returns at once when already initialised.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
ReadSample() or ReadRawReply(); empty before. No I/O.
|
inlinenoexcept |
Auto before identification; may be null.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
ReadTemperature() decoded, in milli-degrees C; 0 before and after a failed call. No I/O.
|
noexcept |
Reset by the /RES pin (SFM4200) or by cycling the supply; needs the port hook.
Unsupported, Busy, or a plan error.
|
inlinenoexcept |
Poll().
|
noexcept |
Poll() using the port's NowUs(); without a clock the whole wait counts as elapsed.
Poll(uint32_t).
|
noexcept |
Continue a pending operation after the wait it returned.
| elapsed_us | How long you waited; less than the wait returns the remainder. |
|
noexcept |
One raw read of the running measurement: the CRC-checked words, with no decoding, no status check and no range check. The single-shot raw access for bring-up and diagnostics; GetLastReply() returns it again without I/O. A failed read does not count towards the SF05 error limit, and a silent sensor is never reported here (NoData for ever): only ReadSample() reports DeviceReset.
NotInitialized, Busy, StateUnknown, NoData, Crc, InvalidReply, Bus, Timeout.
|
noexcept |
Read one sample of the running measurement.
NotInitialized, Busy, StateUnknown, NoData (nothing new yet), Crc, InvalidReply, StatusMismatch, OutOfRange, Stale, DeviceReset, NoDevice, Bus, Timeout (SFM4100 stretch).
|
noexcept |
Read and check the sensor's scaling of a gas while idle; see GetScaling().
| gas | A gas of the part's table row. |
Unsupported, InvalidArgument, Crc, DeviceFault, or a plan error.
|
noexcept |
Read the sensor temperature by a pointer sequence while measuring (parts that offer it); the SF05 family needs 5 ms between the pointer and the read, so this returns a wait. The value is GetTemperature() once the operation ended without an error.
Unsupported, Busy, NotInitialized, StateUnknown, Bus, Crc. A failure after the pointer moved leaves StateUnknown.
|
noexcept |
Set the averaging while idle.
| n | 0 for average-until-read where offered, 1 to 128, or kAveragingDefault. |
Unsupported, InvalidArgument, Busy, or a plan error.
|
noexcept |
Enter sleep mode (idle only). Failure leaves StateUnknown.
Unsupported, Busy, or a plan error.
|
noexcept |
Reset by the part's soft-reset command (the general call needs allow_general_call_reset). Afterwards the driver is Uninitialized: call EnsureInitialized() again.
Unsupported, Busy, or a plan error.
|
noexcept |
Start a measurement of a gas or gas mixture; reads and checks the part's scaling first.
| gas | A gas of the part's table row. |
| o2_permille | Mixtures: the oxygen fraction, 0 to 1000; 0 otherwise. |
NotInitialized, Busy, StateUnknown, InvalidArgument, DeviceFault (scaling differs), or a plan error.
|
noexcept |
Stop the measurement. A no-op when idle. Failure leaves StateUnknown.
NotInitialized, Busy, StateUnknown, or a plan error.
|
noexcept |
Change the oxygen fraction of a running mixture (no read in between).
| o2_permille | The new fraction, 0 to 1000. |
Unsupported, InvalidArgument, Busy, or a plan error.
|
noexcept |
Wake from sleep and write the averaging again.
Busy, Timeout (the sensor stays asleep), or a plan error.