Add stringify function
This commit is contained in:
parent
e3492862e9
commit
f34829f534
@ -18,6 +18,9 @@ use embedded_io::asynch::Write;
|
|||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
use heapless::String;
|
||||||
|
|
||||||
|
|
||||||
macro_rules! singleton {
|
macro_rules! singleton {
|
||||||
($val:expr) => {{
|
($val:expr) => {{
|
||||||
type T = impl Sized;
|
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 {
|
match socket.write_all(&buf[..n]).await {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
@ -214,3 +218,7 @@ impl SpiBusWrite<u32> for MySpi {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn asciify(buf: &[u8],) -> String<4096> {
|
||||||
|
buf.into_iter().map(|c| *c as char).into_iter().collect()
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user