From 33f726fadf6a04296729870650ea8e562d546585 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 11 Oct 2017 20:12:11 -0400 Subject: [PATCH] Changed wMaxPacketSize to 0x200 since the previous value was invalid. Send bytes 0x00..0xff in a loop, with '\n' being sent first. All of this (binary) data is now properly read by the host(via /dev usb-tty). --- usb/usbds/source/main.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/usb/usbds/source/main.c b/usb/usbds/source/main.c index 3a410a0..7c27dc7 100644 --- a/usb/usbds/source/main.c +++ b/usb/usbds/source/main.c @@ -28,7 +28,7 @@ Result usbds_test(u8 *tmpbuf) .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_ENDPOINT_IN, .bmAttributes = USB_TRANSFER_TYPE_BULK, - .wMaxPacketSize = 0x40, + .wMaxPacketSize = 0x200, }; struct usb_endpoint_descriptor endpoint_descriptor_out = { @@ -36,7 +36,7 @@ Result usbds_test(u8 *tmpbuf) .bDescriptorType = USB_DT_ENDPOINT, .bEndpointAddress = USB_ENDPOINT_OUT, .bmAttributes = USB_TRANSFER_TYPE_BULK, - .wMaxPacketSize = 0x40, + .wMaxPacketSize = 0x200, }; //Setup interface. @@ -57,19 +57,33 @@ Result usbds_test(u8 *tmpbuf) ret = usbDsWaitReady(); if(R_FAILED(ret))return ret; + u32 somepos; + for(somepos=0; somepos<0x101; somepos++) + { memset(tmpbuf, 0, 0x1000); - char *strptr = "Hello World!\n"; - strncpy((char*)&tmpbuf[2], strptr, 0x1000-2); + char *strptr = "\n";//"Hello World!\n"; tmpbuf[0] = 0x11; tmpbuf[1] = 0x1; + if(somepos==0 || somepos==0x101) + { + strncpy((char*)&tmpbuf[2], strptr, 0x1000-2); + ret = usbDsEndpoint_PostBufferAsync(endpoint_in, tmpbuf, 2+strlen(strptr), NULL); + } + else + { + tmpbuf[2] = somepos-1; + ret = usbDsEndpoint_PostBufferAsync(endpoint_in, tmpbuf, 2+1, NULL); + } //Start a device->host transfer. - ret = usbDsEndpoint_PostBufferAsync(endpoint_in, tmpbuf, 2+strlen(strptr), NULL); + //ret = usbDsEndpoint_PostBufferAsync(endpoint_in, tmpbuf, 2+1, NULL); + //ret = usbDsEndpoint_PostBufferAsync(endpoint_in, tmpbuf, 2+strlen(strptr), NULL); if(R_FAILED(ret))return ret; //Wait for the transfer to finish. svcWaitSynchronization(&tmpindex, &endpoint_in->CompletionEvent, 1, U64_MAX); svcClearEvent(endpoint_in->CompletionEvent); + } //Start a host->device transfer. ret = usbDsEndpoint_PostBufferAsync(endpoint_out, tmpbuf, 0x200, NULL);