DYNAMIXEL Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dynamixel::protocol::FrameWriter Class Reference

Builds one instruction packet in a caller buffer, with byte stuffing for protocol 2.0. More...

#include <dynamixel_protocol.hpp>

Public Member Functions

 FrameWriter (std::span< uint8_t > buffer, Protocol protocol, uint8_t id, Instruction instruction) noexcept
 Start a packet.
 
void Put (uint8_t byte) noexcept
 Append one parameter byte (stuffed in protocol 2.0).
 
void PutLe16 (uint16_t value) noexcept
 Append a 16-bit value, low byte first.
 
void PutBytes (std::span< const uint8_t > data) noexcept
 Append bytes.
 
std::size_t Finish () noexcept
 Complete the packet: length and CRC or checksum.
 

Detailed Description

Builds one instruction packet in a caller buffer, with byte stuffing for protocol 2.0.

Put the parameters, then Finish(). Any write that does not fit, or a protocol 1.0 packet over 253 parameters, makes Finish() return 0: nothing is sent then.

Constructor & Destructor Documentation

◆ FrameWriter()

dynamixel::protocol::FrameWriter::FrameWriter ( std::span< uint8_t >  buffer,
Protocol  protocol,
uint8_t  id,
Instruction  instruction 
)
inlinenoexcept

Start a packet.

Parameters
bufferWhere the packet goes; the driver's transmit buffer.
protocolThe packet format.
idThe target ID (0 to 254).
instructionThe instruction code.

Member Function Documentation

◆ Finish()

std::size_t dynamixel::protocol::FrameWriter::Finish ( )
inlinenoexcept

Complete the packet: length and CRC or checksum.

Returns
The packet size in bytes, or 0 when it did not fit or is too long for the protocol.

◆ Put()

void dynamixel::protocol::FrameWriter::Put ( uint8_t  byte)
inlinenoexcept

Append one parameter byte (stuffed in protocol 2.0).

Parameters
byteThe byte.

◆ PutBytes()

void dynamixel::protocol::FrameWriter::PutBytes ( std::span< const uint8_t >  data)
inlinenoexcept

Append bytes.

Parameters
dataThe bytes.

◆ PutLe16()

void dynamixel::protocol::FrameWriter::PutLe16 ( uint16_t  value)
inlinenoexcept

Append a 16-bit value, low byte first.

Parameters
valueThe value.

The documentation for this class was generated from the following file: