diff --git a/examples/rtic_bare8.rs b/examples/rtic_bare8.rs index b4b18ee4a72d728359e36c70467f4de9ba8643a0..040bfb12675fb434d9e5831d351043682027ab4f 100644 --- a/examples/rtic_bare8.rs +++ b/examples/rtic_bare8.rs @@ -11,13 +11,13 @@ use panic_rtt_target as _; -use nb::block; use stm32f4xx_hal::{ gpio::{gpioa::PA, Output, PushPull}, prelude::*, serial::{config::Config, Rx, Serial, Tx}, stm32::USART2, + nb::block, }; use rtic::app; @@ -69,17 +69,25 @@ const APP: () = { fn idle(cx: idle::Context) -> ! { let rx = cx.resources.RX; let tx = cx.resources.TX; + let mut received = 0; + let mut errors = 0; loop { match block!(rx.read()) { Ok(byte) => { rprintln!("Ok {:?}", byte); tx.write(byte).unwrap(); + received +=1; } Err(err) => { rprintln!("Error {:?}", err); + let test:u8 = 13; + tx.write(test).unwrap(); + errors +=1; } } + rprintln!("Numbers of received: {:?}", received); + rprintln!("Numbers of errors: {:?}", errors); } } }; @@ -113,31 +121,33 @@ const APP: () = { // // What do you receive in `moserial`? // -// ** your answer here ** +// I can't run moserial (Windows). But PuTTY seems to get a. // // What do you receive in the RTT terminal? // -// ** your answer here ** +// OK 97 // // Try sending: "abcd" as a single sequence, don't send the quotation marks, just abcd. // // What did you receive in `moserial`? // -// ** your answer here ** +// ad (Running PuTTY. Not moserial) // // What do you receive in the RTT terminal? // -// ** your answer here ** +// Ok 97 +// Error Overrun +// Ok 100 // // What do you believe to be the problem? // // Hint: Look at the code in `idle` what does it do? // -// ** your answer here ** +// The buffer have not been read from and has not been cleared. // // Experiment a bit, what is the max length sequence you can receive without errors? // -// ** your answer here ** +// 8 bits or 1 byte. // // Commit your answers (bare8_1) // @@ -152,11 +162,11 @@ const APP: () = { // // 3. Experiment a bit, what is the max length sequence you can receive without errors? // -// ** your answer here ** +// 1 // // How did the added tracing/instrumentation affect the behavior? // -// ** your answer here ** +// I now only receive a back. // // Commit your answer (bare8_3) // @@ -168,7 +178,7 @@ const APP: () = { // // Experiment a bit, what is the max length sequence you can receive without errors? // -// ** your answer here ** +// Now I receive "ad" again // // Commit your answer (bare8_4) //