Skip to content

Commit 4f845ca

Browse files
authored
Merge pull request #1268 from luxonis/rvc4_discovery
RVC4 discovery
2 parents 79cdb20 + 2cfb310 commit 4f845ca

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

cmake/Hunter/config.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ hunter_config(
66
hunter_config(
77
XLink
88
VERSION "luxonis-2021.4.2-master"
9-
URL "https://github.com/luxonis/XLink/archive/2b517e1cb1ca77bea17679f9fdeb739812431174.tar.gz"
10-
SHA1 "fa7eeb46abeb97626dad923b7733899198284587"
9+
URL "https://github.com/luxonis/XLink/archive/82839cb04f2102177fad926fb8f7fcf7b4093cb1.tar.gz"
10+
SHA1 "c371bdefb2ea9f4c382b00d8629a466b3c79b35d"
1111
CMAKE_ARGS
1212
XLINK_ENABLE_LIBUSB=${DEPTHAI_ENABLE_LIBUSB}
1313
)

include/depthai/xlink/XLinkConnection.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ class XLinkConnection {
5757
*
5858
* @param state State which the devices should be in
5959
* @param skipInvalidDevices whether or not to skip over devices that cannot be successfully communicated with
60+
* @param platform Which platforms to search for
6061
* @returns Vector of connected device information
6162
*/
62-
static std::vector<DeviceInfo> getAllConnectedDevices(XLinkDeviceState_t state = X_LINK_ANY_STATE, bool skipInvalidDevices = true);
63+
static std::vector<DeviceInfo> getAllConnectedDevices(XLinkDeviceState_t state = X_LINK_ANY_STATE,
64+
bool skipInvalidDevices = true,
65+
XLinkPlatform_t platform = X_LINK_MYRIAD_X);
6366

6467
/**
6568
* Returns information of first device with given state

src/device/DeviceBase.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,13 +322,17 @@ void DeviceBase::tryGetDevice() {
322322
bool found = false;
323323
std::tie(found, deviceInfo) = getAnyAvailableDevice();
324324

325-
// If no device found, throw
326325
if(!found) {
327326
auto numConnected = getAllAvailableDevices().size();
328327
if(numConnected > 0) {
329-
throw std::runtime_error(fmt::format("No available devices ({} connected, but in use)", numConnected));
330-
} else {
331-
throw std::runtime_error("No available devices");
328+
throw std::runtime_error("No available devices (" + std::to_string(numConnected) + " connected, but in use)");
329+
}
330+
auto numDevicesAnyPlatform = dai::XLinkConnection::getAllConnectedDevices(X_LINK_ANY_STATE, false, X_LINK_ANY_PLATFORM).size();
331+
auto numDevicesRVC2 = dai::XLinkConnection::getAllConnectedDevices(X_LINK_ANY_STATE, false, X_LINK_MYRIAD_X).size();
332+
auto nonRVC2Devices = numDevicesAnyPlatform - numDevicesRVC2;
333+
if(nonRVC2Devices > 0) {
334+
throw std::runtime_error("No available RVC2 devices found, but found " + std::to_string(nonRVC2Devices)
335+
+ " non RVC2 device[s]. To use RVC4 devices, please update DepthAI to version v3.x or newer.");
332336
}
333337
}
334338
}

src/xlink/XLinkConnection.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ constexpr std::chrono::milliseconds XLinkConnection::WAIT_FOR_BOOTUP_TIMEOUT;
110110
constexpr std::chrono::milliseconds XLinkConnection::WAIT_FOR_CONNECT_TIMEOUT;
111111
constexpr std::chrono::milliseconds XLinkConnection::POLLING_DELAY_TIME;
112112

113-
std::vector<DeviceInfo> XLinkConnection::getAllConnectedDevices(XLinkDeviceState_t state, bool skipInvalidDevices) {
113+
std::vector<DeviceInfo> XLinkConnection::getAllConnectedDevices(XLinkDeviceState_t state, bool skipInvalidDevices, XLinkPlatform_t platform) {
114114
initialize();
115115

116116
std::vector<DeviceInfo> devices;
@@ -119,7 +119,7 @@ std::vector<DeviceInfo> XLinkConnection::getAllConnectedDevices(XLinkDeviceState
119119
std::array<deviceDesc_t, 64> deviceDescAll = {};
120120
deviceDesc_t suitableDevice = {};
121121
suitableDevice.protocol = getDefaultProtocol();
122-
suitableDevice.platform = X_LINK_ANY_PLATFORM;
122+
suitableDevice.platform = platform;
123123
suitableDevice.state = state;
124124

125125
auto allowedDeviceMxIds = utility::getEnv("DEPTHAI_DEVICE_MXID_LIST");
@@ -162,7 +162,7 @@ std::tuple<bool, DeviceInfo> XLinkConnection::getFirstDevice(XLinkDeviceState_t
162162

163163
DeviceInfo devReq = {};
164164
devReq.protocol = X_LINK_ANY_PROTOCOL;
165-
devReq.platform = X_LINK_ANY_PLATFORM;
165+
devReq.platform = X_LINK_MYRIAD_X;
166166
devReq.name = "";
167167
devReq.mxid = "";
168168
devReq.state = state;
@@ -195,6 +195,7 @@ std::tuple<bool, DeviceInfo> XLinkConnection::getDeviceByMxId(std::string mxId,
195195
DeviceInfo dev;
196196
dev.mxid = mxId;
197197
dev.state = state;
198+
dev.platform = X_LINK_MYRIAD_X;
198199

199200
deviceDesc_t desc = {};
200201
auto res = XLinkFindFirstSuitableDevice(dev.getXLinkDeviceDesc(), &desc);

0 commit comments

Comments
 (0)