1 #include "CrazyflieUSB.h" 6 #include <libusb-1.0/libusb.h> 28 return std::string(
"TODO");
45 throw std::runtime_error(
"No valid device handle!");
53 status = libusb_bulk_transfer(
55 (0x01 | LIBUSB_ENDPOINT_OUT),
60 if (status != LIBUSB_SUCCESS) {
61 throw std::runtime_error(libusb_error_name(status));
63 if (length != (uint32_t)transferred) {
64 std::stringstream sstr;
65 sstr <<
"Did transfer " << transferred <<
" but " << length <<
" was requested!";
66 throw std::runtime_error(sstr.str());
72 status = libusb_bulk_transfer(
74 (0x81 | LIBUSB_ENDPOINT_IN),
75 (
unsigned char*)&result.data[0],
79 if (status != LIBUSB_SUCCESS) {
80 throw std::runtime_error(libusb_error_name(status));
84 result.size = transferred;
99 throw std::runtime_error(
"No valid device handle!");
107 status = libusb_bulk_transfer(
109 (0x01 | LIBUSB_ENDPOINT_OUT),
114 if (status != LIBUSB_SUCCESS) {
115 throw std::runtime_error(libusb_error_name(status));
117 if (length != (uint32_t)transferred) {
118 std::stringstream sstr;
119 sstr <<
"Did transfer " << transferred <<
" but " << length <<
" was requested!";
120 throw std::runtime_error(sstr.str());
CrazyflieUSB(uint32_t devid)
static uint32_t numDevices(uint16_t idVendor, uint16_t idProduct)
void sendVendorSetup(uint8_t request, uint16_t value, uint16_t index, const unsigned char *data, uint16_t length)
virtual void sendPacketNoAck(const uint8_t *data, uint32_t length)
void logPacket(const uint8_t *data, uint32_t length)
void setCrtpToUsb(bool crtpToUsb)
void logAck(const Ack &ack)
static uint32_t numDevices()
virtual void sendPacket(const uint8_t *data, uint32_t length, ITransport::Ack &result)
libusb_device_handle * m_handle