mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
chunk data to the USB subsystem
the chunks match the size of the application buffer, eliminating the possibility of an overrun (of the buffer at least) there is a possibility still i think of overrunning USB itself but i think the CPU can't produce data fast enough to actually do that.
This commit is contained in:
parent
e98ffaadfd
commit
37ff052b34
1 changed files with 4 additions and 14 deletions
|
|
@ -745,20 +745,10 @@ pub(crate) fn main_hw() -> ! {
|
|||
let buffer = unsafe { Buffer::from_memory_message(mem_msg) };
|
||||
match buffer.to_original::<api::UsbString, _>() {
|
||||
Ok(usb_send) => {
|
||||
// this is implemented as a "blocking write": the routine will block until the
|
||||
// data has all been written.
|
||||
let send_data = usb_send.s.as_bytes();
|
||||
let to_send = usb_send.s.len();
|
||||
let mut sent = 0;
|
||||
while sent < to_send {
|
||||
match cu.serial_port.write(&send_data[sent..to_send]) {
|
||||
Ok(written) => {
|
||||
sent += written;
|
||||
}
|
||||
Err(_) => {
|
||||
// just drop characters
|
||||
}
|
||||
}
|
||||
for chunk in
|
||||
usb_send.s.as_bytes().chunks(bao1x_hal::usb::driver::CRG_UDC_APP_BUFSIZE)
|
||||
{
|
||||
cu.serial_port.write(&chunk).ok();
|
||||
cu.serial_port.flush().ok(); // just drop characters on error
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue