Go to the documentation of this file.
49 inline bool empty()
const {
return queue_.empty(); }
50 inline size_t size()
const {
return queue_.size(); }
66 std::queue<MessageBuffer>
queue_;
72 CanUsb::CanUsb(
lusb::UsbDevice *dev) : ready_(false), heap_dev_(false), dev_(dev), recv_callback_(NULL), version_major_(0), version_minor_(0), version_build_(0), version_comms_(0), serial_number_(0), num_channels_(0)
123 std::vector<lusb::UsbDevice::Location> list;
125 for (
size_t i = 0; i < list.size(); i++) {
165 int len =
readConfig(&packet,
sizeof(packet));
184 int len =
readConfig(&packet,
sizeof(packet));
197 while (size >= (
int)
sizeof(*ptr)) {
198 size -=
sizeof(*ptr);
199 recv_callback_(ptr->channel, ptr->id, ptr->extended, ptr->dlc, ptr->data);
233 packet.
bus_cfg.channel = channel;
234 packet.
bus_cfg.bitrate = bitrate;
249 packet.
filter.channel = channel;
250 packet.
filter.mask = mask;
251 packet.
filter.match = match;
255 if (packet.
filter.success) {
264 std::vector<uint8_t> &rx_errors, std::vector<uint8_t> &tx_errors,
bool)
273 rx_drops.resize(size);
274 tx_drops.resize(size);
275 rx_errors.resize(size);
276 tx_errors.resize(size);
277 for (
unsigned int i = 0; i < size; i++) {
278 rx_drops[i] = packet.
stats.rx_drops[i];
279 tx_drops[i] = packet.
stats.tx_drops[i];
280 rx_errors[i] = packet.
stats.rx_errors[i];
281 tx_errors[i] = packet.
stats.tx_errors[i];
294 int len =
readConfig(&packet,
sizeof(packet));
296 timestamp = packet.
time.stamp;
303 void CanUsb::sendMessage(
unsigned int channel, uint32_t
id,
bool extended, uint8_t dlc,
const uint8_t data[8],
bool flush)
306 msg.headerWord[0] = 0;
307 msg.headerWord[1] = 0;
309 msg.extended = extended ? 1 : 0;
310 msg.channel = channel;
312 memcpy(msg.data, data, 8);
bool bulkWrite(const void *data, int size, unsigned char endpoint, int timeout)
bool setBitrate(unsigned int channel, uint32_t bitrate, uint8_t mode=0)
struct PACK_ATTRIB::PACK_ATTRIB bus_cfg
bool match(const MacAddr &other) const
int readConfig(void *data, int size)
struct PACK_ATTRIB::PACK_ATTRIB filter
struct PACK_ATTRIB::PACK_ATTRIB version
bool open(const Location &location=Location())
void stopBulkReadThread(unsigned char endpoint)
void listDevices(std::vector< Location > &list) const
#define CONFIGURATION_ENDPOINT
void sendMessage(unsigned int channel, uint32_t id, bool extended, uint8_t dlc, const uint8_t data[8], bool flush=true)
bool writeConfig(const void *data, int size)
void recvStream(const void *data, int size)
unsigned int num_channels_
bool push(const MessageBuffer &__x)
bool getTimeStamp(uint32_t ×tamp)
bool open(const std::string &mac=std::string())
static const int USB_DEFAULT_TIMEOUT
std::string version() const
bool getStats(std::vector< uint32_t > &rx_drops, std::vector< uint32_t > &tx_drops, std::vector< uint8_t > &rx_errors, std::vector< uint8_t > &tx_errors, bool clear=false)
struct PACK_ATTRIB::PACK_ATTRIB time
struct PACK_ATTRIB::PACK_ATTRIB num_channels
void startBulkReadThread(Callback callback, unsigned char endpoint)
int readStream(void *data, int size)
CanUsb(lusb::UsbDevice *dev=NULL)
std::queue< MessageBuffer > queue_
static const unsigned int MAX_CHANNELS
struct PACK_ATTRIB::PACK_ATTRIB stats
bool writeStream(const void *data, int size)
int bulkRead(void *data, int size, unsigned char endpoint, int timeout)
bool addFilter(unsigned int channel, uint32_t mask, uint32_t match)
bool configure(const std::string &mac=std::string())
dataspeed_can_usb
Author(s): Kevin Hallenbeck
autogenerated on Sat Feb 4 2023 03:39:26