32 public yarp::dev::ICanBus,
33 public yarp::dev::ICanBusErrors,
34 public yarp::dev::ImplementCanBufferFactory<roboticslab::HicoCanMessage, struct can_msg>,
41 bool open(yarp::os::Searchable& config)
override;
42 bool close()
override;
46 bool canSetBaudRate(
unsigned int rate)
override;
47 bool canGetBaudRate(
unsigned int * rate)
override;
48 bool canIdAdd(
unsigned int id)
override;
49 bool canIdDelete(
unsigned int id)
override;
50 bool canRead(yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * read,
bool wait =
false)
override;
51 bool canWrite(
const yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * sent,
bool wait =
false)
override;
55 bool canGetErrors(yarp::dev::CanErrors & err)
override;
62 enum filter_config { DISABLED, NO_RANGE, MASK_AND_RANGE };
66 bool parseIds(
const std::vector<int> & ids);
67 bool hasId(
unsigned int id)
const;
69 bool insertId(
unsigned int id);
70 bool eraseId(
unsigned int id);
71 bool clearFilters(
bool clearStage =
true);
73 static constexpr int MAX_FILTERS = 4;
76 bool setMaskedFilter(
unsigned int id);
77 bool setRangedFilter(
unsigned int lower,
unsigned int upper);
83 bool enableRanges {
false};
84 std::set<unsigned int> stage, currentlyActive;
87 FilterManager::filter_config parseFilterConfiguration(
const std::string & str);
89 enum io_operation { READ, WRITE };
91 bool waitUntilTimeout(io_operation op,
bool * bufferReady);
92 bool bitrateToId(
unsigned int bitrate,
unsigned int *
id);
93 bool idToBitrate(
unsigned int id,
unsigned int * bitrate);
95 int fileDescriptor {0};
97 mutable std::mutex canBusReady;
99 std::pair<bool, unsigned int> bitrateState;
101 FilterManager * filterManager {
nullptr};
103 FilterManager::filter_config filterConfig;