DYNAMIXEL Driver 0.1.0
API reference
Loading...
Searching...
No Matches
dynamixel_uart_interface.hpp
Go to the documentation of this file.
1// clang-format off: the table below must keep one row per line.
30// clang-format on
31#ifndef DYNAMIXEL_UART_INTERFACE_HPP
32#define DYNAMIXEL_UART_INTERFACE_HPP
33
34#include <concepts>
35#include <cstddef>
36#include <cstdint>
37
38#include "dynamixel_detail.hpp"
39#include "dynamixel_types.hpp"
40
41namespace dynamixel {
42
52inline constexpr uint32_t kMaxBaudRate = 4'500'000;
54inline constexpr uint32_t kFactoryBaudRate = 57'600;
57inline constexpr uint32_t kTurnaroundUs = 500;
59inline constexpr uint32_t kMaxTurnaroundUs = 508;
61inline constexpr uint32_t kInstructionByteGapMaxUsV2 = 1500;
63inline constexpr uint32_t kInstructionByteGapMaxUsV1 = 100'000;
76template <typename Derived>
78public:
80 UartInterface(const UartInterface&) = delete;
83
84protected:
86 UartInterface() noexcept = default;
88 ~UartInterface() noexcept = default;
89};
90
101template <typename Port>
102concept UartPort = std::derived_from<Port, UartInterface<Port>> && requires {
103 detail::ExactHook<Port, bool() noexcept>::Take(&Port::EnsureInitialized);
104 detail::ExactHook<Port, bool(const uint8_t*, std::size_t) noexcept>::Take(&Port::Write);
105 detail::ExactHook<Port, std::size_t(uint8_t*, std::size_t, uint32_t) noexcept>::Take(&Port::Read);
106 detail::ExactHook<Port, bool() noexcept>::Take(&Port::FlushInput);
107 detail::ExactHook<Port, void(uint32_t) noexcept>::Take(&Port::DelayUs);
108};
109
110} // namespace dynamixel
111
112#endif // DYNAMIXEL_UART_INTERFACE_HPP
CRTP base of the platform UART port.
Definition dynamixel_uart_interface.hpp:77
UartInterface() noexcept=default
Only the derived port is constructed.
UartInterface & operator=(const UartInterface &)=delete
Ports are not copied: the driver holds a reference.
UartInterface(const UartInterface &)=delete
Ports are not copied: the driver holds a reference.
Satisfied by a class that derives from UartInterface<Port> and implements the required hooks with exa...
Definition dynamixel_uart_interface.hpp:102
Compile-time helpers of the DYNAMIXEL driver: typed integer literals, exact hook matching,...
Public types of the DYNAMIXEL driver: errors, Result<T>, protocol enumerations, replies,...
The DYNAMIXEL driver: everything it declares lives here; internals in detail.
Definition dynamixel.hpp:35
constexpr uint32_t kMaxTurnaroundUs
Largest Return Delay Time (254 counts of 2 microseconds).
Definition dynamixel_uart_interface.hpp:59
constexpr uint32_t kTurnaroundUs
Definition dynamixel_uart_interface.hpp:57
constexpr uint32_t kInstructionByteGapMaxUsV1
Longest pause between two bytes of a protocol 1.0 instruction packet that the servo accepts.
Definition dynamixel_uart_interface.hpp:63
constexpr uint32_t kFactoryBaudRate
Factory rate of the X series (Baud Rate register value 1).
Definition dynamixel_uart_interface.hpp:54
constexpr uint32_t kMaxBaudRate
Definition dynamixel_uart_interface.hpp:52
constexpr uint32_t kInstructionByteGapMaxUsV2
Longest pause between two bytes of a protocol 2.0 instruction packet that the servo accepts.
Definition dynamixel_uart_interface.hpp:61