yarp-devices
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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.
 
ICanSenderDelegategetDelegate ()
 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::Contactable *dumpPort, yarp::os::PortWriterBuffer< yarp::os::Bottle > *dumpWriter, 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
 
ICanSenderDelegatesender
 
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
 
yarp::dev::ICanBufferFactory * iCanBufferFactory
 
yarp::dev::CanBuffer canBuffer
 
yarp::os::Contactable * dumpPort
 
yarp::os::PortWriterBuffer< yarp::os::Bottle > * dumpWriter
 
std::mutex * dumpMutex
 
yarp::os::Stamp lastStamp
 
ICanMessageNotifierbusLoadMonitor
 
unsigned int bufferSize
 
double delay
 

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: