From c1d0fa9d049aae77db35504f77369da48d107185 Mon Sep 17 00:00:00 2001 From: Priec Date: Tue, 11 Nov 2025 22:34:16 +0100 Subject: [PATCH] i can read HW uart in the terminal via info --- semestralka_1/src/bin/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/semestralka_1/src/bin/main.rs b/semestralka_1/src/bin/main.rs index 97c2a40..8602ea1 100644 --- a/semestralka_1/src/bin/main.rs +++ b/semestralka_1/src/bin/main.rs @@ -44,7 +44,7 @@ async fn main(spawner: Spawner) { // HARDWARE UART to the PC let mut cfg = Config::default(); - cfg.baudrate = 230_400; + cfg.baudrate = BAUD; static TX_BUF: StaticCell<[u8; 256]> = StaticCell::new(); static RX_BUF: StaticCell<[u8; 256]> = StaticCell::new(); let uart = BufferedUart::new( @@ -79,14 +79,19 @@ async fn main(spawner: Spawner) { // EDN OF SOFTWARE UART let mut last_yield = Instant::now(); + let mut buf = [0u8; 32]; loop { info!("tick start"); // Timer::after(Duration::from_millis(100)).await; // info!("tick end"); + let n = handle.rx.read(&mut buf).await; + if n > 0 { + info!("PC received: {:a}", &buf[..n]); + } if Instant::now().duration_since(last_yield) >= handle.yield_period { - embassy_futures::yield_now().await; + yield_now().await; last_yield = Instant::now(); }