Merge pull request #191 from ferrous-systems/correct-logging

Correct logging
This commit is contained in:
Tanks Transfeld 2022-12-07 13:16:04 +01:00 committed by GitHub
commit 8e33ee685c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 40 deletions

View File

@ -12,18 +12,18 @@ usb2 = "0.0.1"
[dependencies]
consts = { path = "../common/consts" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.1"
cortex-m-rtic = "1.0.0"
defmt = "0.3.0"
defmt-rtt = "0.3.1"
cortex-m = "0.7.6"
cortex-m-rt = "0.7.2"
cortex-m-rtic = "1.1.3"
defmt = "0.3.2"
defmt-rtt = "0.3.2"
dk = { path = "../../boards/dk", features = ["advanced"] }
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
usb = { path = "../common/usb" }
usb2 = "0.0.1"
[dependencies.heapless]
version = "0.7.9"
version = "0.7.16"
features = ["defmt-impl"]
# optimize code in both profiles

View File

@ -6,13 +6,13 @@ name = "apps"
version = "0.0.0"
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.1"
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
dk = { path = "../../boards/dk", features = ["beginner"] }
heapless = "0.7.9"
heapless = "0.7.16"
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
defmt = "0.3.0"
defmt-rtt = "0.3.1"
defmt = "0.3.2"
defmt-rtt = "0.3.2"
# optimize code in both profiles
[profile.dev]
@ -34,12 +34,11 @@ opt-level = 3
overflow-checks = false
[features]
# set defmt logging levels here
default = [
"defmt-default",
# "dependency-a/defmt-trace",
]
default = [
"other-feature"
]
other-feature = []
# do NOT modify these features
defmt-default = []
defmt-trace = []

View File

@ -20,7 +20,7 @@ fn main() -> ! {
radio.set_channel(Channel::_25);
// capacity (128) should be large enough for the ASCII range
let mut dict = LinearMap::<u8, u8, 128>::new();
let dict = LinearMap::<u8, u8, 128>::new();
let mut packet = Packet::new();
// TODO do the whole ASCII range [0, 127]

View File

@ -6,23 +6,22 @@ name = "dk"
version = "0.0.0"
[dependencies]
cortex-m = "0.7.3"
cortex-m-rt = "0.7.1"
embedded-hal = "0.2.6"
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
embedded-hal = "0.2.7"
hal = { package = "nrf52840-hal", version = "0.14.0" }
panic-probe = { version = "0.3.0", features = ["print-defmt"] }
defmt = "0.3.0"
defmt-rtt = "0.3.1"
defmt = "0.3.2"
defmt-rtt = "0.3.2"
[features]
advanced = []
beginner = []
# set defmt logging levels here
default = [
"defmt-info",
# "dependency-a/defmt-trace",
"other-feature"
]
other-feature = []
# do NOT modify these features
defmt-default = []

View File

@ -6,16 +6,16 @@ name = "panic-log"
version = "0.0.0"
[dependencies]
cortex-m = "0.6.4"
defmt = "0.2.1"
cortex-m = "0.7.6"
defmt = "0.3.2"
[features]
# set defmt logging levels here
default = [
"defmt-debug",
# "dependency-a/defmt-trace",
"other-feature"
]
other-feature = []
# do NOT modify these features
defmt-default = []

View File

@ -37,12 +37,13 @@ stack backtrace:
In `no_std` programs the behavior of panic is defined using the `#[panic_handler]` attribute. In the example, the *panic handler* is defined in the `panic_log` crate but we can also implement it manually:
✅ Comment out the `panic_probe` import and add the following function to the example:
✅ Comment out the `use apps as _;` import and add the following function to the example:
``` rust
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
defmt::panic!("{}", info);
defmt::error!("{}", defmt::Debug2Format(info));
asm::udf();
}
```

View File

@ -28,15 +28,10 @@ $ cargo doc -p dk --open
✅ Check the API docs of the `Led` abstraction. Change the `led` program, so that the bottom two LEDs are turned on, and the top two are turned off.
🔎 If you want to see logs from Led API of the `dk` Hardware Abstraction Layer, go to `boards/dk/Cargo.toml` and change the log level of the `dk` crate:
🔎 If you want to see logs from Led API of the `dk` Hardware Abstraction Layer, flash the dk with the following environment variable:
```diff
# set defmt logging levels here
default = [
- "defmt-debug",
+ "defmt-trace",
# "dependency-a/defmt-trace",
]
```console
$ DEFMT_LOG=trace cargo run --bin led
```
Among the logs you'll find the line "I/O pins have been configured for digital output". At this point the electrical pins of the nRF52840 microcontroller have been configured to drive the 4 LEDs on the board.