rsusb-backend.cpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #include "rsusb-backend.h"
5 
6 #include "../uvc/uvc-device.h"
7 #include "../types.h"
8 #include "../hid/hid-types.h"
9 #include "../hid/hid-device.h"
10 #include "../usb/usb-enumerator.h"
11 
12 #include "../tm2/tm-boot.h"
13 
14 #include <chrono>
15 #include <cctype> // std::tolower
16 
17 
18 namespace librealsense
19 {
20  namespace platform
21  {
23  {
24 
25  }
26 
28  {
29 
30  }
31 
32  std::shared_ptr<uvc_device> rs_backend::create_uvc_device(uvc_device_info info) const
33  {
34  LOG_DEBUG("Creating UVC Device from path: " << info.device_path.c_str());
35  auto dev = create_rsuvc_device(info);
36  if (!dev)
37  return nullptr;
38  return std::make_shared<retry_controls_work_around>(dev);
39  }
40 
41  std::vector<uvc_device_info> rs_backend::query_uvc_devices() const {
42  return query_uvc_devices_info();
43  }
44 
45  std::shared_ptr<command_transfer> rs_backend::create_usb_device(usb_device_info info) const
46  {
48  if(dev != nullptr)
49  return std::make_shared<command_transfer_usb>(dev);
50  return nullptr;
51  }
52 
53  std::vector<usb_device_info> rs_backend::query_usb_devices() const
54  {
55  auto device_infos = usb_enumerator::query_devices_info();
56  // Give the device a chance to restart, if we don't catch
57  // it, the watcher will find it later.
58  if(tm_boot(device_infos)) {
59  std::this_thread::sleep_for(std::chrono::milliseconds(2000));
60  device_infos = usb_enumerator::query_devices_info();
61  }
62  return device_infos;
63  }
64 
65  std::shared_ptr<hid_device> rs_backend::create_hid_device(hid_device_info info) const
66  {
67  return create_rshid_device(info);
68  }
69 
70  std::vector<hid_device_info> rs_backend::query_hid_devices() const
71  {
72  return query_hid_devices_info();
73  }
74 
75  std::shared_ptr<time_service> rs_backend::create_time_service() const
76  {
77  return std::make_shared<os_time_service>();
78  }
79  }
80 }
std::shared_ptr< hid_device > create_hid_device(hid_device_info info) const override
static rs_usb_device create_usb_device(const usb_device_info &info)
std::shared_ptr< uvc_device > create_rsuvc_device(uvc_device_info info)
Definition: uvc-device.cpp:62
std::vector< uvc_device_info > query_uvc_devices_info()
Definition: uvc-device.cpp:40
static std::vector< usb_device_info > query_devices_info()
std::vector< uvc_device_info > query_uvc_devices() const override
std::shared_ptr< command_transfer > create_usb_device(usb_device_info info) const override
std::shared_ptr< uvc_device > create_uvc_device(uvc_device_info info) const override
std::shared_ptr< hid_device > create_rshid_device(hid_device_info info)
Definition: hid-device.cpp:38
bool tm_boot(const std::vector< usb_device_info > &devices)
Definition: tm-boot.h:48
def info(name, value, persistent=False)
Definition: test.py:301
virtual std::shared_ptr< time_service > create_time_service() const override
std::vector< usb_device_info > query_usb_devices() const override
std::vector< hid_device_info > query_hid_devices_info()
Definition: hid-device.cpp:13
std::vector< hid_device_info > query_hid_devices() const override
#define LOG_DEBUG(...)
Definition: src/types.h:239


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41