gauteh / defmt-serial

Log defmt messages over the serial port.
24 stars 7 forks source link

Marker trait to allow blocking API #7

Closed adejewski closed 11 months ago

adejewski commented 11 months ago

Hi @gauteh ,

I got a question. I am working with STM32WL and I am using new embedded_hal v2. According to defmt-serial you need to use blocking API, but the embedded_hal in this version does not provide it. How to implement this marker trait Default to enable it?

The code blow shows, how I tried to use it:

  let uart: LpUart<pins::A3, pins::A2> = cortex_m::interrupt::free(|cs| {
        LpUart::new(dp.LPUART, 115_200, uart::Clk::Hsi16, &mut dp.RCC)
            .enable_rx(gpioa.a3, cs)
            .enable_tx(gpioa.a2, cs)
    });

    defmt_serial::defmt_serial(uart);
gauteh commented 11 months ago

Here is how I did it for ambiq hal: https://github.com/gauteh/ambiq-rs/commit/a9bdbb5c7cfae0cece923872a29e1421a9b03696

impl hal::blocking::serial::write::Default<u8> for Uart0 {}

adejewski commented 11 months ago

Anyway, used your code as an example and implemented my own version that accepts non-blocking version of write. It works as expected :) Thanks

gauteh commented 11 months ago

By the way, issue #1 is also related to STM32WL. Maybe this works now?

adejewski commented 11 months ago

Not sure what the other issue is about, but for me the biggest problem was not the code, but how to read the data. It took me some time before I realized you need this defmt-print application to decode the log. I know that you are mentioning it in readme, but might be also worth adding there a full command how to redirect logs using socat to defmt-print.

gauteh commented 11 months ago

Yeah, agreed. Just hasn't gotten around to it. Feel free to add some suggestion.

adejewski commented 11 months ago

Will create a PR to the readme file to explain how to decode the logs on linux system, give me a couple of days