Skip to content

Conversation

@TheMutta
Copy link

@TheMutta TheMutta commented Sep 3, 2025

Purpose

This patch gets the state and the platform from gate dynamically.

Specification

Inside the USB EP device discovery functions, once the device is found a request is sent to Gate to get discovery information, and that is used to determine the device state and platform

Dependencies & Potential Impact

This must be paired with the Gate update to make it function correctly.

Deployment Plan

First, the Gate patch must be released to allow for this to work and to allow for testing.

Testing & Validation

For correct testing, first DepthAI Gate must be merged

Filippo Mutta and others added 30 commits July 1, 2025 08:11
This reverts commit 4e42afb.
This reverts commit 4e42afb.
This reverts commit aa476c7.
#include <fcntl.h>
#endif

#include <stdint.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <stdint.h>
#include <cstdint>

#endif

if (usbEpInitialize() != 0) {
xlinkSetProtocolInitialized(X_LINK_USB_EP, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

return error;
}

// Try claiming interface 0 to test if it's in use
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to go directly to INTERFACE_XLINK & INTERFACE_GATE by interface index, instead of searching for it



int usbEpPlatformGateRead(void *data, int size)
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has to be mutex'd

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each R/W opening & closing USB device - lets leave it for now, for initial DAI impl.
But, we might want to move that DeviceGate session has a "opened device" as well

Comment on lines 584 to 589
char *serialStr = (char*)malloc(serialStrLen + 1);
memcpy(serialStr, (const char*)&respBuffer[0], serialStrLen);
serialStr[serialStrLen] = '\0';
serial = serialStr;
free(serialStr);
outSerial = serial;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
char *serialStr = (char*)malloc(serialStrLen + 1);
memcpy(serialStr, (const char*)&respBuffer[0], serialStrLen);
serialStr[serialStrLen] = '\0';
serial = serialStr;
free(serialStr);
outSerial = serial;
serial.resize(serialStrLen);
for(int i = 0; i < serialStrLen; i++){
serial[i] = ...
}

}
return getLocalShdmemDevices(in_deviceRequirements, out_foundDevices, sizeFoundDevices, out_amountOfFoundDevices);
#endif

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary whitespace diff

}



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary whitespace diff

{
mvLog(MVLOG_DEBUG, "cannot open device: %s\n", xlink_libusb_strerror(res));
return (libusb_error) res;
return (libusb_error) res;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary whitespace diff

int rc = 0;

/* Get our device */
libusb_device_handle *gate_dev_handle = libusb_open_device_with_vid_pid(context, 0x05C6, 0x4321);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use: usbPlatformConnect, usbPlatformClose

(if not at all possible, then usbLinkOpen or refLibusbDeviceByName)

return rc;
}

int usbPlatformGateRead(void *data, int size, int timeout)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int usbPlatformGateRead(void *data, int size, int timeout)
int usbPlatformGateRead(name or deviceInfo, void *data, int size, int timeout)

case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
return usbPlatformClose(deviceHandle->xLinkFD);
case X_LINK_USB_EP:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case X_LINK_USB_EP:
case X_LINK_USB_EP:

memset(out_foundDevices[numDevicesFound].mxid, 0, sizeof(out_foundDevices[numDevicesFound].mxid));
strncpy(out_foundDevices[numDevicesFound].mxid, mxId.c_str(), sizeof(out_foundDevices[numDevicesFound].mxid));
numDevicesFound++;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

add_subdirectory("${XLINK_LIBUSB_LOCAL}" "${CMAKE_CURRENT_BINARY_DIR}/libusb" EXCLUDE_FROM_ALL)
elseif(XLINK_LIBUSB_SYSTEM)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace - use spaces: 4 on vscode

Copy link
Collaborator

@themarpe themarpe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added my comments that have to be addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants