Conversation
themarpe
left a comment
There was a problem hiding this comment.
USB_EP for "client" should not exist.
USB_EP is specialization ONLY for Server part of USB Device capability
Eg usb_host_ep.cpp now contains exactly the same thing as USB_VSC server does.
It should only contain USB_EP
examples/xlink_usb_client.cpp
Outdated
| deviceDesc_t deviceDesc; | ||
| strcpy(deviceDesc.name, "usbdev"); | ||
| deviceDesc.protocol = X_LINK_USB_EP; |
There was a problem hiding this comment.
USB_VSC will use EPs 81 and 1 to communicate, but those aren't the ones that are present in our gadget.
That's because in our gadget we create first the NCM function, then the XLink function, and after the ADB function.
I'll first modify the gadget and test it if it works.
There was a problem hiding this comment.
Then lets move the specialization for custom EP to usb vsc, and well then pick the right one afterwards. (Eg using state, or some other attributes of the device. We'll have to make the device discovery as well)
src/pc/protocols/usb_host_ep.cpp
Outdated
| char outPath[256]; | ||
| strcpy(outPath, devPathWrite); | ||
| strcat(outPath, "/ep1"); | ||
|
|
||
| char inPath[256]; | ||
| strcpy(inPath, devPathWrite); | ||
| strcat(inPath, "/ep2"); | ||
|
|
||
| int outfd = open(outPath, O_RDWR); | ||
| int infd = open(inPath, O_RDWR); | ||
|
|
There was a problem hiding this comment.
c++ std::string instead
+add a special case where devPathREAD is supplied as well and then don't do any "auto /ep1&2 assumptions" but just directly open outPath & open inPath and use that as FD's
src/pc/protocols/usb_host_ep.cpp
Outdated
| int usbEpPlatformClose(void *fdKey) | ||
| { | ||
| int error; | ||
|
|
||
| #if defined(_WIN32) | ||
| return X_LINK_ERROR; | ||
| #else | ||
| if (usbFdRead != -1){ | ||
| close(usbFdRead); | ||
| usbFdRead = -1; | ||
| } | ||
|
|
||
| if (usbFdWrite != -1){ | ||
| close(usbFdWrite); | ||
| usbFdWrite = -1; | ||
| } | ||
| #endif |
There was a problem hiding this comment.
These should come from fdKeys while we are working on this. Remove global static usbFdRead/Write.
You'll have to tweak static std::unordered_map<std::uintptr_t, void*> map; to take a struct instead with two FDs, default api can return still just first FD, but add API to be able to query both FDs
|
|
||
| int usb_write(libusb_device_handle *f, const void *data, size_t size) | ||
| { | ||
| int bt, ss = (int)size; |
| int usbEpPlatformClose(void *fdKey) | ||
| { | ||
| fdPair *pair; | ||
| getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Check if ret val good & pair != nullptr
| int usbEpPlatformRead(void *fdKey, void *data, int size) | ||
| { | ||
| fdPair *pair; | ||
| getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Check if ret val good & pair != nullptr
| fdPair *pair; | ||
| getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Check if ret val good & pair != nullptr
Added support for using the USB EPs from FunctionFS.