Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
e6f7b24
Added gadgets
Jul 1, 2025
58edff5
Removed binary files
Jul 1, 2025
f486e90
Merge branch 'develop_server' into develop_gadget
Jul 1, 2025
30093ee
Added comments for EPs offsets
Jul 1, 2025
6dbba16
Set correct offsets.
Jul 1, 2025
0de2e87
Merge pull request #91 from luxonis/develop_gadget
TheMutta Jul 1, 2025
1958f31
Merge branch 'develop_server' into no_hunter
Jul 1, 2025
7538a46
Added discovery
Jul 2, 2025
6ab310d
Recognition of the USB EP interface via strings
Jul 2, 2025
5c220ed
Set correct PRODUCT_ID in USB EP
Jul 3, 2025
ca49e53
Using first unused device in USB EP.
Jul 3, 2025
d20978d
Finalised USB EPs
Jul 10, 2025
30f184d
Merge pull request #92 from luxonis/develop_gadget
TheMutta Jul 10, 2025
1f1ade0
Merge branch 'develop_server' into no_hunter
Jul 10, 2025
0e2e7d1
Initialising usb ctx.
Jul 10, 2025
8423b90
Fixed wrong protocol in discovery for USB EP
Jul 10, 2025
11538f3
Set priority for USB_EP during discovery
Jul 11, 2025
fdc7ca6
Removed ctx deinitialisation
Jul 11, 2025
9909f6d
Brainstorm
themarpe Jul 15, 2025
077bb1c
Merge remote-tracking branch 'origin/usb_ep_discovery' into develop_g…
Jul 15, 2025
4891a88
Added GATE read and write functions.
Jul 16, 2025
e519b86
Changed XLinkGateReadData to behave like XLinkReadMoveData
Jul 16, 2025
4e42afb
Set state to gate
Jul 16, 2025
aa476c7
Revert "Set state to gate"
Jul 16, 2025
5968190
Revert "Set state to gate"
Jul 16, 2025
fd7e65f
Reapply "Set state to gate"
Jul 16, 2025
1b68e19
Merge branch 'develop_gadget' into no_hunter
Jul 16, 2025
4126554
Set gate state.
Jul 16, 2025
7d9d6b9
Changed XLinkPlatformGate functions to not require device handle
Jul 16, 2025
d46c049
Removed dispatched implementation.
Jul 16, 2025
58c5cb8
Added conditional compilation for windows for usb_host_ep
Aug 5, 2025
674b295
Added wrapper for XLinkPlatformGate functions
Aug 5, 2025
798a74e
Getting state from gate
Sep 3, 2025
c72e670
Made sure the response in usbepGetDevices isn't larger than the struct
Sep 11, 2025
8ddeb2b
Separated the bytes transferred variable in bulk transfer for device …
Sep 12, 2025
2f5db2d
usb_host_ep: Added checks in Gate functions
Sep 17, 2025
3606f51
Fixed string size calculation.
Sep 18, 2025
d5abd87
usb_host_ep: Fixed typo
Sep 18, 2025
57b192b
usb_host_ep: Corrected dynamic platform assignment.
Sep 18, 2025
085e25d
usb_host_ep: Reinstated timeout
Sep 23, 2025
c8fb130
usb_host_ep: Using async transfers.
Sep 23, 2025
551b333
usb_host_ep: Fixed use after free.
Sep 23, 2025
c856a76
usb_host_ep: Async fixes in handling, buffers and volatile.
Sep 23, 2025
80e5394
usb_host_ep: Added usb disconnection/reconnection callback
Sep 23, 2025
3010d2a
usb_host_ep: Setup gate_ctx for gate transfers.
Sep 23, 2025
cc65c5e
Removed file.
Sep 23, 2025
647dcc4
usb_host_ep: Initialising gate only once.
Sep 24, 2025
9262cc1
usb_host_ep: Removed references to libusb_exit for gate_ctx
Sep 24, 2025
7f30c51
Gate: added explicit timeout.
Sep 25, 2025
6cc5e92
Gate: instated correct error handling.
Sep 25, 2025
24d0be0
XLinkData: fixed missing semicolon.
Sep 25, 2025
85502ee
Merging usb_host_ep into usb_host: fixing discovery.
Sep 29, 2025
2fc723a
Merging usb_host_ep into usb_host: added read/write/gate read/gate write
Sep 29, 2025
0988394
Merging usb_host_ep into usb_host: merged final quirks and added usb …
Oct 1, 2025
dcc9a91
Removed file.
Oct 1, 2025
a4cc70a
Merge branch 'discovery_gate_usb_ep' into no_hunter_discovery_gate_us…
Oct 1, 2025
2ca735d
usb_ep: Removed references to usb_host_ep
Oct 1, 2025
87e1e75
usb_ep: Removed references to usb_host_ep v2
Oct 1, 2025
62d8c43
Merge branch 'discovery_gate_usb_ep' into no_hunter_discovery_gate_us…
Oct 1, 2025
bc8afd1
usb_host: Fixed bug in discovery for USB EPs
Oct 1, 2025
4daffea
usb_ep: Fixed platform assignment from gate.
Oct 1, 2025
871076f
usb_ep: removed unused function is PlatformGate functions.
Oct 1, 2025
4dc7073
usb_host: Reinstated old Gate functions.
Oct 1, 2025
52f2419
usb_host: Fixed naming in EP functions
Oct 1, 2025
f4dc80b
usb_host: Added lock in usb link opening.
Oct 1, 2025
a24a3e3
usb_host: Added mutext usb checks.
Oct 2, 2025
2814d66
usb_host: Removed excess mutex locks.
Oct 6, 2025
7cf6eb7
usb_host: Added correct handling in Read/Write for VSC/EP
Oct 6, 2025
68a9933
usb_host: Remove read/write mutexes for testing.
Oct 6, 2025
cdeb969
usb_host: Added server setting for EPs.
Oct 6, 2025
2164106
usb_host: Disabled mutex in read/write due to scheduler.
Oct 6, 2025
9c0193b
Whitespace tweaks
themarpe Oct 6, 2025
4e33b55
usb_host: Formatting changes.
Oct 6, 2025
18d6dee
usb_host: Added explicit dev path for Gate Read/Write
Oct 7, 2025
72e6b7e
usb_host: Fixed missing else case.
Oct 7, 2025
deaedf5
usb_host: Explicit ep assignment in read/write
Oct 7, 2025
79d268b
usb_host: Reset VIDPID to pre-testing.
Oct 7, 2025
e8c3654
usb_host: Fixed formatting.
Oct 7, 2025
8db8777
usb_host: Fixed serial.
Oct 7, 2025
eadd24d
Fixed formatting.
Oct 7, 2025
b83a8c3
Fixed formatting.
Oct 7, 2025
7ea6780
Rearranged some format & fixed an if statement misassignment bug
themarpe Oct 8, 2025
b5f63da
usb_host: Added atomic bool for isServer.
Oct 8, 2025
03b94f9
Merge branch 'v3_develop' into discovery_gate_usb_ep
Oct 8, 2025
e56ec8a
usb_host: Added missing bracket.
Oct 8, 2025
fccbec0
usb_host: cleanup a few whitespaces
alex-luxonis Feb 2, 2026
d061873
usb_host: USB_EP adapt to latest RVC4 OS USB interfaces
alex-luxonis Feb 2, 2026
6949d8d
Merge 'origin/v3_develop' into discovery_gate_usb_ep
alex-luxonis Feb 2, 2026
32fefff
Rename /dev/usb-ffs/xlink -> /dev/usb-ffs/device
alex-luxonis Feb 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ if (UNIX AND !APPLE)
add_example(xlink_client_local xlink_client_local.cpp)
endif (UNIX AND !APPLE)

