yarp-devices
Loading...
Searching...
No Matches
roboticslab::CanWriterThread Class Reference

A thread that attends CAN writes. More...

#include <CanRxTxThreads.hpp>

Inheritance diagram for roboticslab::CanWriterThread:
roboticslab::CanReaderWriterThread

Public Member Functions

 CanWriterThread (const std::string &id, double delay, unsigned int bufferSize)
 Constructor.
 ~CanWriterThread () override
 Destructor.
ICanSenderDelegate * getDelegate ()
 Retrieve a handle to the CAN sender delegate.
void flush ()
 Send awaiting messages and clear the queue.
void run () override
Public Member Functions inherited from roboticslab::CanReaderWriterThread
 CanReaderWriterThread (const std::string &type, const std::string &id, double delay, unsigned int bufferSize)
 Constructor.
 ~CanReaderWriterThread () override=default
 Virtual destructor.
bool threadInit () override
 Invoked by the thread right before it is started.
void threadRelease () override
 Invoked by the thread right after it is started.
void beforeStart () override
 Invoked by the caller right before the thread is started.
void afterStart (bool success) override
 Invoked by the caller right before the thread is joined.
void onStop () override
 Callback on thread stop.
void setCanHandles (yarp::dev::ICanBus *iCanBus, yarp::dev::ICanBufferFactory *iCanBufferFactory)
 Configure CAN interface handles.
void attachDumpWriter (yarp::os::BufferedPort< yarp::os::Bottle > *dumpPort, std::mutex *dumpMutex)
 Attach YARP port writer for CAN message dumping.
void attachBusLoadMonitor (ICanMessageNotifier *busLoadMonitor)
 Attach CAN bus load monitor.

Private Member Functions

void handlePartialWrite (unsigned int sent)
 In case a write did not succeed, rearrange the CAN message buffer.

Private Attributes

unsigned int preparedMessages {0}
ICanSenderDelegate * sender {nullptr}
std::mutex bufferMutex

Additional Inherited Members

Static Protected Member Functions inherited from roboticslab::CanReaderWriterThread
static void dumpMessage (const can_message &msg, yarp::os::Bottle &b)
 Dump a CAN message to a YARP bottle.
Protected Attributes inherited from roboticslab::CanReaderWriterThread
yarp::dev::ICanBus * iCanBus {nullptr}
yarp::dev::ICanBufferFactory * iCanBufferFactory {nullptr}
yarp::dev::CanBuffer canBuffer
yarp::os::BufferedPort< yarp::os::Bottle > * dumpPort {nullptr}
std::mutex * dumpMutex {nullptr}
yarp::os::Stamp lastStamp
ICanMessageNotifier * busLoadMonitor {nullptr}
unsigned int bufferSize {0}
double delay {0.0}

Detailed Description

Uses YarpCanSenderDelegate to let raw subdevices register outgoing CAN messages. Those are written to the CAN network in FIFO batches on each step.


The documentation for this class was generated from the following files:
  • libraries/YarpPlugins/CanBusBroker/CanRxTxThreads.hpp
  • libraries/YarpPlugins/CanBusBroker/CanRxTxThreads.cpp