|
| bool | AppendCmd (char *buf, std::size_t cap, std::string_view cmd) noexcept |
| |
| uint16_t | Crc16Modbus (const char *data, std::size_t len) noexcept |
| | CRC-16/MODBUS (CRC-16-IBM, reflected polynomial 0xA001, initial value 0xFFFF, no final XOR).
|
| |
| DriverError | VerifyAndStripCrc (char *line, bool require) noexcept |
| | Verify and remove the optional CRC suffix of a reply line (CR already removed).
|
| |
| void | StripOptionalModbusCrcSuffix (char *line) noexcept |
| |
| template<typename UartT > |
| DriverError | ReadAsciiLine (UartT &uart, char *buf, std::size_t cap, uint32_t timeout_ms, bool require_crc=false) noexcept |
| |
| const char * | SkipWs (const char *p) noexcept |
| |
| DriverError | Tokenize (const char *line, char *store, std::size_t store_cap, const char *tokens[], std::size_t max_tokens, std::size_t *out_count) noexcept |
| |
| bool | IsDecimalToken (const char *s, bool allow_minus) noexcept |
| | True when s is an optional '-' followed by one or more decimal digits and nothing else.
|
| |
| int32_t | ParseI32 (const char *s, bool *ok) noexcept |
| | Parse a signed 32-bit decimal (data sheet §4.1 value range). ok is set (not accumulated).
|
| |
| uint32_t | ParseU32 (const char *s, bool *ok) noexcept |
| | Parse an unsigned 32-bit decimal (no sign). ok is set (not accumulated).
|
| |
| uint64_t | ParseU64 (const char *s, bool *ok) noexcept |
| | Parse an unsigned 64-bit decimal (no sign; #IDNR). ok is set (not accumulated).
|
| |
| int32_t | FieldI32 (const char *s, bool &all_ok) noexcept |
| | Parse one field of a reply; all_ok is cleared if it is invalid and never set back to true.
|
| |
| uint32_t | FieldU32 (const char *s, bool &all_ok) noexcept |
| | Parse one field of a reply; all_ok is cleared if it is invalid and never set back to true.
|
| |
| bool | IsErroHeader (const char *tok0) noexcept |
| |
| uint16_t fdo2::detail::Crc16Modbus |
( |
const char * |
data, |
|
|
std::size_t |
len |
|
) |
| |
|
inlinenoexcept |
CRC-16/MODBUS (CRC-16-IBM, reflected polynomial 0xA001, initial value 0xFFFF, no final XOR).
Data sheet §4.2: the checksum the module appends with #CRCE 1, computed over the reply from its first character up to, not including, the :. Check value: "123456789" -> 0x4B37.
| DriverError fdo2::detail::VerifyAndStripCrc |
( |
char * |
line, |
|
|
bool |
require |
|
) |
| |
|
inlinenoexcept |
Verify and remove the optional CRC suffix of a reply line (CR already removed).
Data sheet §4.2: with #CRCE 1 every reply ends in ": C" before the CR, where C is the CRC-16 as a decimal ASCII string, computed over every byte before the : (spaces included). Replies never contain : otherwise, so a : marks the suffix. On success the line is cut at the :.
- Parameters
-
| require | When true, a line without the suffix is rejected (module known to have #CRCE 1). |
- Returns
- None (no suffix and not required, or suffix valid); CrcMismatch (checksum differs, or required and missing); ProtocolError (a
: not followed by a decimal 0..65535).