mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +02:00
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).
This commit is contained in:
parent
a23a01c7bd
commit
33f726fadf
@ -28,7 +28,7 @@ Result usbds_test(u8 *tmpbuf)
|
|||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
.bEndpointAddress = USB_ENDPOINT_IN,
|
.bEndpointAddress = USB_ENDPOINT_IN,
|
||||||
.bmAttributes = USB_TRANSFER_TYPE_BULK,
|
.bmAttributes = USB_TRANSFER_TYPE_BULK,
|
||||||
.wMaxPacketSize = 0x40,
|
.wMaxPacketSize = 0x200,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_endpoint_descriptor endpoint_descriptor_out = {
|
struct usb_endpoint_descriptor endpoint_descriptor_out = {
|
||||||
@ -36,7 +36,7 @@ Result usbds_test(u8 *tmpbuf)
|
|||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
.bEndpointAddress = USB_ENDPOINT_OUT,
|
.bEndpointAddress = USB_ENDPOINT_OUT,
|
||||||
.bmAttributes = USB_TRANSFER_TYPE_BULK,
|
.bmAttributes = USB_TRANSFER_TYPE_BULK,
|
||||||
.wMaxPacketSize = 0x40,
|
.wMaxPacketSize = 0x200,
|
||||||
};
|
};
|
||||||
|
|
||||||
//Setup interface.
|
//Setup interface.
|
||||||
@ -57,19 +57,33 @@ Result usbds_test(u8 *tmpbuf)
|
|||||||
ret = usbDsWaitReady();
|
ret = usbDsWaitReady();
|
||||||
if(R_FAILED(ret))return ret;
|
if(R_FAILED(ret))return ret;
|
||||||
|
|
||||||
|
u32 somepos;
|
||||||
|
for(somepos=0; somepos<0x101; somepos++)
|
||||||
|
{
|
||||||
memset(tmpbuf, 0, 0x1000);
|
memset(tmpbuf, 0, 0x1000);
|
||||||
char *strptr = "Hello World!\n";
|
char *strptr = "\n";//"Hello World!\n";
|
||||||
strncpy((char*)&tmpbuf[2], strptr, 0x1000-2);
|
|
||||||
|
|
||||||
tmpbuf[0] = 0x11;
|
tmpbuf[0] = 0x11;
|
||||||
tmpbuf[1] = 0x1;
|
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.
|
//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;
|
if(R_FAILED(ret))return ret;
|
||||||
//Wait for the transfer to finish.
|
//Wait for the transfer to finish.
|
||||||
svcWaitSynchronization(&tmpindex, &endpoint_in->CompletionEvent, 1, U64_MAX);
|
svcWaitSynchronization(&tmpindex, &endpoint_in->CompletionEvent, 1, U64_MAX);
|
||||||
svcClearEvent(endpoint_in->CompletionEvent);
|
svcClearEvent(endpoint_in->CompletionEvent);
|
||||||
|
}
|
||||||
|
|
||||||
//Start a host->device transfer.
|
//Start a host->device transfer.
|
||||||
ret = usbDsEndpoint_PostBufferAsync(endpoint_out, tmpbuf, 0x200, NULL);
|
ret = usbDsEndpoint_PostBufferAsync(endpoint_out, tmpbuf, 0x200, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user