Skip to main content
Version: Development (main)

:::tip Experimental This documents unreleased main — not a released, committed API. See the API stability policy and use Stable instead. :::

Robotiq::Serial Class

Byte-level transport to the gripper hardware — the transport extension point.

The driver talks to the hardware through an implementation of this interface: the built-in libserialport transport on a desktop, an application's own (a TCP-serial bridge, an MCU UART/DMA transport), or a scripted connection in tests. Link parameters (port, baud rate, timeout, ...) are fixed at construction of the implementation — see SerialConfig — so a connection cannot be silently reconfigured while open.

warning

On an RTOS, read() MUST yield the CPU while awaiting bytes (e.g. interrupt/DMA completion signalled through a semaphore): it runs on the exchange thread, and a busy-wait there starves lower-priority tasks — see the caveats in ports/threadx/threadx_platform.hpp.

See Also

makeFakeGripper() for Testing & CI Utilities without hardware; ports/threadx/ for a reference MCU Transport.

Included Headers​

#include <serial.hpp>

Members​

Public Destructor
~Serial ()=default
Public Member Functions
voidopen ()=0

Open the configured link. More...

boolisOpen () const =0
voidclose ()=0

Close the link. Safe to call when already closed. More...

std::vector< uint8_t >read (size_t size, std::chrono::milliseconds timeout)=0

Read up to size bytes from the serial port. More...

voidwrite (const std::vector< uint8_t > &data)=0

Write a sequence of bytes to the serial port. More...

std::chrono::millisecondsgetTimeout () const =0

Public Destructor​

~Serial()​

virtual Robotiq::Serial::~Serial ()
virtual default

Public Member Functions​

close()​

virtual void Robotiq::Serial::close ()

Close the link. Safe to call when already closed.

getTimeout()​

virtual std::chrono::milliseconds Robotiq::Serial::getTimeout ()
Returns

The per-transaction read/write timeout of this connection.

isOpen()​

virtual bool Robotiq::Serial::isOpen ()
Returns

true if the link is currently open.

open()​

virtual void Robotiq::Serial::open ()

Open the configured link.

Exceptions
<a href="/docs/drivers/Adaptive grippers/Libraries/C++/next/API/classes/robotiq/serialioexception">SerialIOException</a>

when the port cannot be opened/configured.

read()​

virtual std::vector< uint8_t > Robotiq::Serial::read(size_tsize,
std::chrono::millisecondstimeout
)

Read up to size bytes from the serial port.

Parameters
size

Maximum number of bytes to read.

timeout

How long to wait for bytes to arrive. A zero timeout returns only what is instantly available (used to drain stale bytes before a request).

Returns

The bytes received — possibly fewer than size, or empty when nothing arrived in time.

Exceptions
<a href="/docs/drivers/Adaptive grippers/Libraries/C++/next/API/classes/robotiq/serialioexception">SerialIOException</a>

on wire-level failure.

write()​

virtual void Robotiq::Serial::write(const std::vector< uint8_t > &data
)

Write a sequence of bytes to the serial port.

Parameters
data

The bytes to write.

Exceptions
<a href="/docs/drivers/Adaptive grippers/Libraries/C++/next/API/classes/robotiq/serialioexception">SerialIOException</a>

on timeout or wire-level failure.


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

  • serial.hpp

Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.9.8.