mirror of
https://github.com/palera1n/palera1n.git
synced 2026-10-24 02:59:49 +02:00
fix: redo issue_pongo_command, add error msg
This commit is contained in:
2 files changed
+12
-16
No files matched your search
@@ -67,6 +67,7 @@ const char* stage_to_string(int stage)
|
|||||||
case STAGE_YOLODFU: return "Booting PongoOS...";
|
case STAGE_YOLODFU: return "Booting PongoOS...";
|
||||||
case STAGE_PONGO: return "Booting...";
|
case STAGE_PONGO: return "Booting...";
|
||||||
case STAGE_DONE: return "Done!";
|
case STAGE_DONE: return "Done!";
|
||||||
|
case STAGE_ERROR: return "Error!";
|
||||||
default: return "Waiting...";
|
default: return "Waiting...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,7 @@ int stage_to_progress(int stage)
|
|||||||
case STAGE_YOLODFU: return 60;
|
case STAGE_YOLODFU: return 60;
|
||||||
case STAGE_PONGO: return 70;
|
case STAGE_PONGO: return 70;
|
||||||
case STAGE_DONE: return 100;
|
case STAGE_DONE: return 100;
|
||||||
|
case STAGE_ERROR: return 99;
|
||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-16
@@ -62,9 +62,7 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char
|
|||||||
if (command != NULL) {
|
if (command != NULL) {
|
||||||
size_t len = strlen(command);
|
size_t len = strlen(command);
|
||||||
|
|
||||||
// unlikely to happen, unless we add support for pongoterm
|
if (len >= CMD_LENGTH_MAX) {
|
||||||
// TODO: discuss on adding a pongoterm
|
|
||||||
if (len > CMD_LENGTH_MAX) {
|
|
||||||
LOG_ERROR("Pongo command too long: %s", command);
|
LOG_ERROR("Pongo command too long: %s", command);
|
||||||
result.ret = 1;
|
result.ret = 1;
|
||||||
return result;
|
return result;
|
||||||
@@ -86,12 +84,8 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char
|
|||||||
result = send_interface_control_request(handle, 0x21, 3, 0, 0, command_buf, len);
|
result = send_interface_control_request(handle, 0x21, 3, 0, 0, command_buf, len);
|
||||||
if (result.ret != USB_TRANSFER_OK) goto result;
|
if (result.ret != USB_TRANSFER_OK) goto result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// return early if the command is boot, we dont care about results
|
|
||||||
if (strncmp(command,"boot",4) == 0) goto result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: does this work correctly?
|
|
||||||
while (in_progress) {
|
while (in_progress) {
|
||||||
#if WITH_CIDERRAIN
|
#if WITH_CIDERRAIN
|
||||||
result = usb_ctrl_transfer(handle, 0xA1, 2, 0, 0, &in_progress, sizeof(in_progress));
|
result = usb_ctrl_transfer(handle, 0xA1, 2, 0, 0, &in_progress, sizeof(in_progress));
|
||||||
@@ -101,26 +95,26 @@ p1_transfer_ret_t issue_pongo_command(const p1_usb_handle_t *handle, const char
|
|||||||
if (result.ret != USB_TRANSFER_OK) goto result;
|
if (result.ret != USB_TRANSFER_OK) goto result;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (in_progress == 0) break;
|
if (!in_progress) break;
|
||||||
|
if (outpos > 0x1000) {
|
||||||
if (outpos + 0x1000 >= sizeof(stdout_buf)) {
|
memmove(stdout_buf, stdout_buf + outpos - 0x1000, 0x1000);
|
||||||
memmove(stdout_buf, stdout_buf + 0x1000, sizeof(stdout_buf) - 0x1000);
|
outpos = 0x1000;
|
||||||
outpos -= 0x1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
outlen = 0;
|
||||||
#if WITH_CIDERRAIN
|
#if WITH_CIDERRAIN
|
||||||
result = usb_ctrl_transfer(handle, 0xA1, 1, 0, 0, stdout_buf + outpos, 0x1000);
|
result = usb_ctrl_transfer(handle, 0xA1, 1, 0, 0, (uint8_t *)(stdout_buf + outpos), 0x1000);
|
||||||
if (result.ret != kUSBResponseSuccess) goto result;
|
if (result.ret != kUSBResponseSuccess) goto result;
|
||||||
|
outlen = result.wLenDone;
|
||||||
#else
|
#else
|
||||||
result = send_interface_control_request(handle, 0xA1, 1, 0, 0, stdout_buf + outpos, 0x1000);
|
result = send_interface_control_request(handle, 0xA1, 1, 0, 0, stdout_buf + outpos, 0x1000);
|
||||||
if (result.ret != USB_TRANSFER_OK) goto result;
|
if (result.ret != USB_TRANSFER_OK) goto result;
|
||||||
|
outlen = result.sz;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
outlen = 0x1000;
|
|
||||||
outpos += outlen;
|
outpos += outlen;
|
||||||
}
|
}
|
||||||
|
|
||||||
result:
|
result:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user