fix: 🐛 修复打印logo异常

This commit is contained in:
Alvin Young 2024-11-26 12:22:07 +00:00
parent f263ea3a34
commit 4d4f08e95e
2 changed files with 14 additions and 4 deletions

View File

@ -33,7 +33,16 @@ unsigned short userShellWrite(char *data, unsigned short len)
// return uart_write_bytes(SHELL_UART, (const char *)data, len);
// return cdc_usb_writ_bytes(data, len);
unsigned short ret = 0;
ret = cdc_usb_writ_bytes(data, len);
int idx = 0, n = 0;
while (idx < len) {
n = len - idx >= 64 ? 64 : len - idx;
ret = cdc_usb_writ_bytes(data + idx, n);
while (!ret) {
vTaskDelay(10);
ret = cdc_usb_writ_bytes(data + idx, n);
}
idx += n;
}
// cdc_printf("write need : %d, get %d\r\n", len, ret);
// cdc_printf("%s", data);
return len;

View File

@ -209,14 +209,15 @@ signed short cdc_usb_writ_bytes(char* data, unsigned short len)
signed short n;
char aBuffer[64] = { 0 };
n = len >= 64 ? 64 : len;
aBuffer[63] = '\n';
int ret = -1;
// aBuffer[63] = '\n';
strncpy(aBuffer, data, n);
if (dtr_enable) {
usbd_ep_write(CDC_IN_EP, (uint8_t*)data, n, NULL);
ret = usbd_ep_write(CDC_IN_EP, (uint8_t*)data, n, NULL);
}
return len;
return ret == 0 ? len : 0;
}
int cdc_printf(const char *fmt, ...) {