-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Develop sever usb #70
base: develop_server
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be USB_VSC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -938,6 +939,8 @@ int usb_read(libusb_device_handle *f, void *data, size_t size) | |||
|
|||
int usb_write(libusb_device_handle *f, const void *data, size_t size) | |||
{ | |||
int bt, ss = (int)size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Required?
} | ||
|
||
|
||
int usbEpPlatformClose(void *fdKey) | ||
{ | ||
fdPair *pair; | ||
getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if ret val good & pair != nullptr
|
||
return EXIT_SUCCESS; | ||
} | ||
|
||
int usbEpPlatformRead(void *fdKey, void *data, int size) | ||
{ | ||
fdPair *pair; | ||
getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if ret val good & pair != nullptr
fdPair *pair; | ||
getPlatformDeviceFdFromKey(fdKey, (void**)&pair); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if ret val good & pair != nullptr
Added support for using the USB EPs from FunctionFS.