yarp-devices
DumpCanBus.hpp
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 #ifndef __DUMP_CAN_BUS_HPP__
4 #define __DUMP_CAN_BUS_HPP__
5 
6 #include <yarp/os/Bottle.h>
7 #include <yarp/os/Port.h>
8 #include <yarp/os/PortReaderBuffer.h>
9 #include <yarp/os/Stamp.h>
10 #include <yarp/os/RFModule.h>
11 #include <yarp/os/TypedReaderCallback.h>
12 
13 namespace roboticslab
14 {
15 
20 class DumpCanBus : public yarp::os::RFModule,
21  public yarp::os::TypedReaderCallback<yarp::os::Bottle>
22 {
23 public:
24  ~DumpCanBus() override
25  { close(); }
26 
27  bool configure(yarp::os::ResourceFinder & rf) override;
28 
29  bool updateModule() override
30  { return true; }
31 
32  bool close() override;
33 
34  void onRead(yarp::os::Bottle & b) override;
35 
36 private:
37  void printMessage(const yarp::os::Bottle & b, const yarp::os::Stamp & stamp);
38 
39  yarp::os::Port port;
40  yarp::os::PortReaderBuffer<yarp::os::Bottle> portReader;
41  bool useCanOpen;
42  bool printTimestamp;
43 };
44 
45 } // namespace roboticslab
46 
47 #endif // __DUMP_CAN_BUS_HPP__
Connects to a remote CAN publisher port and dumps output.
Definition: DumpCanBus.hpp:22
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6