|
DYNAMIXEL Driver 0.1.0
API reference
|
The UART port of the DYNAMIXEL driver: the CRTP base, the UartPort concept and the line requirements.
More...
#include <concepts>#include <cstddef>#include <cstdint>#include "dynamixel_detail.hpp"#include "dynamixel_types.hpp"Go to the source code of this file.
Classes | |
| class | dynamixel::UartInterface< Derived > |
| CRTP base of the platform UART port. More... | |
Namespaces | |
| namespace | dynamixel |
The DYNAMIXEL driver: everything it declares lives here; internals in detail. | |
Concepts | |
| concept | dynamixel::UartPort |
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exactly the types above and noexcept. | |
Variables | |
Bus requirements | |
What the servos need from the UART (e-Manual, protocol 1.0 and 2.0, "DYNAMIXEL Protocol"). A port and a board configuration check their settings against these with | |
| constexpr uint32_t | dynamixel::kMaxBaudRate = 4'500'000 |
| constexpr uint32_t | dynamixel::kFactoryBaudRate = 57'600 |
| Factory rate of the X series (Baud Rate register value 1). | |
| constexpr uint32_t | dynamixel::kTurnaroundUs = 500 |
| constexpr uint32_t | dynamixel::kMaxTurnaroundUs = 508 |
| Largest Return Delay Time (254 counts of 2 microseconds). | |
| constexpr uint32_t | dynamixel::kInstructionByteGapMaxUsV2 = 1500 |
| Longest pause between two bytes of a protocol 2.0 instruction packet that the servo accepts. | |
| constexpr uint32_t | dynamixel::kInstructionByteGapMaxUsV1 = 100'000 |
| Longest pause between two bytes of a protocol 1.0 instruction packet that the servo accepts. | |
The UART port of the DYNAMIXEL driver: the CRTP base, the UartPort concept and the line requirements.
The driver never calls an SDK. It calls hooks on a class you derive from dynamixel::UartInterface<Self>:
| Hook | Contract |
|---|---|
bool EnsureInitialized() noexcept | UART up at 8 data bits, no parity, 1 stop bit; true at once afterwards |
bool Write(const uint8_t* data, std::size_t len) noexcept | Switch the line to transmit, send all len bytes without gaps, wait until the last stop bit has left the shift register, switch back to receive; false on an error |
std::size_t Read(uint8_t* data, std::size_t max, uint32_t timeout_us) noexcept | Return 1 to max bytes as soon as one is there, waiting at most timeout_us for the first; 0 when none arrived |
bool FlushInput() noexcept | Drop every received byte not yet returned by Read() |
void DelayUs(uint32_t us) noexcept | Wait at least us microseconds (reboot and baud change settle times) |
bool SetBaudRate(uint32_t baud) noexcept (optional) | Reconfigure the UART; without it the baud is the port's own |
void Log(LogLevel, const char*) noexcept (optional) | One plain text line per event |
Half duplex (e-Manual, protocol 2.0, "Tx, Rx Direction"): the direction switch back to receive must wait for the transmit shift register to be empty, not only the buffer, and must not be delayed by an interrupt past the servo's Return Delay Time. A transmit pause longer than 1.5 ms inside a protocol 2.0 packet (100 ms in protocol 1.0) makes the servo drop the packet (kInstructionByteGapMaxUs...), so Write() sends the packet in one go. With a single-wire loopback the port leaves the echo in the receive FIFO and Config::echo = EchoMode::Loopback makes the driver verify it. The port moves raw bytes; the driver builds, frames, checks and times everything.