Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
dai::XLinkConnection Class Reference

#include <XLinkConnection.hpp>

Public Member Functions

void close ()
 
int getLinkId () const
 
ProfilingData getProfilingData ()
 
bool getRebootOnDestruction () const
 
bool isClosed () const
 
void setRebootOnDestruction (bool reboot)
 
 XLinkConnection (const DeviceInfo &deviceDesc, dai::Path pathToMvcmd, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
 
 XLinkConnection (const DeviceInfo &deviceDesc, std::vector< std::uint8_t > mvcmdBinary, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
 
 XLinkConnection (const DeviceInfo &deviceDesc, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
 
 ~XLinkConnection ()
 

Static Public Member Functions

static DeviceInfo bootBootloader (const DeviceInfo &devInfo)
 
static std::vector< DeviceInfogetAllConnectedDevices (XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevices=true, XLinkPlatform_t platform=X_LINK_MYRIAD_X)
 
static std::tuple< bool, DeviceInfogetDeviceByMxId (std::string mxId, XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevice=true)
 
static std::tuple< bool, DeviceInfogetFirstDevice (XLinkDeviceState_t state=X_LINK_ANY_STATE, bool skipInvalidDevices=true)
 
static ProfilingData getGlobalProfilingData ()
 

Private Member Functions

void initDevice (const DeviceInfo &deviceToInit, XLinkDeviceState_t expectedState=X_LINK_BOOTED)
 

Static Private Member Functions

static bool bootAvailableDevice (const deviceDesc_t &deviceToBoot, const dai::Path &pathToMvcmd)
 
static bool bootAvailableDevice (const deviceDesc_t &deviceToBoot, std::vector< std::uint8_t > &mvcmd)
 
static std::string convertErrorCodeToString (XLinkError_t errorCode)
 

Private Attributes

bool bootDevice = true
 
bool bootWithPath = true
 
bool closed {false}
 
std::mutex closedMtx
 
DeviceInfo deviceInfo
 
int deviceLinkId = -1
 
std::vector< std::uint8_t > mvcmd
 
dai::Path pathToMvcmd
 
bool rebootOnDestruction {true}
 

Static Private Attributes

constexpr static std::chrono::milliseconds POLLING_DELAY_TIME {10}
 
constexpr static std::chrono::milliseconds WAIT_FOR_BOOTUP_TIMEOUT {15000}
 
constexpr static std::chrono::milliseconds WAIT_FOR_CONNECT_TIMEOUT {5000}
 

Friends

struct XLinkReadError
 
struct XLinkWriteError
 

Detailed Description

Represents connection between host and device over XLink protocol

Definition at line 51 of file XLinkConnection.hpp.

Constructor & Destructor Documentation

◆ XLinkConnection() [1/3]

dai::XLinkConnection::XLinkConnection ( const DeviceInfo deviceDesc,
std::vector< std::uint8_t >  mvcmdBinary,
XLinkDeviceState_t  expectedState = X_LINK_BOOTED 
)

Definition at line 286 of file XLinkConnection.cpp.

◆ XLinkConnection() [2/3]

dai::XLinkConnection::XLinkConnection ( const DeviceInfo deviceDesc,
dai::Path  pathToMvcmd,
XLinkDeviceState_t  expectedState = X_LINK_BOOTED 
)

Definition at line 292 of file XLinkConnection.cpp.

◆ XLinkConnection() [3/3]

dai::XLinkConnection::XLinkConnection ( const DeviceInfo deviceDesc,
XLinkDeviceState_t  expectedState = X_LINK_BOOTED 
)
explicit

Definition at line 302 of file XLinkConnection.cpp.

◆ ~XLinkConnection()

dai::XLinkConnection::~XLinkConnection ( )

Definition at line 357 of file XLinkConnection.cpp.

Member Function Documentation

◆ bootAvailableDevice() [1/2]

bool dai::XLinkConnection::bootAvailableDevice ( const deviceDesc_t &  deviceToBoot,
const dai::Path pathToMvcmd 
)
staticprivate

Definition at line 369 of file XLinkConnection.cpp.

◆ bootAvailableDevice() [2/2]

bool dai::XLinkConnection::bootAvailableDevice ( const deviceDesc_t &  deviceToBoot,
std::vector< std::uint8_t > &  mvcmd 
)
staticprivate

Definition at line 376 of file XLinkConnection.cpp.

◆ bootBootloader()

DeviceInfo dai::XLinkConnection::bootBootloader ( const DeviceInfo devInfo)
static

Tries booting the given device into bootloader state

Parameters
devInfoInformation of device which it should boot into bootloader state
Returns
New device information if successful

Definition at line 221 of file XLinkConnection.cpp.

◆ close()

void dai::XLinkConnection::close ( )

Explicitly closes xlink connection.

Note
This function does not need to be explicitly called as destructor closes the connection automatically

Definition at line 315 of file XLinkConnection.cpp.

◆ convertErrorCodeToString()

std::string dai::XLinkConnection::convertErrorCodeToString ( XLinkError_t  errorCode)
staticprivate

Definition at line 504 of file XLinkConnection.cpp.

◆ getAllConnectedDevices()

std::vector< DeviceInfo > dai::XLinkConnection::getAllConnectedDevices ( XLinkDeviceState_t  state = X_LINK_ANY_STATE,
bool  skipInvalidDevices = true,
XLinkPlatform_t  platform = X_LINK_MYRIAD_X 
)
static

Returns information of all connected devices with given state

Parameters
stateState which the devices should be in
skipInvalidDeviceswhether or not to skip over devices that cannot be successfully communicated with
platformWhich platforms to search for
Returns
Vector of connected device information

Definition at line 113 of file XLinkConnection.cpp.

◆ getDeviceByMxId()

std::tuple< bool, DeviceInfo > dai::XLinkConnection::getDeviceByMxId ( std::string  mxId,
XLinkDeviceState_t  state = X_LINK_ANY_STATE,
bool  skipInvalidDevice = true 
)
static

Finds a device by MX ID. Example: 14442C10D13EABCE00

Parameters
mxIdMyraidX ID which uniquely specifies a device
stateWhich state should the device be in
skipInvalidDevicesWhether or not to skip devices that cannot be fully detected
Returns
Tuple of bool and DeviceInfo. Bool specifies if device was found. DeviceInfo specifies the found device

Definition at line 192 of file XLinkConnection.cpp.

◆ getFirstDevice()

std::tuple< bool, DeviceInfo > dai::XLinkConnection::getFirstDevice ( XLinkDeviceState_t  state = X_LINK_ANY_STATE,
bool  skipInvalidDevices = true 
)
static

Returns information of first device with given state

Parameters
stateState which the device should be in
Returns
Device information

Definition at line 160 of file XLinkConnection.cpp.

◆ getGlobalProfilingData()

ProfilingData dai::XLinkConnection::getGlobalProfilingData ( )
static

Get current accumulated profiling data

Returns
ProfilingData from the specific connection

Definition at line 508 of file XLinkConnection.cpp.

◆ getLinkId()

int dai::XLinkConnection::getLinkId ( ) const

Definition at line 500 of file XLinkConnection.cpp.

◆ getProfilingData()

ProfilingData dai::XLinkConnection::getProfilingData ( )

Get current accumulated profiling data

Returns
ProfilingData from the specific connection

Definition at line 519 of file XLinkConnection.cpp.

◆ getRebootOnDestruction()

bool dai::XLinkConnection::getRebootOnDestruction ( ) const

Definition at line 365 of file XLinkConnection.cpp.

◆ initDevice()

void dai::XLinkConnection::initDevice ( const DeviceInfo deviceToInit,
XLinkDeviceState_t  expectedState = X_LINK_BOOTED 
)
private

Definition at line 381 of file XLinkConnection.cpp.

◆ isClosed()

bool dai::XLinkConnection::isClosed ( ) const

Is the connection already closed (or disconnected)

Warning
This function is thread-unsafe and may return outdated incorrect values. It is only meant for use in simple single-threaded code. Well written code should handle exceptions when calling any DepthAI apis to handle hardware events and multithreaded use.

Definition at line 310 of file XLinkConnection.cpp.

◆ setRebootOnDestruction()

void dai::XLinkConnection::setRebootOnDestruction ( bool  reboot)

Definition at line 361 of file XLinkConnection.cpp.

Friends And Related Function Documentation

◆ XLinkReadError

friend struct XLinkReadError
friend

Definition at line 133 of file XLinkConnection.hpp.

◆ XLinkWriteError

friend struct XLinkWriteError
friend

Definition at line 134 of file XLinkConnection.hpp.

Member Data Documentation

◆ bootDevice

bool dai::XLinkConnection::bootDevice = true
private

Definition at line 142 of file XLinkConnection.hpp.

◆ bootWithPath

bool dai::XLinkConnection::bootWithPath = true
private

Definition at line 143 of file XLinkConnection.hpp.

◆ closed

bool dai::XLinkConnection::closed {false}
private

Definition at line 155 of file XLinkConnection.hpp.

◆ closedMtx

std::mutex dai::XLinkConnection::closedMtx
mutableprivate

Definition at line 154 of file XLinkConnection.hpp.

◆ deviceInfo

DeviceInfo dai::XLinkConnection::deviceInfo
private

Definition at line 151 of file XLinkConnection.hpp.

◆ deviceLinkId

int dai::XLinkConnection::deviceLinkId = -1
private

Definition at line 149 of file XLinkConnection.hpp.

◆ mvcmd

std::vector<std::uint8_t> dai::XLinkConnection::mvcmd
private

Definition at line 145 of file XLinkConnection.hpp.

◆ pathToMvcmd

dai::Path dai::XLinkConnection::pathToMvcmd
private

Definition at line 144 of file XLinkConnection.hpp.

◆ POLLING_DELAY_TIME

constexpr std::chrono::milliseconds dai::XLinkConnection::POLLING_DELAY_TIME {10}
staticconstexprprivate

Definition at line 159 of file XLinkConnection.hpp.

◆ rebootOnDestruction

bool dai::XLinkConnection::rebootOnDestruction {true}
private

Definition at line 147 of file XLinkConnection.hpp.

◆ WAIT_FOR_BOOTUP_TIMEOUT

constexpr std::chrono::milliseconds dai::XLinkConnection::WAIT_FOR_BOOTUP_TIMEOUT {15000}
staticconstexprprivate

Definition at line 157 of file XLinkConnection.hpp.

◆ WAIT_FOR_CONNECT_TIMEOUT

constexpr std::chrono::milliseconds dai::XLinkConnection::WAIT_FOR_CONNECT_TIMEOUT {5000}
staticconstexprprivate

Definition at line 158 of file XLinkConnection.hpp.


The documentation for this class was generated from the following files:


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