32 yarp::dev::CanBuffer createBuffer(
int elem)
override
34 yarp::dev::CanBuffer ret;
35 struct pcanfd_msg * storage =
new pcanfd_msg[elem];
36 yarp::dev::CanMessage ** messages =
new yarp::dev::CanMessage *[elem];
39 std::memset(storage, 0,
sizeof(
struct pcanfd_msg) * elem);
41 for (
int k = 0; k < elem; k++)
43 messages[k] = &tmp[k];
44 messages[k]->setBuffer(
reinterpret_cast<unsigned char *
>(&storage[k]));
47 storage[k].type = PCANFD_TYPE_CAN20_MSG;
48 storage[k].flags = PCANFD_MSG_STD;
51 ret.resize(messages, elem);
61 public yarp::dev::ICanBus,
62 public yarp::dev::ICanBusErrors,
70 bool open(yarp::os::Searchable& config)
override;
71 bool close()
override;
75 bool canSetBaudRate(
unsigned int rate)
override;
76 bool canGetBaudRate(
unsigned int * rate)
override;
77 bool canIdAdd(
unsigned int id)
override;
78 bool canIdDelete(
unsigned int id)
override;
79 bool canRead(yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * read,
bool wait =
false)
override;
80 bool canWrite(
const yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * sent,
bool wait =
false)
override;
84 bool canGetErrors(yarp::dev::CanErrors & err)
override;
88 enum io_operation { READ, WRITE };
90 bool waitUntilTimeout(io_operation op,
bool * bufferReady);
92 std::uint64_t computeAcceptanceCodeAndMask();
94 int fileDescriptor {0};
96 mutable std::mutex canBusReady;
98 std::set<unsigned int> activeFilters;