3 #ifndef __SINGLE_BUS_BROKER_HPP__
4 #define __SINGLE_BUS_BROKER_HPP__
9 #include <yarp/os/Bottle.h>
10 #include <yarp/os/Port.h>
11 #include <yarp/os/PortReaderBuffer.h>
12 #include <yarp/os/PortWriterBuffer.h>
13 #include <yarp/os/RpcServer.h>
14 #include <yarp/os/Searchable.h>
15 #include <yarp/os/TypedReaderCallback.h>
17 #include <yarp/dev/CanBusInterface.h>
18 #include <yarp/dev/PolyDriver.h>
20 #include "CanRxTxThreads.hpp"
21 #include "SdoReplier.hpp"
22 #include "BusLoadMonitor.hpp"
39 class SingleBusBroker final :
public yarp::os::TypedReaderCallback<yarp::os::Bottle>
49 bool configure(
const yarp::os::Searchable & config);
65 {
return readerThread; }
69 {
return writerThread; }
76 void onRead(yarp::os::Bottle & b)
override;
87 yarp::dev::ICanBus * iCanBus;
88 yarp::dev::ICanBufferFactory * iCanBufferFactory;
90 yarp::os::Port dumpPort;
91 yarp::os::PortWriterBuffer<yarp::os::Bottle> dumpWriter;
94 yarp::os::Port sendPort;
95 yarp::os::PortReaderBuffer<yarp::os::Bottle> commandReader;
97 yarp::os::RpcServer sdoPort;
100 yarp::os::Port busLoadPort;
Periodically sends CAN bus load stats through a YARP port.
Definition: BusLoadMonitor.hpp:40
A thread that deals with CAN reads.
Definition: CanRxTxThreads.hpp:110
A thread that attends CAN writes.
Definition: CanRxTxThreads.hpp:142
RPC replier for remote SDO transfers.
Definition: SdoReplier.hpp:25
Message broker of a CAN bus with YARP port interfaces.
Definition: SingleBusBroker.hpp:40
void onRead(yarp::os::Bottle &b) override
Callback on incoming remote CAN commands.
Definition: SingleBusBroker.cpp:276
bool configure(const yarp::os::Searchable &config)
Configure this CAN bus.
Definition: SingleBusBroker.cpp:47
bool clearFilters()
Clear CAN acceptance filters.
Definition: SingleBusBroker.cpp:198
bool stopThreads()
Stop CAN read/write threads.
Definition: SingleBusBroker.cpp:242
CanReaderThread * getReader() const
Get handle of the CAN RX thread.
Definition: SingleBusBroker.hpp:64
std::string getName() const
Retrieve string identifier for this CAN bus.
Definition: SingleBusBroker.hpp:72
bool startThreads()
Start CAN read/write threads.
Definition: SingleBusBroker.cpp:217
bool registerDevice(yarp::dev::PolyDriver *driver)
Register CAN handles associated to the input device driver.
Definition: SingleBusBroker.cpp:87
bool createPorts(const std::string &prefix)
Open remote CAN interface ports.
Definition: SingleBusBroker.cpp:129
~SingleBusBroker() override
Destructor.
Definition: SingleBusBroker.cpp:27
SingleBusBroker(const std::string &name)
Constructor, passes string identifier of the CAN bus.
Definition: SingleBusBroker.cpp:16
CanWriterThread * getWriter() const
Get handle.
Definition: SingleBusBroker.hpp:68
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6