.. _program_listing_file_include_depthai_xlink_XLinkConnection.hpp: Program Listing for File XLinkConnection.hpp ============================================ |exhale_lsh| :ref:`Return to documentation for file ` (``include/depthai/xlink/XLinkConnection.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once // Std #include #include #include #include #include #include #include #include #include #include // project #include "depthai/utility/Path.hpp" #include "depthai/utility/ProfilingData.hpp" // Libraries #include namespace dai { struct DeviceInfo { DeviceInfo() = default; DeviceInfo(std::string name, std::string mxid, XLinkDeviceState_t state, XLinkProtocol_t protocol, XLinkPlatform_t platform, XLinkError_t status); explicit DeviceInfo(std::string mxidOrName); explicit DeviceInfo(const deviceDesc_t& desc); deviceDesc_t getXLinkDeviceDesc() const; std::string getMxId() const; std::string toString() const; std::string name = ""; std::string mxid = ""; XLinkDeviceState_t state = X_LINK_ANY_STATE; XLinkProtocol_t protocol = X_LINK_ANY_PROTOCOL; XLinkPlatform_t platform = X_LINK_ANY_PLATFORM; XLinkError_t status = X_LINK_SUCCESS; }; class XLinkConnection { public: // static API static std::vector getAllConnectedDevices(XLinkDeviceState_t state = X_LINK_ANY_STATE, bool skipInvalidDevices = true, XLinkPlatform_t platform = X_LINK_MYRIAD_X); static std::tuple getFirstDevice(XLinkDeviceState_t state = X_LINK_ANY_STATE, bool skipInvalidDevices = true); static std::tuple getDeviceByMxId(std::string mxId, XLinkDeviceState_t state = X_LINK_ANY_STATE, bool skipInvalidDevice = true); static DeviceInfo bootBootloader(const DeviceInfo& devInfo); static ProfilingData getGlobalProfilingData(); XLinkConnection(const DeviceInfo& deviceDesc, std::vector mvcmdBinary, XLinkDeviceState_t expectedState = X_LINK_BOOTED); XLinkConnection(const DeviceInfo& deviceDesc, dai::Path pathToMvcmd, XLinkDeviceState_t expectedState = X_LINK_BOOTED); explicit XLinkConnection(const DeviceInfo& deviceDesc, XLinkDeviceState_t expectedState = X_LINK_BOOTED); ~XLinkConnection(); void setRebootOnDestruction(bool reboot); bool getRebootOnDestruction() const; int getLinkId() const; void close(); bool isClosed() const; ProfilingData getProfilingData(); private: friend struct XLinkReadError; friend struct XLinkWriteError; // static static bool bootAvailableDevice(const deviceDesc_t& deviceToBoot, const dai::Path& pathToMvcmd); static bool bootAvailableDevice(const deviceDesc_t& deviceToBoot, std::vector& mvcmd); static std::string convertErrorCodeToString(XLinkError_t errorCode); void initDevice(const DeviceInfo& deviceToInit, XLinkDeviceState_t expectedState = X_LINK_BOOTED); bool bootDevice = true; bool bootWithPath = true; dai::Path pathToMvcmd; std::vector mvcmd; bool rebootOnDestruction{true}; int deviceLinkId = -1; DeviceInfo deviceInfo; // closed mutable std::mutex closedMtx; bool closed{false}; constexpr static std::chrono::milliseconds WAIT_FOR_BOOTUP_TIMEOUT{15000}; constexpr static std::chrono::milliseconds WAIT_FOR_CONNECT_TIMEOUT{5000}; constexpr static std::chrono::milliseconds POLLING_DELAY_TIME{10}; }; } // namespace dai