# EP example
add_example(xlink_usb_server xlink_usb_server.cpp)
add_example(xlink_usb_client xlink_usb_client.cpp)
54 changes: 54 additions & 0 deletions examples/xlink_usb_client.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <thread>
#include <stdexcept>
#include <iostream>
#include <cassert>
#include <chrono>
#include <thread>
#include <algorithm>
#include <cstring>
#include <atomic>

#include "XLink/XLink.h"
#include "XLink/XLinkPublicDefines.h"
#include "XLink/XLinkLog.h"

// Common constants
const uint8_t DUMMY_DATA[1024*128] = {};

int main(int argc, char** argv) {
XLinkGlobalHandler_t gHandler;
XLinkInitialize(&gHandler);

mvLogDefaultLevelSet(MVLOG_DEBUG);

deviceDesc_t deviceDesc;
strcpy(deviceDesc.name, "usbdev");
deviceDesc.protocol = X_LINK_USB_EP;

printf("Device name: %s\n", deviceDesc.name);

XLinkHandler_t handler;
handler.devicePath = deviceDesc.name;
handler.protocol = deviceDesc.protocol;
auto connRet = XLinkConnect(&handler);
printf("Connection returned: %s\n", XLinkErrorToStr(connRet));
if(connRet != X_LINK_SUCCESS) {
return -1;
}

auto s = XLinkOpenStream(handler.linkId, "test_0", sizeof(DUMMY_DATA) * 2);
if(s == INVALID_STREAM_ID){
printf("Open stream failed...\n");
} else {
printf("Open stream OK - id: 0x%08X\n", s);
}

auto w = XLinkWriteData(s, (uint8_t*) &s, sizeof(s));
assert(w == X_LINK_SUCCESS);

return 0;
}
62 changes: 62 additions & 0 deletions examples/xlink_usb_server.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <thread>
#include <stdexcept>
#include <iostream>
#include <cassert>
#include <chrono>
#include <thread>
#include <algorithm>
#include <cstring>
#include <atomic>

