BASIS 2 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Enumerations
alicat_basis2_uart_interface.hpp File Reference

The serial port of the ALICAT_BASIS2 driver: the CRTP base, the UartPort concept and Bus<Port>, the transaction machine shared by every instrument on one serial line. More...

#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <span>
#include "alicat_basis2_ascii.hpp"
#include "alicat_basis2_detail.hpp"
#include "alicat_basis2_modbus.hpp"
#include "alicat_basis2_request.hpp"
#include "alicat_basis2_types.hpp"
#include "../src/alicat_basis2_uart_interface.ipp"

Go to the source code of this file.

Classes

class  alicat_basis2::UartInterface< Derived >
 CRTP base of the platform serial port. More...
 
struct  alicat_basis2::Timing
 What the bus needs to know about the instrument it talks to, per transaction. More...
 
class  alicat_basis2::Bus< Port >
 The transaction machine of one serial line, shared by every instrument on it. More...
 

Namespaces

namespace  alicat_basis2
 The ALICAT_BASIS2 driver: everything it declares lives here; internals in detail.
 

Concepts

concept  alicat_basis2::UartPort
 Satisfied by a class that derives from UartInterface<Port> and implements the five required hooks with exactly the types above, noexcept.
 

Enumerations

enum class  alicat_basis2::PollState : uint8_t { alicat_basis2::Idle = 0 , alicat_basis2::Pending = 1 , alicat_basis2::Done = 2 , alicat_basis2::Failed = 3 }
 State of a transaction as seen by Bus::Poll(). More...
 
enum class  alicat_basis2::BusState : uint8_t { alicat_basis2::Idle = 0 , alicat_basis2::Gap = 1 , alicat_basis2::AwaitReply = 2 , alicat_basis2::Settling = 3 }
 Internal phase of the bus. More...
 

Variables

Bus requirements

What the instrument needs from the serial line and its supply (manual pp. 6, 10 and 17). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123).

constexpr uint32_t alicat_basis2::kPortDefaultBaud = 38'400
 The baud rate after a factory restore, 8 data bits, no parity, 1 stop bit (M p.10).
 
constexpr uint32_t alicat_basis2::kMinBaudRate = 4'800
 The lowest baud rate the instrument offers (M p.17).
 
constexpr uint32_t alicat_basis2::kMaxBaudRate = 115'200
 The highest baud rate the instrument offers, firmware 2.2.2 or later (M p.17).
 
constexpr uint32_t alicat_basis2::kSilentBitTimes = 35
 
constexpr uint32_t alicat_basis2::kTurnaroundUs = 50'000
 
constexpr uint32_t alicat_basis2::kSupplyMinMv = 12'000
 Lowest supply, millivolts, on pin 4 only (M p.6).
 
constexpr uint32_t alicat_basis2::kSupplyMaxMv = 24'000
 Highest supply, millivolts (M p.6).
 

Detailed Description

The serial port of the ALICAT_BASIS2 driver: the CRTP base, the UartPort concept and Bus<Port>, the transaction machine shared by every instrument on one serial line.

The driver never calls an SDK. It calls hooks on a class you derive from alicat_basis2::UartInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the UART up (8N1 at the configured baud rate); true at once afterwards
bool Write(const uint8_t* data, std::size_t len) noexcept Send exactly len bytes and return only after the last stop bit has left the shift register (RS-485: the bus is released); false on any error
std::size_t Read(uint8_t* out, std::size_t cap, uint32_t timeout_ms) noexcept Copy up to cap received bytes into out and return the count (0 to cap); wait up to timeout_ms for the first byte only; timeout_ms == 0 never blocks
bool FlushInput() noexcept Discard every received byte not read yet, including the UART FIFO
uint32_t NowMs() noexcept Monotonic millisecond counter; wrap-around is handled

Optional hooks (a wrong signature is a compile error): void DelayMs(uint32_t) (the blocking wrappers sleep through it, else they spin on NowMs()), bool SetBaud(uint32_t) noexcept (needed by ChangeBaud()), void Log(LogLevel, const char*) noexcept. RS-485 direction control belongs inside Write(). TTL levels are the port's business: the instrument offers RS-232 or RS-485 levels (M p.7).