17 std::vector<hid_device_info> rv;
19 for (
auto&&
info : usb_devices) {
28 for(
auto&& hs : hid_sensors)
32 rv.push_back(device_info);
47 return std::make_shared<rs_hid_device>(
dev);
54 : _usb_device(usb_device),
55 _action_dispatcher(10)
67 _hidapi_device =
hid_open(devices[0].vendor_id, devices[0].product_id, devices[0].serial_number);
86 std::vector<hid_sensor> sensors;
89 sensors.push_back({
sensor.sensor_name });
96 for(
auto&&
p : hid_profiles)
162 memcpy(&report,
r->get_buffer().data(),
r->get_actual_length());
167 LOG_ERROR(
"failed to submit UVC request");
173 for(
auto&&
r : _requests)
182 for(
auto&&
r : _requests)
209 if(
_queue.dequeue(&report, 10))
256 sizeof(featureReport),
262 LOG_WARNING(
"control_transfer of USB_REQUEST_CODE_GET failed return value is: " <<
res);
266 featureReport.
power = power;
276 sizeof(featureReport),
282 LOG_WARNING(
"control_transfer of USB_REQUEST_CODE_SET failed return value is: " <<
res);
291 sizeof(featureReport),
297 LOG_WARNING(
"control_transfer of USB_REQUEST_CODE_GET failed return value is: " <<
res);
301 if(featureReport.
power != power)
310 int rs_hid_device::hidapi_PowerDevice(
unsigned char reportId)
312 if (_hidapi_device ==
NULL)
318 memset(&featureReport,0,
sizeof(featureReport));
322 &featureReport ,
sizeof(featureReport) );
325 LOG_ERROR(
"fail to read feature report from device");
337 LOG_ERROR(
"fail to write feature report from device");
344 LOG_ERROR(
"fail to read feature report from device");
363 auto it = std::find_if(intfs.begin(), intfs.end(),
366 if (
it == intfs.end())
367 throw std::runtime_error(
"can't find HID interface of device: " +
_usb_device->get_info().id);
378 throw std::runtime_error(
"can't find HID endpoint of device: " +
_usb_device->get_info().id);
const int USB_REQUEST_COUNT
def info(name, value, persistent=False)
std::string hexify(const T &val)
#define REPORT_ID_GYROMETER_3D
static std::string custom
int HID_API_EXPORT hid_read(hidapi_device *dev, unsigned char *data, size_t length)
Read an Input report from a HID device.
LOG_INFO("Log message using LOG_INFO()")
void invoke(T item, bool is_blocking=false)
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
struct hidapi_device_info HID_API_EXPORT * hid_enumerate(unsigned short vendor_id, unsigned short product_id)
Enumerate the HID Devices.
#define HID_REPORT_TYPE_FEATURE
int HID_API_EXPORT hid_get_feature_report(hidapi_device *dev, unsigned char *data, size_t length)
Get a feature report from a HID device.
#define REPORT_ID_ACCELEROMETER_3D
int HID_API_EXPORT hid_send_feature_report(hidapi_device *dev, const unsigned char *data, size_t length)
Send a Feature report to the device.
void invoke_and_wait(T item, std::function< bool()> exit_condition, bool is_blocking=false)