#include "XLink/XLink.h"
#include "XLink/XLinkPublicDefines.h"
#include "XLink/XLinkLog.h"

// Common constants
constexpr static auto NUM_STREAMS = 16;
constexpr static auto NUM_PACKETS = 120;
const uint8_t DUMMY_DATA[1024*128] = {};
XLinkGlobalHandler_t xlinkGlobalHandler = {};

// Server
//

int main(int argc, const char** argv){

xlinkGlobalHandler.protocol = X_LINK_USB_EP;

// Initialize and suppress XLink logs
mvLogDefaultLevelSet(MVLOG_DEBUG);
auto status = XLinkInitialize(&xlinkGlobalHandler);
if(X_LINK_SUCCESS != status) {
throw std::runtime_error("Couldn't initialize XLink");
}

XLinkHandler_t handler;
handler.devicePath = "/dev/usb-ffs/device";
handler.protocol = X_LINK_USB_EP;
XLinkServerOnly(&handler);


// loop through streams
auto s = XLinkOpenStream(0, "test_0", sizeof(DUMMY_DATA) * 2);
assert(s != INVALID_STREAM_ID);

// auto w = XLinkWriteData2(s, (uint8_t*) &s, sizeof(s/2), ((uint8_t*) &s) + sizeof(s/2), sizeof(s) - sizeof(s/2));
// assert(w == X_LINK_SUCCESS);

auto w = XLinkWriteData(s, (uint8_t*) &s, sizeof(s));
assert(w == X_LINK_SUCCESS);


streamPacketDesc_t p;
w = XLinkReadMoveData(s, &p);
assert(w == X_LINK_SUCCESS);
XLinkDeallocateMoveData(p.data, p.length);

return 0;
}
11 changes: 11 additions & 0 deletions include/XLink/XLink.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,17 @@ XLinkError_t XLinkWriteData(streamId_t const streamId, const uint8_t* buffer, in

XLinkError_t XLinkWriteData_(streamId_t streamId, const uint8_t* buffer, int size, XLinkTimespec* outTSend);

/**
* @brief Sends/Receives a message to Gate via USB
* @param[in] name - Device name/path
* @param[in] data - Data to be transmitted/collected
* @param[in] size - The data size
* @param[in] size - USB timeout
* @return Status code of the operation: X_LINK_SUCCESS (0) for success
*/
XLinkError_t XLinkGateWrite(const char *name, void *data, int size, int timeout);
XLinkError_t XLinkGateRead(const char *name, void *data, int size, int timeout);

/**
* @brief Sends a package to initiate the writing of a file descriptor
* @warning Actual size of the written data is ALIGN_UP(size, 64)
Expand Down
3 changes: 3 additions & 0 deletions include/XLink/XLinkPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum {
X_LINK_PLATFORM_LOCAL_SHDMEM_DRIVER_NOT_LOADED = X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_LOCAL_SHDMEM,
X_LINK_PLATFORM_TCP_IP_OR_LOCAL_SHDMEM_DRIVER_NOT_LOADED = X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_TCP_IP_OR_LOCAL_SHDMEM,
X_LINK_PLATFORM_PCIE_DRIVER_NOT_LOADED = X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_PCIE,
X_LINK_PLATFORM_USB_EP_DRIVER_NOT_LOADED = X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_USB_EP,
} xLinkPlatformErrorCode_t;

// ------------------------------------
Expand Down Expand Up @@ -90,6 +91,8 @@ xLinkPlatformErrorCode_t XLinkPlatformCloseRemote(xLinkDeviceHandle_t* deviceHan
int XLinkPlatformWrite(xLinkDeviceHandle_t *deviceHandle, void *data, int size);
int XLinkPlatformWriteFd(xLinkDeviceHandle_t *deviceHandle, const long fd, void *data2, int size2);
int XLinkPlatformRead(xLinkDeviceHandle_t *deviceHandle, void *data, int size, long *fd);
int XLinkPlatformGateWrite(const char *name, void *data, int size, int timeout);
int XLinkPlatformGateRead(const char *name, void *data, int size, int timeout);

void* XLinkPlatformAllocateData(uint32_t size, uint32_t alignment);
void XLinkPlatformDeallocateData(void *ptr, uint32_t size, uint32_t alignment);
Expand Down
1 change: 1 addition & 0 deletions include/XLink/XLinkPublicDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum{
X_LINK_TCP_IP,
X_LINK_LOCAL_SHDMEM,
X_LINK_TCP_IP_OR_LOCAL_SHDMEM,
X_LINK_USB_EP,
X_LINK_NMB_OF_PROTOCOLS,
X_LINK_ANY_PROTOCOL
} XLinkProtocol_t;
Expand Down
30 changes: 27 additions & 3 deletions src/pc/PlatformData.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@
#include <termios.h>

#include "usb_host.h"
#endif /*USE_USB_VSC*/

extern int usbFdWrite;
extern int usbFdRead;
#endif /*USE_USB_VSC*/
extern int usbGateFdWrite;
extern int usbGateFdRead;

// ------------------------------------
// Wrappers declaration. Begin.
Expand Down Expand Up @@ -87,7 +89,8 @@ int XLinkPlatformWrite(xLinkDeviceHandle_t *deviceHandle, void *data, int size)
switch (deviceHandle->protocol) {
case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
return usbPlatformWrite(deviceHandle->xLinkFD, data, size);
case X_LINK_USB_EP:
return usbPlatformWrite(deviceHandle->protocol, deviceHandle->xLinkFD, data, size);

case X_LINK_PCIE:
return pciePlatformWrite(deviceHandle->xLinkFD, data, size);
Expand Down Expand Up @@ -134,7 +137,8 @@ int XLinkPlatformRead(xLinkDeviceHandle_t *deviceHandle, void *data, int size, l
switch (deviceHandle->protocol) {
case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
return usbPlatformRead(deviceHandle->xLinkFD, data, size);
case X_LINK_USB_EP:
return usbPlatformRead(deviceHandle->protocol, deviceHandle->xLinkFD, data, size);

case X_LINK_PCIE:
return pciePlatformRead(deviceHandle->xLinkFD, data, size);
Expand All @@ -153,6 +157,26 @@ int XLinkPlatformRead(xLinkDeviceHandle_t *deviceHandle, void *data, int size, l
}
}

int XLinkPlatformGateWrite(const char *name, void *data, int size, int timeout)
{
if(!XLinkIsProtocolInitialized(X_LINK_USB_EP)) {
return X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_USB_EP;
}

return usbPlatformGateWrite(name, data, size, timeout);
}

int XLinkPlatformGateRead(const char *name, void *data, int size, int timeout)
{
if(!XLinkIsProtocolInitialized(X_LINK_USB_EP)) {
return X_LINK_PLATFORM_DRIVER_NOT_LOADED+X_LINK_USB_EP;
}

return usbPlatformGateRead(name, data, size, timeout);
}



void* XLinkPlatformAllocateData(uint32_t size, uint32_t alignment)
{
void* ret = NULL;
Expand Down
18 changes: 14 additions & 4 deletions src/pc/PlatformDeviceControl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
#include <sys/ioctl.h>
#include <termios.h>
#include <fcntl.h>
#endif /*USE_USB_VSC*/

int usbFdWrite = -1;
int usbFdRead = -1;
#endif /*USE_USB_VSC*/
int usbGateFdWrite = -1;
int usbGateFdRead = -1;

#include "XLinkPublicDefines.h"

Expand Down Expand Up @@ -90,6 +92,7 @@ xLinkPlatformErrorCode_t XLinkPlatformInit(XLinkGlobalHandler_t* globalHandler)
// check for failed initialization; LIBUSB_SUCCESS = 0
if (usbInitialize(globalHandler->options) != 0) {
xlinkSetProtocolInitialized(X_LINK_USB_VSC, 0);
xlinkSetProtocolInitialized(X_LINK_USB_EP, 0);
}

// Initialize tcpip protocol if necessary
Expand All @@ -103,7 +106,7 @@ xLinkPlatformErrorCode_t XLinkPlatformInit(XLinkGlobalHandler_t* globalHandler)
xlinkSetProtocolInitialized(X_LINK_LOCAL_SHDMEM, 0);
}
#endif

xlinkSetProtocolInitialized(X_LINK_TCP_IP_OR_LOCAL_SHDMEM, 1);

return X_LINK_PLATFORM_SUCCESS;
Expand Down Expand Up @@ -185,7 +188,8 @@ xLinkPlatformErrorCode_t XLinkPlatformConnect(const char* devPathRead, const cha
switch (*protocol) {
case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
return usbPlatformConnect(devPathRead, devPathWrite, fd);
case X_LINK_USB_EP:
return usbPlatformConnect(*protocol, devPathRead, devPathWrite, fd);

case X_LINK_PCIE:
return pciePlatformConnect(devPathRead, devPathWrite, fd);
Expand All @@ -209,6 +213,11 @@ xLinkPlatformErrorCode_t XLinkPlatformConnect(const char* devPathRead, const cha
xLinkPlatformErrorCode_t XLinkPlatformServer(const char* devPathRead, const char* devPathWrite, XLinkProtocol_t *protocol, void** fd)
{
switch (*protocol) {
case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
case X_LINK_USB_EP:
return usbPlatformServer(devPathRead, devPathWrite, fd);

case X_LINK_TCP_IP:
return tcpipPlatformServer(devPathRead, devPathWrite, fd, NULL);

Expand Down Expand Up @@ -260,7 +269,8 @@ xLinkPlatformErrorCode_t XLinkPlatformCloseRemote(xLinkDeviceHandle_t* deviceHan
switch (deviceHandle->protocol) {
case X_LINK_USB_VSC:
case X_LINK_USB_CDC:
return usbPlatformClose(deviceHandle->xLinkFD);
case X_LINK_USB_EP:
return usbPlatformClose(deviceHandle->protocol, deviceHandle->xLinkFD);

case X_LINK_PCIE:
return pciePlatformClose(deviceHandle->xLinkFD);
Expand Down
1 change: 1 addition & 0 deletions src/pc/PlatformDeviceSearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ xLinkPlatformErrorCode_t XLinkPlatformFindDevices(const deviceDesc_t in_deviceRe
switch (in_deviceRequirements.protocol){
case X_LINK_USB_CDC:
case X_LINK_USB_VSC:
case X_LINK_USB_EP:
if(!XLinkIsProtocolInitialized(in_deviceRequirements.protocol)) {
return X_LINK_PLATFORM_DRIVER_NOT_LOADED+in_deviceRequirements.protocol;
}
Expand Down
Loading
Loading