3 #ifndef __CAN_BUS_PEAK_HPP__
4 #define __CAN_BUS_PEAK_HPP__
11 #include <yarp/dev/DeviceDriver.h>
12 #include <yarp/dev/CanBusInterface.h>
14 #include <libpcanfd.h>
16 #include "PeakCanMessage.hpp"
34 yarp::dev::CanBuffer createBuffer(
int elem)
override
36 yarp::dev::CanBuffer ret;
37 struct pcanfd_msg * storage =
new pcanfd_msg[elem];
38 yarp::dev::CanMessage ** messages =
new yarp::dev::CanMessage *[elem];
41 std::memset(storage, 0,
sizeof(
struct pcanfd_msg) * elem);
43 for (
int k = 0; k < elem; k++)
45 messages[k] = &tmp[k];
46 messages[k]->setBuffer(
reinterpret_cast<unsigned char *
>(&storage[k]));
49 storage[k].type = PCANFD_TYPE_CAN20_MSG;
50 storage[k].flags = PCANFD_MSG_STD;
53 ret.resize(messages, elem);
63 public yarp::dev::ICanBus,
64 public yarp::dev::ICanBusErrors,
74 bool open(yarp::os::Searchable& config)
override;
76 bool close()
override;
80 bool canSetBaudRate(
unsigned int rate)
override;
82 bool canGetBaudRate(
unsigned int * rate)
override;
84 bool canIdAdd(
unsigned int id)
override;
86 bool canIdDelete(
unsigned int id)
override;
88 bool canRead(yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * read,
bool wait =
false)
override;
90 bool canWrite(
const yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * sent,
bool wait =
false)
override;
94 bool canGetErrors(yarp::dev::CanErrors & err)
override;
98 enum io_operation { READ, WRITE };
100 bool waitUntilTimeout(io_operation op,
bool * bufferReady);
102 std::uint64_t computeAcceptanceCodeAndMask();
104 int fileDescriptor {0};
109 bool allowPermissive;
111 mutable std::mutex canBusReady;
113 std::set<unsigned int> activeFilters;
Specifies the PeakCan behaviour and specifications.
Definition: CanBusPeak.hpp:66
Custom buffer of PeakCanMessage instances.
Definition: CanBusPeak.hpp:32
YARP wrapper for PeakCAN messages.
Definition: PeakCanMessage.hpp:21
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6