common/usb/serial: add some trace logging.
This commit is contained in:
parent
24b6478a7c
commit
88d9599a63
1 changed files with 26 additions and 6 deletions
|
@ -167,6 +167,7 @@ impl<'bus, 'a, B: UsbBus> AsyncWrite for UsbSerial<'bus, 'a, B> {
|
||||||
|
|
||||||
let write_buf = this.write_buf.push_buf();
|
let write_buf = this.write_buf.push_buf();
|
||||||
if write_buf.is_empty() {
|
if write_buf.is_empty() {
|
||||||
|
trace!("buf full, registering waker");
|
||||||
this.write_waker.register(cx.waker());
|
this.write_waker.register(cx.waker());
|
||||||
return Poll::Pending;
|
return Poll::Pending;
|
||||||
}
|
}
|
||||||
|
@ -244,10 +245,18 @@ impl<'bus, 'a, B: UsbBus> UsbSerial<'bus, 'a, B> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if !buf.is_empty() {
|
if !buf.is_empty() {
|
||||||
|
trace!("writing packet len {}", buf.len());
|
||||||
let count = match self.inner.write_packet(buf) {
|
let count = match self.inner.write_packet(buf) {
|
||||||
Ok(c) => c,
|
Ok(c) => {
|
||||||
Err(UsbError::WouldBlock) => 0,
|
trace!("write packet: OK {}", c);
|
||||||
|
c
|
||||||
|
}
|
||||||
|
Err(UsbError::WouldBlock) => {
|
||||||
|
trace!("write packet: WouldBlock");
|
||||||
|
0
|
||||||
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
trace!("write packet: error");
|
||||||
self.write_error = true;
|
self.write_error = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -260,11 +269,20 @@ impl<'bus, 'a, B: UsbBus> UsbSerial<'bus, 'a, B> {
|
||||||
}
|
}
|
||||||
self.write_buf.pop(count);
|
self.write_buf.pop(count);
|
||||||
} else if full_size_packets > 0 {
|
} else if full_size_packets > 0 {
|
||||||
if let Err(e) = self.inner.write_packet(&[]) {
|
trace!("writing empty packet");
|
||||||
if !matches!(e, UsbError::WouldBlock) {
|
match self.inner.write_packet(&[]) {
|
||||||
self.write_error = true;
|
Ok(_) => {
|
||||||
|
trace!("write empty packet: OK");
|
||||||
|
}
|
||||||
|
Err(UsbError::WouldBlock) => {
|
||||||
|
trace!("write empty packet: WouldBlock");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Err(_) => {
|
||||||
|
trace!("write empty packet: Error");
|
||||||
|
self.write_error = true;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
self.write_state = WriteState::Idle;
|
self.write_state = WriteState::Idle;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +305,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn endpoint_in_complete(&mut self, addr: EndpointAddress) {
|
fn endpoint_in_complete(&mut self, addr: EndpointAddress) {
|
||||||
|
trace!("DONE endpoint_in_complete");
|
||||||
if addr == self.inner.write_ep_address() {
|
if addr == self.inner.write_ep_address() {
|
||||||
|
trace!("DONE writing packet, waking");
|
||||||
self.write_waker.wake();
|
self.write_waker.wake();
|
||||||
|
|
||||||
self.flush_write();
|
self.flush_write();
|
||||||
|
|
Loading…
Reference in a new issue