Add stringify function

This commit is contained in:
Pol Fernandez 2023-02-20 21:03:39 +01:00
parent e3492862e9
commit f34829f534

View file

@ -18,6 +18,9 @@ use embedded_io::asynch::Write;
use static_cell::StaticCell;
use {defmt_rtt as _, panic_probe as _};
use heapless::String;
macro_rules! singleton {
($val:expr) => {{
type T = impl Sized;
@ -129,7 +132,8 @@ async fn main(spawner: Spawner) {
}
};
info!("rxd {:02x}", &buf[..n]);
info!("rxd {}", asciify(&buf[..n]));
match socket.write_all(&buf[..n]).await {
Ok(()) => {}
@ -214,3 +218,7 @@ impl SpiBusWrite<u32> for MySpi {
Ok(())
}
}
fn asciify(buf: &[u8],) -> String<4096> {
buf.into_iter().map(|c| *c as char).into_iter().collect()
}