Skip to content

panic in receive #27

@flippette

Description

@flippette

I'm using dw3000-ng in sync mode with this code, just listening for messages:

    loop {
        let mut recv = dwm.receive(dwm_config)?;
        let mut buf = [0_u8; 8192];

        loop {
            match recv.r_wait(&mut buf) {
                Ok(_) => break,
                Err(nb::Error::WouldBlock) => {
                    info!("DW3000 receive pending...");
                    irq.wait_for_any_edge().await;
                }
                Err(nb::Error::Other(err)) =>
                    break error!(
                        "DW3000 receive error: {}",
                        err
                    ),
            }
        }

        dwm = recv
            .finish_receiving()
            .unwrap();
    }

Running this code on an ESP32-C3 produces a panic at dw3000-ng/src/hl/receiving.rs:324:47, on this line:

        buffer[..len].copy_from_slice(&rx_buffer.data()[..len]);

len seems to come from rx_finfo, so I've tried printing out the relevant variables:

        let len = rx_finfo.rxflen() as usize;
        defmt::info!("rx_finfo = {}", rx_finfo);
        defmt::info!("rxflen = {}", len);
        defmt::info!(
            "rx_buffer = {}",
            rx_buffer.data().len()
        );

Which produces the following logs:

0.178921 INFO rx_finfo = 0x00deca03
0.179591 INFO rxflen = 515
0.179652 INFO rx_buffer = 127

Am I doing something wrong? The driver documentation isn't particularly great.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions