Alicat BASIS-2 Driver 1.0.0
API reference
Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions | Variables
alicat_basis2 Namespace Reference

Namespaces

namespace  MeasurementTrigger
 Measurement-trigger bitmask — register 4200 (controllers only).
 
namespace  modbus
 
namespace  reg
 

Classes

class  Driver
 Main BASIS-2 driver. More...
 
struct  DriverResult
 Lightweight result wrapper. Aborts on value() if !ok(). More...
 
struct  DriverResult< void >
 
struct  InstantaneousData
 Decoded snapshot of registers 2100..2109 (one Modbus burst). More...
 
struct  InstrumentIdentity
 Static identification of an instrument (read once at init). More...
 
struct  InstrumentStatus
 Carries the global instrument health derived from InstantaneousData. More...
 
struct  MeasurementData
 Decoded measurement-window result (registers 4201..4215). More...
 
class  UartInterface
 CRTP base for the BASIS-2 serial transport. More...
 

Enumerations

enum class  DriverError : uint8_t {
  None = 0 , NotInitialized , InvalidParameter , InvalidAddress ,
  BufferTooSmall , SerialError , Timeout , BadCrc ,
  InvalidFrame , ModbusException , UnsupportedRequest , ResponseMismatch ,
  AsciiBadResponse
}
 Driver-level error codes. More...
 
enum class  ModbusExceptionCode : uint8_t {
  None = 0x00 , IllegalFunction = 0x01 , IllegalDataAddress = 0x02 , IllegalDataValue = 0x03 ,
  ServerDeviceFailure = 0x04 , Acknowledge = 0x05 , ServerDeviceBusy = 0x06
}
 Exception code of a Modbus exception reply (function code | 0x80, one code byte). More...
 
enum class  Gas : uint8_t {
  Air = 0 , Argon = 1 , CarbonDioxide = 2 , Nitrogen = 3 ,
  Oxygen = 4 , NitrousOxide = 5 , Hydrogen = 6 , Helium = 7 ,
  Methane = 8
}
 Index into the BASIS-2 calibrated gas table. More...
 
enum class  FlowUnits : uint8_t {
  SCCM = 0 , NCCM = 1 , SLPM = 2 , NLPM = 3 ,
  SmL_s = 4 , NmL_s = 5 , SmL_m = 6 , NmL_m = 7 ,
  SL_h = 8 , NL_h = 9 , SCCS = 10 , NCCS = 11 ,
  Sm3_h = 12 , Nm3_h = 13 , Sm3_d = 14 , Nm3_d = 15 ,
  SCIM = 16 , SCFM = 17 , SCFH = 18 , SCFD = 19 ,
  Unknown = 0xFF
}
 Flow-unit identifier read from instrument register 49. More...
 
enum class  BaudRate : uint8_t {
  Bps_4800 = 0 , Bps_9600 = 1 , Bps_19200 = 2 , Bps_38400 = 3 ,
  Bps_57600 = 4 , Bps_115200 = 5
}
 Baud-rate codes for register 21 (datasheet "Changing the Baud Rate"). More...
 
enum class  SetpointSource : uint8_t { Analog = 0 , DigitalSaved = 1 , DigitalUnsaved = 2 }
 Setpoint source — register 516 (controllers only). More...
 
enum class  TotalizerLimitMode : uint8_t { SaturateNoError = 0 , ResetNoError = 1 , SaturateWithOvr = 2 , ResetWithOvr = 3 }
 Totalizer overflow behaviour — register 54. More...
 

Functions

const char * GetDriverVersion () noexcept
 Driver version string (from generated alicat_basis2_version.h).
 
constexpr std::string_view ToString (DriverError e) noexcept
 Convert a DriverError to a stable human-readable string (no allocation).
 
constexpr std::string_view ToString (ModbusExceptionCode c) noexcept
 Convert a ModbusExceptionCode to a stable human-readable string (no allocation).
 
constexpr std::string_view GasShortName (Gas g) noexcept
 
constexpr std::string_view ToString (FlowUnits u) noexcept
 
constexpr uint32_t BaudRateToBps (BaudRate b) noexcept
 

Variables

constexpr uint8_t kBroadcastAddress = 0
 
constexpr uint8_t kMaxModbusAddress = 247
 
constexpr uint16_t kMagicTare = 0xAA55
 
constexpr uint16_t kMagicFactoryRestore = 0x5214
 
constexpr uint16_t kDefaultTimeoutMs = 200
 
constexpr uint16_t kInterFrameDelayMs = 5
 
