|
BASIS 2 Driver 0.1.0
API reference
|
The ASCII grammar of "BASIS Protocol 2" (M pp.10 to 17): the command table, the encoder, the independent wire validator and the pure reply decoders. More...
#include <algorithm>#include <array>#include <cstddef>#include <cstdint>#include <span>#include "alicat_basis2_registers.hpp"#include "alicat_basis2_request.hpp"#include "alicat_basis2_types.hpp"Go to the source code of this file.
Classes | |
| struct | alicat_basis2::ascii::CommandSpec |
| One row of the command table (rows C01 to C46). More... | |
| struct | alicat_basis2::ascii::Args |
| The arguments of a request before encoding. More... | |
| struct | alicat_basis2::ascii::Token |
| One token: where it starts and how long it is. More... | |
| struct | alicat_basis2::ascii::Tokens |
| The tokens of a line. More... | |
| struct | alicat_basis2::ascii::FrameRules |
| The rules a decoded frame is checked against. More... | |
| struct | alicat_basis2::ascii::Values |
The numbers of a short reply: ID v1 [v2 ...]. More... | |
Namespaces | |
| namespace | alicat_basis2 |
The ALICAT_BASIS2 driver: everything it declares lives here; internals in detail. | |
| namespace | alicat_basis2::ascii |
| The ASCII grammar: table, encoder, validator, decoders. | |
Enumerations | |
| enum class | alicat_basis2::ascii::ArgKind : uint8_t { alicat_basis2::ascii::ArgKind::None = 0 , alicat_basis2::ascii::ArgKind::Int = 1 , alicat_basis2::ascii::ArgKind::Milli = 2 , alicat_basis2::ascii::ArgKind::Letter = 3 , alicat_basis2::ascii::ArgKind::Star = 4 , alicat_basis2::ascii::ArgKind::Ramp = 5 , alicat_basis2::ascii::ArgKind::IntPair = 6 } |
| What a command's argument looks like. More... | |
Functions | |
| constexpr const CommandSpec & | alicat_basis2::ascii::Spec (Command c) noexcept |
| The row of a command. | |
| Result< Request > | alicat_basis2::ascii::Make (Command command, char id, const Args &args, bool allow_guarded) noexcept |
| Build a request: validate every argument, write the wire bytes. | |
| bool | alicat_basis2::ascii::IsLegalRequest (std::span< const uint8_t > bytes) noexcept |
Whether bytes is exactly one request of the grammar of M pp.10 to 17: unit ID A to Z, a command with its argument, one CR at the end, only the characters A-Z 0-9 space + - . * @ =. | |
| Error | alicat_basis2::ascii::Tokenize (std::span< const char > line, Tokens &out) noexcept |
| Split a line on runs of spaces. | |
| std::span< const char > | alicat_basis2::ascii::View (std::span< const char > line, const Token &t) noexcept |
| The characters of a token. | |
| bool | alicat_basis2::ascii::ParseDecimal (std::span< const char > tok, Decimal &out) noexcept |
Parse ‘[+-]? digit{1,12} ( ’.' digit{1,6} )?: no exponent, no hex, nonan`, no leading or trailing point. | |
| constexpr char | alicat_basis2::ascii::Upper (char c) noexcept |
| Upper-case a letter. | |
| bool | alicat_basis2::ascii::EqualsNoCase (std::span< const char > tok, const char *word) noexcept |
| Case-insensitive equality of a token and a word. | |
| bool | alicat_basis2::ascii::StartsWithId (std::span< const char > line, const Tokens &toks, char id) noexcept |
| Whether the first token is exactly one letter equal (any case) to the unit ID. | |
| Error | alicat_basis2::ascii::DecodeFrame (std::span< const char > line, const FrameRules &rules, Frame &out, FrameLayout &layout_seen) noexcept |
| Decode a data frame (C01): ID, three or five numbers, the gas, zero or more flags (M p.10 to 11). | |
| Error | alicat_basis2::ascii::DecodeData (std::span< const char > line, uint8_t mask, const FrameRules &rules, Frame &out) noexcept |
Decode a DV n reply: ID, then the selected fields in table order (M p.11). | |
| Error | alicat_basis2::ascii::DecodeValues (std::span< const char > line, char id, uint8_t count, Values &out) noexcept |
Decode ID followed by exactly count numbers. | |
| Error | alicat_basis2::ascii::DecodeLetter (std::span< const char > line, char id, const char *allowed, char &out) noexcept |
Decode ID x where x is one character out of allowed (case-insensitive). | |
| Error | alicat_basis2::ascii::DecodeText (std::span< const char > line, char id, Text &out) noexcept |
Decode ID text...: the rest of the line after the ID, truncated to kTextMax characters. | |
| Error | alicat_basis2::ascii::DecodeGas (std::span< const char > line, char id, Frame &out) noexcept |
Decode a gas reply ID number name (C27, C29). | |
| Error | alicat_basis2::ascii::DecodeFullScale (std::span< const char > line, char id, FullScale &out) noexcept |
Decode a full-scale reply ID value units (C35). | |
| FlowUnit | alicat_basis2::ascii::FlowUnitFromLabel (std::span< const char > label) noexcept |
The flow unit of an instrument's label (case-insensitive), Other when it is not one of the twenty. | |
| Error | alicat_basis2::ascii::DecodeGasList (std::span< const char > line, char id, GasList &out) noexcept |
Decode a gas list ID n name n name ... (C28, A5); sets raw when it does not parse. | |
| Error | alicat_basis2::ascii::DecodeWindow (std::span< const char > line, char id, uint8_t count, uint32_t &time_ms, Values &out) noexcept |
Decode ID time ... replies of DVAA (two values after the time) and DVAR (four). | |
| bool | alicat_basis2::ascii::IsErrorToken (std::span< const char > line, char id) noexcept |
Whether a reply line is the error token: ? alone, or ? after the unit ID. | |
Variables | |
| constexpr char | alicat_basis2::ascii::kCr = '\r' |
| Carriage return, the terminator of every request and reply (M p.10). | |
| constexpr std::size_t | alicat_basis2::ascii::kCommandRows = 46 |
| Number of rows of the command table. | |
| constexpr int64_t | alicat_basis2::ascii::kMilliCap = 999'999'999'999LL |
| constexpr int64_t | alicat_basis2::ascii::kMeasureMaxMs = 163'837 |
| Longest measurement duration in ms the driver sends (derived: 65535 samples of 2.5 ms, A7). | |
| constexpr std::array< CommandSpec, kCommandRows > | alicat_basis2::ascii::kCommands |
The command table, indexed by Command (data; one row per command of the coverage map). | |
| constexpr std::size_t | alicat_basis2::ascii::kMaxTokens = 26 |
| Tokens in a line, at most. | |
| constexpr std::size_t | alicat_basis2::ascii::kMaxToken = 32 |
| Longest token, in characters. | |
The ASCII grammar of "BASIS Protocol 2" (M pp.10 to 17): the command table, the encoder, the independent wire validator and the pure reply decoders.
Wire form of a request: <ID><TOKEN>[ <ARG>]<CR>. Numbers are formatted in integer arithmetic (never printf("%f"), never an exponent). Everything here is pure: no I/O, no allocation.