knurling-rs / defmt

Efficient, deferred formatting for logging on embedded systems
https://defmt.ferrous-systems.com/
Apache License 2.0
848 stars 77 forks source link

u16 can not be used as type specifier #882

Closed hvraven closed 4 hours ago

hvraven commented 4 hours ago

I tried to send an u16 slice or array using {=[u16]} (or {=[u16;3]} as documented in the defmt book. However I got a compiler error complaining about [u16] being an invalid type specifier. Same problem for u32. u8 compiles and runs without issues. Reduced test case below. I am using defmt 0.3.8 with rust/cargo 1.82.0

use defmt::*;

fn main() {
    let arr :[u16; 3] = [0,1,2];

    debug!("{=[u16]}", arr);

}
hvraven commented 4 hours ago

Sorry for being a bit quick, it works when using [?] instead of the concrete type. A bit weird that [u8] is explicitly supported, while the other numbers are not.

jonathanpallant commented 46 minutes ago

=[u8] is supported as a special case because people really often want to log byte arrays on embedded systems (network packets, disk sectors, HID frames, etc). =[u16], etc, is not supported at this time.