Conversation
src/pc/protocols/usb_host_ep.cpp
Outdated
| #include <fcntl.h> | ||
| #endif | ||
|
|
||
| #include <stdint.h> |
There was a problem hiding this comment.
| #include <stdint.h> | |
| #include <cstdint> |
src/pc/PlatformDeviceControl.c
Outdated
| #endif | ||
|
|
||
| if (usbEpInitialize() != 0) { | ||
| xlinkSetProtocolInitialized(X_LINK_USB_EP, 0); |
src/pc/protocols/usb_host_ep.cpp
Outdated
| return error; | ||
| } | ||
|
|
||
| // Try claiming interface 0 to test if it's in use |
There was a problem hiding this comment.
We need to go directly to INTERFACE_XLINK & INTERFACE_GATE by interface index, instead of searching for it
src/pc/protocols/usb_host_ep.cpp
Outdated
|
|
||
|
|
||
| int usbEpPlatformGateRead(void *data, int size) | ||
| { |
There was a problem hiding this comment.
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
src/pc/protocols/usb_host.cpp
Outdated
| char *serialStr = (char*)malloc(serialStrLen + 1); | ||
| memcpy(serialStr, (const char*)&respBuffer[0], serialStrLen); | ||
| serialStr[serialStrLen] = '\0'; | ||
| serial = serialStr; | ||
| free(serialStr); | ||
| outSerial = serial; |
There was a problem hiding this comment.
| 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 | ||
|
|
There was a problem hiding this comment.
unnecessary whitespace diff
src/pc/PlatformDeviceSearch.c
Outdated
| } | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
unnecessary whitespace diff
src/pc/protocols/usb_host.cpp
Outdated
| { | ||
| mvLog(MVLOG_DEBUG, "cannot open device: %s\n", xlink_libusb_strerror(res)); | ||
| return (libusb_error) res; | ||
| return (libusb_error) res; |
There was a problem hiding this comment.
unnecessary whitespace diff
src/pc/protocols/usb_host.cpp
Outdated
| int rc = 0; | ||
|
|
||
| /* Get our device */ | ||
| libusb_device_handle *gate_dev_handle = libusb_open_device_with_vid_pid(context, 0x05C6, 0x4321); |
There was a problem hiding this comment.
Use: usbPlatformConnect, usbPlatformClose
(if not at all possible, then usbLinkOpen or refLibusbDeviceByName)
src/pc/protocols/usb_host.cpp
Outdated
| return rc; | ||
| } | ||
|
|
||
| int usbPlatformGateRead(void *data, int size, int timeout) |
There was a problem hiding this comment.
| int usbPlatformGateRead(void *data, int size, int timeout) | |
| int usbPlatformGateRead(name or deviceInfo, void *data, int size, int timeout) |
src/pc/PlatformDeviceControl.c
Outdated
| case X_LINK_USB_VSC: | ||
| case X_LINK_USB_CDC: | ||
| return usbPlatformClose(deviceHandle->xLinkFD); | ||
| case X_LINK_USB_EP: |
There was a problem hiding this comment.
| 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++; | ||
|
|
cmake/XLinkDependencies.cmake
Outdated
| 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) |
There was a problem hiding this comment.
whitespace - use spaces: 4 on vscode
themarpe
left a comment
There was a problem hiding this comment.
Added my comments that have to be addressed
src/pc/protocols/usb_host.cpp
Outdated
| libusb_release_interface(f, 0); | ||
|
|
||
| if (protocol == X_LINK_USB_EP){ | ||
| libusb_release_interface(f, 1); |
There was a problem hiding this comment.
Might have to be interface 2, todo
src/pc/protocols/usb_host.cpp
Outdated
|
|
||
| rc = usb_read(usbHandle, data, size); | ||
| if(protocol == X_LINK_USB_EP) { | ||
| rc = usb_read(usbHandle, data, size, USB_ENDPOINT_IN + 1); |
There was a problem hiding this comment.
| rc = usb_read(usbHandle, data, size, USB_ENDPOINT_IN + 1); | |
| rc = usb_read(usbHandle, data, size, USB_ENDPOINT_IN + 2); |
Interface 2 likely, TODO -> expose const
src/pc/protocols/usb_host.cpp
Outdated
| libusb_device* dev = libusb_get_device(gate_dev_handle); | ||
|
|
||
| /* Now we claim our ffs interfaces */ | ||
| rc = libusb_claim_interface(gate_dev_handle, 0); |
There was a problem hiding this comment.
check - interface should be 1 probably
# Conflicts: # src/pc/protocols/usb_host.cpp
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