3 #ifndef __CAN_BUS_HICO_HPP__
4 #define __CAN_BUS_HICO_HPP__
11 #include <yarp/os/Bottle.h>
13 #include <yarp/dev/DeviceDriver.h>
14 #include <yarp/dev/CanBusInterface.h>
17 #include "HicoCanMessage.hpp"
33 public yarp::dev::ICanBus,
34 public yarp::dev::ICanBusErrors,
35 public yarp::dev::ImplementCanBufferFactory<HicoCanMessage, struct can_msg>
44 bool open(yarp::os::Searchable& config)
override;
46 bool close()
override;
50 bool canSetBaudRate(
unsigned int rate)
override;
52 bool canGetBaudRate(
unsigned int * rate)
override;
54 bool canIdAdd(
unsigned int id)
override;
56 bool canIdDelete(
unsigned int id)
override;
58 bool canRead(yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * read,
bool wait =
false)
override;
60 bool canWrite(
const yarp::dev::CanBuffer & msgs,
unsigned int size,
unsigned int * sent,
bool wait =
false)
override;
64 bool canGetErrors(yarp::dev::CanErrors & err)
override;
71 enum filter_config { DISABLED, NO_RANGE, MASK_AND_RANGE };
75 bool parseIds(
const yarp::os::Bottle & b);
76 bool hasId(
unsigned int id)
const;
78 bool insertId(
unsigned int id);
79 bool eraseId(
unsigned int id);
80 bool clearFilters(
bool clearStage =
true);
82 static const int MAX_FILTERS;
85 bool setMaskedFilter(
unsigned int id);
86 bool setRangedFilter(
unsigned int lower,
unsigned int upper);
93 std::set<unsigned int> stage, currentlyActive;
96 FilterManager::filter_config parseFilterConfiguration(
const std::string & str);
98 enum io_operation { READ, WRITE };
100 bool waitUntilTimeout(io_operation op,
bool * bufferReady);
101 bool bitrateToId(
unsigned int bitrate,
unsigned int *
id);
102 bool idToBitrate(
unsigned int id,
unsigned int * bitrate);
106 int rxTimeoutMs {0}, txTimeoutMs {0};
109 bool allowPermissive;
111 mutable std::mutex canBusReady;
113 std::pair<bool, unsigned int> bitrateState;
115 FilterManager * filterManager {
nullptr};
117 FilterManager::filter_config filterConfig;
Definition: CanBusHico.hpp:69
Specifies the HicoCan (hcanpci) behaviour and specifications.
Definition: CanBusHico.hpp:36
int fileDescriptor
Definition: CanBusHico.hpp:105
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6