mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-11-26 12:12:02 +00:00
Some more USB fixes.
This commit is contained in:
parent
1f05a39560
commit
47297daf3a
2 changed files with 9 additions and 11 deletions
|
@ -149,7 +149,7 @@ static int read_thread_func(void *arg)
|
|||
return -1;
|
||||
}
|
||||
|
||||
u8 *buf = usbAllocatePageAlignedBuffer(TEST_BUF_SIZE);
|
||||
u8 *buf = malloc(TEST_BUF_SIZE);
|
||||
if (!buf)
|
||||
{
|
||||
shared_data->read_error = true;
|
||||
|
@ -296,7 +296,7 @@ int main(int argc, char *argv[])
|
|||
.id_offset = 0
|
||||
};
|
||||
|
||||
buf = malloc(TEST_BUF_SIZE);
|
||||
buf = usbAllocatePageAlignedBuffer(TEST_BUF_SIZE);
|
||||
if (!buf)
|
||||
{
|
||||
consolePrint("buf failed\n");
|
||||
|
|
16
source/usb.c
16
source/usb.c
|
@ -28,6 +28,8 @@
|
|||
|
||||
#define USB_CMD_HEADER_MAGIC 0x4E584454 /* "NXDT" */
|
||||
|
||||
#define USB_SESSION_START_TIMEOUT 10 /* 10 seconds */
|
||||
|
||||
#define USB_TRANSFER_ALIGNMENT 0x1000 /* 4 KiB */
|
||||
#define USB_TRANSFER_TIMEOUT 5 /* 5 seconds */
|
||||
|
||||
|
@ -188,15 +190,10 @@ bool usbStartSession(void)
|
|||
time_t start = time(NULL);
|
||||
time_t now = start;
|
||||
|
||||
while((now - start) < USB_TRANSFER_TIMEOUT)
|
||||
while((now - start) < USB_SESSION_START_TIMEOUT)
|
||||
{
|
||||
if (usbIsHostAvailable())
|
||||
{
|
||||
/* Once the console has been connected to a host device, there's no need to keep running this loop */
|
||||
/* usbTransferData() implements its own timeout */
|
||||
ret = g_usbSessionStarted = _usbStartSession();
|
||||
break;
|
||||
}
|
||||
ret = g_usbSessionStarted = (usbIsHostAvailable() && _usbStartSession());
|
||||
if (ret) break;
|
||||
|
||||
utilsSleep(1);
|
||||
now = time(NULL);
|
||||
|
@ -950,6 +947,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
if (R_FAILED(rc))
|
||||
{
|
||||
LOGFILE("USB transfer timed out! (0x%08X)", rc);
|
||||
usbDsEndpoint_Cancel(endpoint);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -963,7 +961,7 @@ static bool usbTransferData(void *buf, u64 size, UsbDsEndpoint *endpoint)
|
|||
rc = usbDsParseReportData(&report_data, urb_id, NULL, &transferred_size);
|
||||
if (R_FAILED(rc))
|
||||
{
|
||||
LOGFILE("usbDsEndpoint_GetReportData failed! (0x%08X)", rc);
|
||||
LOGFILE("usbDsParseReportData failed! (0x%08X)", rc);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue