Expose error

This commit is contained in:
hodasemi 2024-03-11 08:30:44 +01:00
parent 6b9fd377e4
commit 9968ada7a0

View file

@ -12,6 +12,7 @@ use embassy_rp::peripherals::USB;
use embassy_rp::usb::{Driver, InterruptHandler}; use embassy_rp::usb::{Driver, InterruptHandler};
use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; use embassy_usb::class::cdc_acm::{CdcAcmClass, State};
pub use embassy_usb::driver::EndpointError;
use embassy_usb::{Builder, Config, UsbDevice}; use embassy_usb::{Builder, Config, UsbDevice};
pub use serial_config::SerialConfig; pub use serial_config::SerialConfig;
@ -93,11 +94,11 @@ impl Serial<'static> {
} }
} }
pub async fn send_msg(&mut self, s: &str) { pub async fn send_msg(&mut self, s: &str) -> Result<(), EndpointError> {
self.class.write_packet(s.as_bytes()).await.unwrap_or(()); self.class.write_packet(s.as_bytes()).await
} }
pub async fn send_number<T, I>(&mut self, i: T, base: I) pub async fn send_number<T, I>(&mut self, i: T, base: I) -> Result<(), EndpointError>
where where
T: NumToA<I>, T: NumToA<I>,
{ {
@ -105,6 +106,6 @@ impl Serial<'static> {
let s = i.numtoa_str(base, &mut buf); let s = i.numtoa_str(base, &mut buf);
self.send_msg(s).await; self.send_msg(s).await
} }
} }