This commit is contained in:
Dario Nieuwenhuis 2023-05-02 22:45:54 +02:00
parent 374c92a4f0
commit a21a2901ac

View File

@ -154,7 +154,7 @@ async fn transmit_task(mut tx: UartTx<'static, board::Uart, board::TxDma>) {
let mut i: u8 = 0; let mut i: u8 = 0;
loop { loop {
let mut buf = [0; 256]; let mut buf = [0; 32];
let len = 1 + (rng.next_u32() as usize % buf.len()); let len = 1 + (rng.next_u32() as usize % buf.len());
for b in &mut buf[..len] { for b in &mut buf[..len] {
*b = i; *b = i;
@ -162,6 +162,8 @@ async fn transmit_task(mut tx: UartTx<'static, board::Uart, board::TxDma>) {
} }
tx.write(&buf[..len]).await.unwrap(); tx.write(&buf[..len]).await.unwrap();
info!("sent {=usize}", len);
Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await; Timer::after(Duration::from_micros((rng.next_u32() % 1000) as _)).await;
} }
} }
@ -175,7 +177,7 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, board::Uart, board::Rx
let mut i = 0; let mut i = 0;
let mut expected = 0; let mut expected = 0;
loop { loop {
let mut buf = [0; 256]; let mut buf = [0; 32];
let max_len = 1 + (rng.next_u32() as usize % buf.len()); let max_len = 1 + (rng.next_u32() as usize % buf.len());
let received = match rx.read(&mut buf[..max_len]).await { let received = match rx.read(&mut buf[..max_len]).await {
Ok(r) => r, Ok(r) => r,
@ -183,6 +185,7 @@ async fn receive_task(mut rx: RingBufferedUartRx<'static, board::Uart, board::Rx
panic!("Test fail! read error: {:?}", e); panic!("Test fail! read error: {:?}", e);
} }
}; };
info!("received {=usize}", received);
for byte in &buf[..received] { for byte in &buf[..received] {
assert_eq!(*byte, expected); assert_eq!(*byte, expected);