constexpr uint32_t kDefaultBusBaudBps = 38400
 Baud rate the driver assumes for the inter-frame gap until told otherwise (the instrument's factory default, manual Rev 4 p.
 

Enumeration Type Documentation

◆ BaudRate

enum class alicat_basis2::BaudRate : uint8_t
strong

Baud-rate codes for register 21 (datasheet "Changing the Baud Rate").

The numeric value is what the instrument expects on the wire; the BaudRateToBps helper converts it to a real bits-per-second number for driver-side serial-port reconfiguration.

Enumerator
Bps_4800 
Bps_9600 
Bps_19200 
Bps_38400 

Factory default.

Bps_57600 
Bps_115200 

◆ DriverError

enum class alicat_basis2::DriverError : uint8_t
strong

Driver-level error codes.

Every public Driver entry point returns one of these in its result type. The values are stable and may be used directly in CAN/MQTT payloads.

Enumerator
None 

Operation succeeded.

NotInitialized 

Driver not initialized yet.

InvalidParameter 

Out-of-range argument.

InvalidAddress 

Modbus address outside 1..247.

BufferTooSmall 

Provided buffer is too small for the response.

SerialError 

Serial transport-layer error (HW failure).

Timeout 

No response within the configured timeout.

BadCrc 

CRC-16 mismatch on received Modbus frame.

InvalidFrame 

Frame too short, wrong function code, etc.

ModbusException 

Slave returned a Modbus exception PDU.

UnsupportedRequest 

Slave does not implement this register/command.

ResponseMismatch 

Echo doesn't match request (function 6/16).

AsciiBadResponse 

ASCII reply not parseable.

◆ FlowUnits

enum class alicat_basis2::FlowUnits : uint8_t
strong

Flow-unit identifier read from instrument register 49.

The numeric value matches the datasheet table verbatim.

Enumerator
SCCM 
NCCM 
SLPM 
NLPM 
SmL_s 
NmL_s 
SmL_m 
NmL_m 
SL_h 
NL_h 
SCCS 
NCCS 
Sm3_h 
Nm3_h 
Sm3_d 
Nm3_d 
SCIM 
SCFM 
SCFH 
SCFD 
Unknown 

◆ Gas

enum class alicat_basis2::Gas : uint8_t
strong

Index into the BASIS-2 calibrated gas table.

The instrument is factory-calibrated for these 9 gases; the value is what the device expects on register 2100 / GS ASCII command.

Enumerator
Air 
Argon 
CarbonDioxide 
Nitrogen 
Oxygen 
NitrousOxide 
Hydrogen 
Helium 
Methane 

◆ ModbusExceptionCode

enum class alicat_basis2::ModbusExceptionCode : uint8_t
strong

Exception code of a Modbus exception reply (function code | 0x80, one code byte).

Modbus Application Protocol V1.1b3, section 7. The BASIS-2 manual (Rev 4, "Communicating Via Modbus-RTU", p. 18) names the illegal data address ("Bad Address") reply for undefined registers. Driver::GetLastException() returns the code of the last exception reply.

Enumerator
None 

The last transaction got no exception reply.

IllegalFunction 

Function code not supported.

IllegalDataAddress 

Register not implemented ("Bad Address").

IllegalDataValue 

Value not accepted.

ServerDeviceFailure 

Unrecoverable error in the instrument.

Acknowledge 

Accepted, long-running.

ServerDeviceBusy 

Busy; retry later.

◆ SetpointSource

enum class alicat_basis2::SetpointSource : uint8_t
strong

Setpoint source — register 516 (controllers only).

Analog — 0–5 V or 4–20 mA on pin 1 controls the setpoint; digital S / register-2053 writes are ignored. DigitalSaved — most recent digital setpoint is persisted to flash and used at next power-up. Avoid frequent writes (the datasheet warns of NVM wear). DigitalUnsaved — digital setpoint is volatile (lost on power loss). Recommended whenever the setpoint changes faster than once per few minutes.

Enumerator
Analog 
DigitalSaved 
DigitalUnsaved 

◆ TotalizerLimitMode

enum class alicat_basis2::TotalizerLimitMode : uint8_t
strong

Totalizer overflow behaviour — register 54.

Enumerator
SaturateNoError 
ResetNoError 
SaturateWithOvr 
ResetWithOvr 

Function Documentation

◆ BaudRateToBps()

constexpr uint32_t alicat_basis2::BaudRateToBps ( BaudRate  b)
constexprnoexcept

◆ GasShortName()

constexpr std::string_view alicat_basis2::GasShortName ( Gas  g)
constexprnoexcept

◆ GetDriverVersion()

const char * alicat_basis2::GetDriverVersion ( )
inlinenoexcept

Driver version string (from generated alicat_basis2_version.h).

◆ ToString() [1/3]

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

Convert a DriverError to a stable human-readable string (no allocation).

◆ ToString() [2/3]

constexpr std::string_view alicat_basis2::ToString ( FlowUnits  u)
constexprnoexcept

◆ ToString() [3/3]

constexpr std::string_view alicat_basis2::ToString ( ModbusExceptionCode  c)
constexprnoexcept

Convert a ModbusExceptionCode to a stable human-readable string (no allocation).

Variable Documentation

◆ kBroadcastAddress

constexpr uint8_t alicat_basis2::kBroadcastAddress = 0
inlineconstexpr

◆ kDefaultBusBaudBps

constexpr uint32_t alicat_basis2::kDefaultBusBaudBps = 38400
inlineconstexpr

Baud rate the driver assumes for the inter-frame gap until told otherwise (the instrument's factory default, manual Rev 4 p.

18).

◆ kDefaultTimeoutMs

constexpr uint16_t alicat_basis2::kDefaultTimeoutMs = 200
inlineconstexpr

◆ kInterFrameDelayMs

constexpr uint16_t alicat_basis2::kInterFrameDelayMs = 5
inlineconstexpr
Deprecated:
Never used by the driver. The inter-frame gap is computed from the bus baud rate: modbus::InterFrameGapUs(), Driver::SetBusBaudRate().

◆ kMagicFactoryRestore

constexpr uint16_t alicat_basis2::kMagicFactoryRestore = 0x5214
inlineconstexpr

◆ kMagicTare

constexpr uint16_t alicat_basis2::kMagicTare = 0xAA55
inlineconstexpr

◆ kMaxModbusAddress

constexpr uint8_t alicat_basis2::kMaxModbusAddress = 247
inlineconstexpr