gauteh / defmt-serial

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

defmt-serial is currently not compatible with rp_pico/rp2040_hal #13

Open gbin opened 7 months ago

gbin commented 7 months ago

I believe the other issue kind of mention that we would need to migrate this project to embedded-hal-1.0+ but this is more for people like me, trying on their own project spending hours in cargo tree to spot a potential incompatible dependency.

The pico example from this project doesn't compile:

  Compiling pico-defmt-serial v0.1.0 (/home/gbin/projects/defmt-serial/example-pi-pico)
error[E0277]: the trait bound `UartPeripheral<rp_pico::rp2040_hal::uart::Enabled, UART0, (rp_pico::rp2040_hal::gpio::Pin<Gpio0, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>, rp_pico::rp2040_hal::gpio::Pin<Gpio1, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>)>: embedded_hal::blocking::serial::write::Default<u8>` is not satisfied
  --> src/main.rs:84:32
   |
84 |     defmt_serial::defmt_serial(SERIAL.init(uart));
   |     -------------------------- ^^^^^^^^^^^^^^^^^ the trait `embedded_hal::blocking::serial::write::Default<u8>` is not implemented for `UartPeripheral<rp_pico::rp2040_hal::uart::Enabled, UART0, (rp_pico::rp2040_hal::gpio::Pin<Gpio0, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>, rp_pico::rp2040_hal::gpio::Pin<Gpio1, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>)>`, which is required by `UartPeripheral<rp_pico::rp2040_hal::uart::Enabled, UART0, (rp_pico::rp2040_hal::gpio::Pin<Gpio0, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>, rp_pico::rp2040_hal::gpio::Pin<Gpio1, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>)>: EraseWrite`
   |     |
   |     required by a bound introduced by this call
   |
   = note: required for `UartPeripheral<rp_pico::rp2040_hal::uart::Enabled, UART0, (rp_pico::rp2040_hal::gpio::Pin<Gpio0, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>, rp_pico::rp2040_hal::gpio::Pin<Gpio1, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>)>` to implement `_embedded_hal_blocking_serial_Write<u8>`
   = note: required for `UartPeripheral<rp_pico::rp2040_hal::uart::Enabled, UART0, (rp_pico::rp2040_hal::gpio::Pin<Gpio0, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>, rp_pico::rp2040_hal::gpio::Pin<Gpio1, rp_pico::rp2040_hal::gpio::Function<rp_pico::rp2040_hal::gpio::Uart>>)>` to implement `EraseWrite`
note: required by a bound in `defmt_serial`
  --> /home/gbin/projects/defmt-serial/src/lib.rs:86:24
   |
86 | pub fn defmt_serial<T: EraseWrite>(serial: &'static mut T) {
   |                        ^^^^^^^^^^ required by this bound in `defmt_serial`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `pico-defmt-serial` (bin "pico-defmt-serial") due to 1 previous error

If anyone is aware of a workaround I would be very interested. Thanks.

gauteh commented 7 months ago

Maybe the changes here can make it work: https://github.com/gauteh/defmt-serial/pull/14

gauteh commented 5 months ago

The example now needs to be updated to eh-1.