XLinkConnection.cpp
Go to the documentation of this file.
2 
3 #include <array>
4 #include <cassert>
5 #include <chrono>
6 #include <cstring>
7 #include <fstream>
8 #include <iostream>
9 #include <thread>
10 #include <vector>
11 
12 // project
14 #include "utility/Environment.hpp"
15 #include "utility/spdlog-fmt.hpp"
16 
17 // libraries
18 #include <XLink/XLink.h>
19 extern "C" {
20 #include <XLink/XLinkLog.h>
21 }
22 
23 #include "spdlog/details/os.h"
24 #include "spdlog/fmt/chrono.h"
25 #include "spdlog/spdlog.h"
26 #include "utility/Logging.hpp"
27 
28 namespace dai {
29 
30 DeviceInfo::DeviceInfo(const deviceDesc_t& desc) {
31  name = std::string(desc.name);
32  mxid = std::string(desc.mxid);
33  state = desc.state;
34  protocol = desc.protocol;
35  platform = desc.platform;
36  status = desc.status;
37 }
38 
39 DeviceInfo::DeviceInfo(std::string name, std::string mxid, XLinkDeviceState_t state, XLinkProtocol_t protocol, XLinkPlatform_t platform, XLinkError_t status)
40  : name(std::move(name)), mxid(std::move(mxid)), state(state), protocol(protocol), platform(platform), status(status) {}
41 
42 DeviceInfo::DeviceInfo(std::string mxidOrName) {
43  // Parse parameter and set to ip if any dots found
44  // mxid doesn't have a dot in the name
45  if(mxidOrName.find(".") != std::string::npos) {
46  // This is reasoned as an IP address or USB path (name). Set rest of info accordingly
47  name = std::move(mxidOrName);
48  mxid = "";
49  } else {
50  // This is reasoned as mxid
51  name = "";
52  mxid = std::move(mxidOrName);
53  }
54 }
55 
56 deviceDesc_t DeviceInfo::getXLinkDeviceDesc() const {
57  // Create XLink deviceDesc_t, init all fields to zero
58  deviceDesc_t desc = {};
59 
60  // c_str is guranteed to be nullterminated
61  desc.mxid[sizeof(desc.mxid) - 1] = 0;
62  strncpy(desc.mxid, mxid.c_str(), sizeof(desc.mxid) - 1);
63  desc.name[sizeof(desc.name) - 1] = 0;
64  strncpy(desc.name, name.c_str(), sizeof(desc.name) - 1);
65 
66  desc.platform = platform;
67  desc.protocol = protocol;
68  desc.state = state;
69  desc.status = status;
70 
71  return desc;
72 }
73 
74 // backward compatibility
75 std::string DeviceInfo::getMxId() const {
76  return mxid;
77 }
78 
79 std::string DeviceInfo::toString() const {
80  return fmt::format("DeviceInfo(name={}, mxid={}, {}, {}, {}, {})",
81  name,
82  mxid,
83  XLinkDeviceStateToStr(state),
84  XLinkProtocolToStr(protocol),
85  XLinkPlatformToStr(platform),
86  XLinkErrorToStr(status));
87 }
88 
89 static XLinkProtocol_t getDefaultProtocol() {
90  XLinkProtocol_t defaultProtocol = X_LINK_ANY_PROTOCOL;
91 
92  auto protocolStr = utility::getEnv("DEPTHAI_PROTOCOL");
93 
94  std::transform(protocolStr.begin(), protocolStr.end(), protocolStr.begin(), ::tolower);
95  if(protocolStr.empty() || protocolStr == "any") {
96  defaultProtocol = X_LINK_ANY_PROTOCOL;
97  } else if(protocolStr == "usb") {
98  defaultProtocol = X_LINK_USB_VSC;
99  } else if(protocolStr == "tcpip") {
100  defaultProtocol = X_LINK_TCP_IP;
101  } else {
102  logger::warn("Unsupported protocol specified");
103  }
104 
105  return defaultProtocol;
106 }
107 
108 // STATIC
109 constexpr std::chrono::milliseconds XLinkConnection::WAIT_FOR_BOOTUP_TIMEOUT;
110 constexpr std::chrono::milliseconds XLinkConnection::WAIT_FOR_CONNECT_TIMEOUT;
111 constexpr std::chrono::milliseconds XLinkConnection::POLLING_DELAY_TIME;
112 
113 std::vector<DeviceInfo> XLinkConnection::getAllConnectedDevices(XLinkDeviceState_t state, bool skipInvalidDevices, XLinkPlatform_t platform) {
114  initialize();
115 
116  std::vector<DeviceInfo> devices;
117 
118  unsigned int numdev = 0;
119  std::array<deviceDesc_t, 64> deviceDescAll = {};
120  deviceDesc_t suitableDevice = {};
121  suitableDevice.protocol = getDefaultProtocol();
122  suitableDevice.platform = platform;
123  suitableDevice.state = state;
124 
125  auto allowedDeviceMxIds = utility::getEnv("DEPTHAI_DEVICE_MXID_LIST");
126  auto allowedDeviceIds = utility::getEnv("DEPTHAI_DEVICE_ID_LIST");
127  auto allowedDeviceNames = utility::getEnv("DEPTHAI_DEVICE_NAME_LIST");
128 
129  auto status = XLinkFindAllSuitableDevices(suitableDevice, deviceDescAll.data(), static_cast<unsigned int>(deviceDescAll.size()), &numdev);
130  if(status != X_LINK_SUCCESS && status != X_LINK_DEVICE_NOT_FOUND) throw std::runtime_error("Couldn't retrieve all connected devices");
131 
132  for(unsigned i = 0; i < numdev; i++) {
133  DeviceInfo info(deviceDescAll.at(i));
134 
135  if(skipInvalidDevices) {
136  if(info.status == X_LINK_SUCCESS) {
137  // device is okay
138  } else if(info.status == X_LINK_INSUFFICIENT_PERMISSIONS) {
139  logger::warn("Insufficient permissions to communicate with {} device having name \"{}\". Make sure udev rules are set",
140  XLinkDeviceStateToStr(info.state),
141  info.name);
142  continue;
143  } else {
144  logger::warn("skipping {} device having name \"{}\"", XLinkDeviceStateToStr(info.state), info.name);
145  continue;
146  }
147  }
148 
149  bool allowedMxId = allowedDeviceMxIds.find(info.getMxId()) != std::string::npos || allowedDeviceMxIds.empty();
150  bool allowedId = allowedDeviceIds.find(info.getMxId()) != std::string::npos || allowedDeviceIds.empty();
151  bool allowedName = allowedDeviceNames.find(info.name) != std::string::npos || allowedDeviceNames.empty();
152  if(allowedMxId && allowedId && allowedName) {
153  devices.push_back(info);
154  }
155  }
156 
157  return devices;
158 }
159 
160 std::tuple<bool, DeviceInfo> XLinkConnection::getFirstDevice(XLinkDeviceState_t state, bool skipInvalidDevice) {
161  initialize();
162 
163  DeviceInfo devReq = {};
164  devReq.protocol = X_LINK_ANY_PROTOCOL;
165  devReq.platform = X_LINK_MYRIAD_X;
166  devReq.name = "";
167  devReq.mxid = "";
168  devReq.state = state;
169 
170  deviceDesc_t desc = {};
171  auto res = XLinkFindFirstSuitableDevice(devReq.getXLinkDeviceDesc(), &desc);
172  if(res == X_LINK_SUCCESS) {
173  if(skipInvalidDevice) {
174  if(desc.status == X_LINK_SUCCESS) {
175  // device is okay
176  } else if(desc.status == X_LINK_INSUFFICIENT_PERMISSIONS) {
177  logger::warn("Insufficient permissions to communicate with {} device having name \"{}\". Make sure udev rules are set",
178  XLinkDeviceStateToStr(desc.state),
179  desc.name);
180  return {false, {}};
181  } else {
182  logger::warn("skipping {} device having name \"{}\"", XLinkDeviceStateToStr(desc.state), desc.name);
183  return {false, {}};
184  }
185  }
186  DeviceInfo info(desc);
187  return {true, info};
188  }
189  return {false, {}};
190 }
191 
192 std::tuple<bool, DeviceInfo> XLinkConnection::getDeviceByMxId(std::string mxId, XLinkDeviceState_t state, bool skipInvalidDevices) {
193  initialize();
194 
195  DeviceInfo dev;
196  dev.mxid = mxId;
197  dev.state = state;
198  dev.platform = X_LINK_MYRIAD_X;
199 
200  deviceDesc_t desc = {};
201  auto res = XLinkFindFirstSuitableDevice(dev.getXLinkDeviceDesc(), &desc);
202  if(res == X_LINK_SUCCESS) {
203  if(skipInvalidDevices) {
204  if(desc.status == X_LINK_SUCCESS) {
205  // device is okay
206  } else if(desc.status == X_LINK_INSUFFICIENT_PERMISSIONS) {
207  logger::warn("Insufficient permissions to communicate with {} device having name \"{}\". Make sure udev rules are set",
208  XLinkDeviceStateToStr(desc.state),
209  desc.name);
210  return {false, {}};
211  } else {
212  logger::warn("skipping {} device having name \"{}\"", XLinkDeviceStateToStr(desc.state), desc.name);
213  return {false, {}};
214  }
215  }
216  return {true, DeviceInfo{desc}};
217  }
218  return {false, {}};
219 }
220 
222  initialize();
223 
224  using namespace std::chrono;
225 
226  // Device is in flash booted state. Boot to bootloader first
227  auto deviceDesc = deviceInfo.getXLinkDeviceDesc();
228 
229  // Device is in flash booted state. Boot to bootloader first
230  XLinkError_t bootBootloaderError = XLinkBootBootloader(&deviceDesc);
231  if(bootBootloaderError != X_LINK_SUCCESS) {
232  throw std::runtime_error(fmt::format("Couldn't boot device to bootloader - {}", XLinkErrorToStr(bootBootloaderError)));
233  }
234 
235  // Wait for a bootloader device now
236  DeviceInfo deviceToWait = deviceInfo;
237  deviceToWait.state = X_LINK_BOOTLOADER;
238 
239  // Prepare descriptor to search for
240  auto descToWait = deviceToWait.getXLinkDeviceDesc();
241  // Use "name" as hint only, but might still change
242  descToWait.nameHintOnly = true;
243 
244  // Device desc if found
245  deviceDesc_t foundDeviceDesc = {};
246 
247  // Wait for device to get to bootloader state
248  XLinkError_t rc;
249  auto bootupTimeout = WAIT_FOR_BOOTUP_TIMEOUT;
250 
251  // Override with environment variables, if set
252  const std::vector<std::pair<std::string, std::chrono::milliseconds*>> evars = {
253  {"DEPTHAI_BOOTUP_TIMEOUT", &bootupTimeout},
254  };
255 
256  for(auto ev : evars) {
257  auto name = ev.first;
258  auto valstr = utility::getEnv(name);
259  if(!valstr.empty()) {
260  try {
261  std::chrono::milliseconds value{std::stoi(valstr)};
262  *ev.second = value;
263  // auto initial = *ev.second;
264  // logger::warn("{} override: {} -> {}", name, initial, value);
265  } catch(const std::invalid_argument& e) {
266  logger::warn("{} value invalid: {}", name, e.what());
267  }
268  }
269  }
270 
271  auto tstart = steady_clock::now();
272  do {
273  rc = XLinkFindFirstSuitableDevice(descToWait, &foundDeviceDesc);
274  if(rc == X_LINK_SUCCESS) break;
275  std::this_thread::sleep_for(POLLING_DELAY_TIME);
276  } while(steady_clock::now() - tstart < bootupTimeout);
277 
278  // If device not found
279  if(rc != X_LINK_SUCCESS) {
280  throw std::runtime_error(fmt::format("Failed to find device ({}), error message: {}", deviceToWait.toString(), convertErrorCodeToString(rc)));
281  }
282 
283  return DeviceInfo(foundDeviceDesc);
284 }
285 
286 XLinkConnection::XLinkConnection(const DeviceInfo& deviceDesc, std::vector<std::uint8_t> mvcmdBinary, XLinkDeviceState_t expectedState)
287  : bootWithPath(false), mvcmd(std::move(mvcmdBinary)) {
288  initialize();
289  initDevice(deviceDesc, expectedState);
290 }
291 
292 XLinkConnection::XLinkConnection(const DeviceInfo& deviceDesc, dai::Path mvcmdPath, XLinkDeviceState_t expectedState) : pathToMvcmd(std::move(mvcmdPath)) {
293  initialize();
294  if(!pathToMvcmd.empty()) {
295  std::ifstream testStream(pathToMvcmd);
296  if(!testStream.good()) throw std::runtime_error("Error path doesn't exist. Note: Environment variables in path are not expanded. (E.g. '~', '$PATH').");
297  }
298  initDevice(deviceDesc, expectedState);
299 }
300 
301 // Skip boot
302 XLinkConnection::XLinkConnection(const DeviceInfo& deviceDesc, XLinkDeviceState_t expectedState) : bootDevice(false) {
303  initialize();
304  initDevice(deviceDesc, expectedState);
305 }
306 
307 // This function is thread-unsafe. The `closed` value is only known and valid
308 // within the context of the lock_guard. The value is immediately invalid and outdated
309 // when it is returned by value to the caller
311  std::lock_guard<std::mutex> lock(closedMtx);
312  return closed;
313 }
314 
316  std::lock_guard<std::mutex> lock(closedMtx);
317  if(closed) return;
318 
319  using namespace std::chrono;
320  constexpr auto RESET_TIMEOUT = seconds(2);
321  constexpr auto BOOTUP_SEARCH = seconds(5);
322 
323  if(deviceLinkId != -1 && rebootOnDestruction) {
324  auto previousLinkId = deviceLinkId;
325 
326  auto ret = XLinkResetRemoteTimeout(deviceLinkId, duration_cast<milliseconds>(RESET_TIMEOUT).count());
327  if(ret != X_LINK_SUCCESS) {
328  logger::debug("XLinkResetRemoteTimeout returned: {}", XLinkErrorToStr(ret));
329  }
330 
331  deviceLinkId = -1;
332 
333  // TODO(themarpe) - revisit for TCPIP protocol
334 
335  // Wait till same device reappears (is rebooted).
336  // Only in case if device was booted to begin with
337  if(bootDevice) {
338  auto t1 = steady_clock::now();
339  bool found = false;
340  do {
341  DeviceInfo rebootingDeviceInfo;
342  std::tie(found, rebootingDeviceInfo) = XLinkConnection::getDeviceByMxId(deviceInfo.getMxId(), X_LINK_ANY_STATE, false);
343  if(found) {
344  if(rebootingDeviceInfo.state == X_LINK_UNBOOTED || rebootingDeviceInfo.state == X_LINK_BOOTLOADER) {
345  break;
346  }
347  }
348  } while(!found && steady_clock::now() - t1 < BOOTUP_SEARCH);
349  }
350 
351  logger::debug("XLinkResetRemote of linkId: ({})", previousLinkId);
352  }
353 
354  closed = true;
355 }
356 
358  close();
359 }
360 
362  rebootOnDestruction = reboot;
363 }
364 
366  return rebootOnDestruction;
367 }
368 
369 bool XLinkConnection::bootAvailableDevice(const deviceDesc_t& deviceToBoot, const dai::Path& pathToMvcmd) {
370  std::ifstream fwStream(pathToMvcmd, std::ios::binary);
371  if(!fwStream.is_open()) throw std::runtime_error(fmt::format("Cannot boot firmware, binary at path: {} doesn't exist", pathToMvcmd));
372  std::vector<uint8_t> package = std::vector<std::uint8_t>(std::istreambuf_iterator<char>(fwStream), {});
373  return bootAvailableDevice(deviceToBoot, package);
374 }
375 
376 bool XLinkConnection::bootAvailableDevice(const deviceDesc_t& deviceToBoot, std::vector<std::uint8_t>& mvcmd) {
377  auto status = XLinkBootMemory(&deviceToBoot, mvcmd.data(), static_cast<unsigned long>(mvcmd.size()));
378  return status == X_LINK_SUCCESS;
379 }
380 
381 void XLinkConnection::initDevice(const DeviceInfo& deviceToInit, XLinkDeviceState_t expectedState) {
382  assert(deviceLinkId == -1);
383 
384  XLinkError_t rc = X_LINK_ERROR;
385 
386  using namespace std::chrono;
387 
388  // if device is in UNBOOTED then boot
389  bootDevice = deviceToInit.state == X_LINK_UNBOOTED;
390 
391  DeviceInfo lastDeviceInfo = deviceToInit;
392 
393  std::chrono::milliseconds connectTimeout = WAIT_FOR_CONNECT_TIMEOUT;
394  std::chrono::milliseconds bootupTimeout = WAIT_FOR_BOOTUP_TIMEOUT;
395 
396  // Override with environment variables, if set
397  const std::vector<std::pair<std::string, std::chrono::milliseconds*>> evars = {
398  {"DEPTHAI_CONNECT_TIMEOUT", &connectTimeout},
399  {"DEPTHAI_BOOTUP_TIMEOUT", &bootupTimeout},
400  };
401 
402  for(auto ev : evars) {
403  auto name = ev.first;
404  auto valstr = utility::getEnv(name);
405  if(!valstr.empty()) {
406  try {
407  std::chrono::milliseconds value{std::stoi(valstr)};
408  *ev.second = value;
409  // auto initial = *ev.second;
410  } catch(const std::invalid_argument& e) {
411  logger::warn("{} value invalid: {}", name, e.what());
412  }
413  }
414  }
415 
416  // boot device
417  if(bootDevice) {
418  DeviceInfo deviceToBoot = lastDeviceInfo;
419  deviceToBoot.state = X_LINK_UNBOOTED;
420 
421  deviceDesc_t foundDeviceDesc = {};
422 
423  // Wait for the device to be available
424  auto tstart = steady_clock::now();
425  do {
426  rc = XLinkFindFirstSuitableDevice(deviceToBoot.getXLinkDeviceDesc(), &foundDeviceDesc);
427  if(rc == X_LINK_SUCCESS) break;
428  std::this_thread::sleep_for(POLLING_DELAY_TIME);
429  } while(steady_clock::now() - tstart < bootupTimeout);
430 
431  // If device not found
432  if(rc != X_LINK_SUCCESS) {
433  throw std::runtime_error("Failed to find device (" + deviceToBoot.name + "), error message: " + convertErrorCodeToString(rc));
434  }
435 
436  lastDeviceInfo = DeviceInfo(foundDeviceDesc);
437 
438  bool bootStatus;
439  if(bootWithPath) {
440  bootStatus = bootAvailableDevice(foundDeviceDesc, pathToMvcmd);
441  } else {
442  bootStatus = bootAvailableDevice(foundDeviceDesc, mvcmd);
443  }
444  if(!bootStatus) {
445  throw std::runtime_error("Failed to boot device!");
446  }
447  }
448 
449  // Search for booted device
450  {
451  // Create description of device to look for
452  DeviceInfo bootedDeviceInfo = lastDeviceInfo;
453  // Has to match expected state
454  bootedDeviceInfo.state = expectedState;
455 
456  // Prepare descriptor to search for
457  auto bootedDescInfo = bootedDeviceInfo.getXLinkDeviceDesc();
458  // Use "name" as hint only, but might still change
459  bootedDescInfo.nameHintOnly = true;
460 
461  logger::debug("Searching for booted device: {}, name used as hint only", bootedDeviceInfo.toString());
462 
463  // Find booted device
464  deviceDesc_t foundDeviceDesc = {};
465  auto tstart = steady_clock::now();
466  do {
467  rc = XLinkFindFirstSuitableDevice(bootedDescInfo, &foundDeviceDesc);
468  if(rc == X_LINK_SUCCESS) break;
469  std::this_thread::sleep_for(POLLING_DELAY_TIME);
470  } while(steady_clock::now() - tstart < bootupTimeout);
471 
472  if(rc != X_LINK_SUCCESS) {
473  throw std::runtime_error("Failed to find device after booting, error message: " + convertErrorCodeToString(rc));
474  }
475 
476  lastDeviceInfo = DeviceInfo(foundDeviceDesc);
477  }
478 
479  // Try to connect to device
480  {
481  XLinkHandler_t connectionHandler = {};
482  auto desc = lastDeviceInfo.getXLinkDeviceDesc();
483  connectionHandler.devicePath = desc.name;
484  connectionHandler.protocol = lastDeviceInfo.protocol;
485 
486  auto tstart = steady_clock::now();
487  do {
488  if((rc = XLinkConnect(&connectionHandler)) == X_LINK_SUCCESS) break;
489  std::this_thread::sleep_for(POLLING_DELAY_TIME);
490  } while(steady_clock::now() - tstart < connectTimeout);
491 
492  if(rc != X_LINK_SUCCESS) throw std::runtime_error("Failed to connect to device, error message: " + convertErrorCodeToString(rc));
493 
494  deviceLinkId = connectionHandler.linkId;
495  deviceInfo = lastDeviceInfo;
496  deviceInfo.state = X_LINK_BOOTED;
497  }
498 }
499 
501  return deviceLinkId;
502 }
503 
504 std::string XLinkConnection::convertErrorCodeToString(XLinkError_t errorCode) {
505  return XLinkErrorToStr(errorCode);
506 }
507 
510  XLinkProf_t prof;
511  if(XLinkGetGlobalProfilingData(&prof) != X_LINK_SUCCESS) {
512  throw std::runtime_error("Couldn't retrieve profiling data");
513  }
514  data.numBytesRead = prof.totalReadBytes;
515  data.numBytesWritten = prof.totalWriteBytes;
516  return data;
517 }
518 
521  XLinkProf_t prof;
522  if(XLinkGetProfilingData(deviceLinkId, &prof) != X_LINK_SUCCESS) {
523  throw std::runtime_error("Couldn't retrieve profiling data");
524  }
525  data.numBytesRead = prof.totalReadBytes;
526  data.numBytesWritten = prof.totalWriteBytes;
527  return data;
528 }
529 
530 } // namespace dai
dai::XLinkConnection::initDevice
void initDevice(const DeviceInfo &deviceToInit, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
Definition: XLinkConnection.cpp:381
dai::XLinkConnection::getAllConnectedDevices
static std::vector< DeviceInfo > getAllConnectedDevices(XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevices=true, XLinkPlatform_t platform=X_LINK_MYRIAD_X)
Definition: XLinkConnection.cpp:113
dai::Path::empty
bool empty() const noexcept
Observes if path is empty (contains no string/folders/filename)
Definition: Path.hpp:194
dai::XLinkConnection::POLLING_DELAY_TIME
constexpr static std::chrono::milliseconds POLLING_DELAY_TIME
Definition: XLinkConnection.hpp:159
dai::XLinkConnection::pathToMvcmd
dai::Path pathToMvcmd
Definition: XLinkConnection.hpp:144
dai::DeviceInfo
Definition: XLinkConnection.hpp:27
dai::XLinkConnection::convertErrorCodeToString
static std::string convertErrorCodeToString(XLinkError_t errorCode)
Definition: XLinkConnection.cpp:504
dai::XLinkConnection::getFirstDevice
static std::tuple< bool, DeviceInfo > getFirstDevice(XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevices=true)
Definition: XLinkConnection.cpp:160
dai::XLinkConnection::bootBootloader
static DeviceInfo bootBootloader(const DeviceInfo &devInfo)
Definition: XLinkConnection.cpp:221
dai::DeviceInfo::toString
std::string toString() const
Definition: XLinkConnection.cpp:79
Environment.hpp
dai::logger::info
void info(const FormatString &fmt, Args &&...args)
Definition: Logging.hpp:78
nanorpc::version::core::protocol
std::integral_constant< std::uint32_t, 1 > protocol
Definition: core.h:22
dai::XLinkConnection::deviceInfo
DeviceInfo deviceInfo
Definition: XLinkConnection.hpp:151
dai::XLinkConnection::getRebootOnDestruction
bool getRebootOnDestruction() const
Definition: XLinkConnection.cpp:365
dai::logger::debug
void debug(const FormatString &fmt, Args &&...args)
Definition: Logging.hpp:72
dai::XLinkConnection::WAIT_FOR_BOOTUP_TIMEOUT
constexpr static std::chrono::milliseconds WAIT_FOR_BOOTUP_TIMEOUT
Definition: XLinkConnection.hpp:157
dai::DeviceInfo::state
XLinkDeviceState_t state
Definition: XLinkConnection.hpp:42
dai::logger::warn
void warn(const FormatString &fmt, Args &&...args)
Definition: Logging.hpp:84
dai::XLinkConnection::closed
bool closed
Definition: XLinkConnection.hpp:155
dai::XLinkConnection::closedMtx
std::mutex closedMtx
Definition: XLinkConnection.hpp:154
dai::XLinkConnection::~XLinkConnection
~XLinkConnection()
Definition: XLinkConnection.cpp:357
dai::XLinkConnection::getLinkId
int getLinkId() const
Definition: XLinkConnection.cpp:500
dai::ProfilingData
Definition: ProfilingData.hpp:5
DAI_SPAN_NAMESPACE_NAME::detail::data
constexpr auto data(C &c) -> decltype(c.data())
Definition: span.hpp:177
dai::utility::getEnv
std::string getEnv(const std::string &var)
Definition: Environment.cpp:18
dai::DeviceInfo::DeviceInfo
DeviceInfo()=default
Initialization.hpp
dai::initialize
bool initialize()
Definition: Initialization.cpp:53
dai::DeviceInfo::name
std::string name
Definition: XLinkConnection.hpp:40
dai::XLinkConnection::getGlobalProfilingData
static ProfilingData getGlobalProfilingData()
Definition: XLinkConnection.cpp:508
XLinkConnection.hpp
dai::XLinkConnection::bootAvailableDevice
static bool bootAvailableDevice(const deviceDesc_t &deviceToBoot, const dai::Path &pathToMvcmd)
Definition: XLinkConnection.cpp:369
dai::DeviceInfo::status
XLinkError_t status
Definition: XLinkConnection.hpp:45
dai::XLinkConnection::XLinkConnection
XLinkConnection(const DeviceInfo &deviceDesc, std::vector< std::uint8_t > mvcmdBinary, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
Definition: XLinkConnection.cpp:286
dai::XLinkConnection::getProfilingData
ProfilingData getProfilingData()
Definition: XLinkConnection.cpp:519
dai::DeviceInfo::getMxId
std::string getMxId() const
Definition: XLinkConnection.cpp:75
nanorpc::core::detail::pack::meta::status
status
Definition: pack_meta.h:33
dai::XLinkConnection::deviceLinkId
int deviceLinkId
Definition: XLinkConnection.hpp:149
transform
static void transform(uint32_t digest[], uint32_t block[BLOCK_INTS], uint64_t &transforms)
Definition: sha1.hpp:129
dai::XLinkConnection::setRebootOnDestruction
void setRebootOnDestruction(bool reboot)
Definition: XLinkConnection.cpp:361
std
Definition: Node.hpp:366
dai::DeviceInfo::protocol
XLinkProtocol_t protocol
Definition: XLinkConnection.hpp:43
dai::DeviceInfo::getXLinkDeviceDesc
deviceDesc_t getXLinkDeviceDesc() const
Definition: XLinkConnection.cpp:56
dai::getDefaultProtocol
static XLinkProtocol_t getDefaultProtocol()
Definition: XLinkConnection.cpp:89
spdlog-fmt.hpp
dai::XLinkConnection::getDeviceByMxId
static std::tuple< bool, DeviceInfo > getDeviceByMxId(std::string mxId, XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevice=true)
Definition: XLinkConnection.cpp:192
dai::XLinkConnection::rebootOnDestruction
bool rebootOnDestruction
Definition: XLinkConnection.hpp:147
dai::XLinkConnection::close
void close()
Definition: XLinkConnection.cpp:315
dai::DeviceInfo::mxid
std::string mxid
Definition: XLinkConnection.hpp:41
dai::Path
Represents paths on a filesystem; accepts utf-8, Windows utf-16 wchar_t, or std::filesystem::path.
Definition: Path.hpp:27
Logging.hpp
dai::XLinkConnection::WAIT_FOR_CONNECT_TIMEOUT
constexpr static std::chrono::milliseconds WAIT_FOR_CONNECT_TIMEOUT
Definition: XLinkConnection.hpp:158
dai::DeviceInfo::platform
XLinkPlatform_t platform
Definition: XLinkConnection.hpp:44
dai
Definition: CameraExposureOffset.hpp:6
dai::XLinkConnection::bootWithPath
bool bootWithPath
Definition: XLinkConnection.hpp:143
dai::XLinkConnection::bootDevice
bool bootDevice
Definition: XLinkConnection.hpp:142
dai::XLinkConnection::isClosed
bool isClosed() const
Definition: XLinkConnection.cpp:310
dai::XLinkConnection::mvcmd
std::vector< std::uint8_t > mvcmd
Definition: XLinkConnection.hpp:145


depthai
Author(s): Martin Peterlin
autogenerated on Sat Mar 22 2025 02:58:19