Skip to content

Commit d0c6f47

Browse files
examples: ieee802154: add debug prints
1 parent c477d9a commit d0c6f47

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

examples/ieee802154_raw.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
#![no_main]
1313
#![no_std]
14+
use core::fmt::Write;
1415
use libtock::console::Console;
1516
use libtock::ieee802154::{Ieee802154, RxOperator as _, RxRingBuffer, RxSingleBufferOperator};
1617
use libtock::runtime::{set_main, stack_size};

examples/ieee802154_rx_raw.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![no_main]
1414
#![no_std]
15-
use core::fmt::Write as _;
15+
use core::fmt::Write;
1616
use libtock::console::Console;
1717
use libtock::ieee802154::{Ieee802154, RxOperator as _, RxRingBuffer, RxSingleBufferOperator};
1818
use libtock::runtime::{set_main, stack_size};
@@ -28,18 +28,41 @@ fn main() {
2828
let tx_power: i8 = 4;
2929
let channel: u8 = 11;
3030

31+
writeln!(Console::writer(), "Configuring IEEE 802.15.4 radio...\n").unwrap();
32+
3133
Ieee802154::set_pan(pan);
34+
writeln!(Console::writer(), "Set PAN to {:#06x}\n", pan).unwrap();
35+
3236
Ieee802154::set_address_short(addr_short);
37+
writeln!(
38+
Console::writer(),
39+
"Set short address to {:#06x}\n",
40+
addr_short
41+
)
42+
.unwrap();
43+
3344
Ieee802154::set_address_long(addr_long);
45+
writeln!(
46+
Console::writer(),
47+
"Set long address to {:#018x}\n",
48+
addr_long
49+
)
50+
.unwrap();
51+
3452
Ieee802154::set_tx_power(tx_power).unwrap();
53+
writeln!(Console::writer(), "Set TX power to {}\n", tx_power).unwrap();
54+
3555
Ieee802154::set_channel(channel).unwrap();
56+
writeln!(Console::writer(), "Set channel to {}\n", channel).unwrap();
3657

3758
// Don't forget to commit the config!
3859
Ieee802154::commit_config();
60+
writeln!(Console::writer(), "Committed radio configuration!\n").unwrap();
3961

4062
// Turn the radio on
4163
Ieee802154::radio_on().unwrap();
4264
assert!(Ieee802154::is_on());
65+
writeln!(Console::writer(), "Radio is on!\n").unwrap();
4366

4467
let mut buf = RxRingBuffer::<2>::new();
4568
let mut operator = RxSingleBufferOperator::new(&mut buf);

examples/ieee802154_rx_tx_raw.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
1414
#![no_main]
1515
#![no_std]
16-
use core::fmt::Write as _;
16+
use core::fmt::Write;
1717
use libtock::alarm::{Alarm, Milliseconds};
1818
use libtock::console::Console;
1919
use libtock::ieee802154::{Ieee802154, RxOperator as _, RxRingBuffer, RxSingleBufferOperator};
@@ -30,18 +30,41 @@ fn main() {
3030
let tx_power: i8 = 4;
3131
let channel: u8 = 11;
3232

33+
writeln!(Console::writer(), "Configuring IEEE 802.15.4 radio...\n").unwrap();
34+
3335
Ieee802154::set_pan(pan);
36+
writeln!(Console::writer(), "Set PAN to {:#06x}\n", pan).unwrap();
37+
3438
Ieee802154::set_address_short(addr_short);
39+
writeln!(
40+
Console::writer(),
41+
"Set short address to {:#06x}\n",
42+
addr_short
43+
)
44+
.unwrap();
45+
3546
Ieee802154::set_address_long(addr_long);
47+
writeln!(
48+
Console::writer(),
49+
"Set long address to {:#018x}\n",
50+
addr_long
51+
)
52+
.unwrap();
53+
3654
Ieee802154::set_tx_power(tx_power).unwrap();
55+
writeln!(Console::writer(), "Set TX power to {}\n", tx_power).unwrap();
56+
3757
Ieee802154::set_channel(channel).unwrap();
58+
writeln!(Console::writer(), "Set channel to {}\n", channel).unwrap();
3859

3960
// Don't forget to commit the config!
4061
Ieee802154::commit_config();
62+
writeln!(Console::writer(), "Committed radio configuration!\n").unwrap();
4163

4264
// Turn the radio on
4365
Ieee802154::radio_on().unwrap();
4466
assert!(Ieee802154::is_on());
67+
writeln!(Console::writer(), "Radio is on!\n").unwrap();
4568

4669
let mut buf = RxRingBuffer::<2>::new();
4770
let mut operator = RxSingleBufferOperator::new(&mut buf);

examples/ieee802154_tx_raw.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
#![no_main]
1414
#![no_std]
15-
use core::fmt::Write as _;
15+
use core::fmt::Write;
1616

1717
use libtock::alarm::{Alarm, Milliseconds};
1818
use libtock::console::Console;
@@ -30,18 +30,41 @@ fn main() {
3030
let tx_power: i8 = 4;
3131
let channel: u8 = 11;
3232

33+
writeln!(Console::writer(), "Configuring IEEE 802.15.4 radio...\n").unwrap();
34+
3335
Ieee802154::set_pan(pan);
36+
writeln!(Console::writer(), "Set PAN to {:#06x}\n", pan).unwrap();
37+
3438
Ieee802154::set_address_short(addr_short);
39+
writeln!(
40+
Console::writer(),
41+
"Set short address to {:#06x}\n",
42+
addr_short
43+
)
44+
.unwrap();
45+
3546
Ieee802154::set_address_long(addr_long);
47+
writeln!(
48+
Console::writer(),
49+
"Set long address to {:#018x}\n",
50+
addr_long
51+
)
52+
.unwrap();
53+
3654
Ieee802154::set_tx_power(tx_power).unwrap();
55+
writeln!(Console::writer(), "Set TX power to {}\n", tx_power).unwrap();
56+
3757
Ieee802154::set_channel(channel).unwrap();
58+
writeln!(Console::writer(), "Set channel to {}\n", channel).unwrap();
3859

3960
// Don't forget to commit the config!
4061
Ieee802154::commit_config();
62+
writeln!(Console::writer(), "Committed radio configuration!\n").unwrap();
4163

4264
// Turn the radio on
4365
Ieee802154::radio_on().unwrap();
4466
assert!(Ieee802154::is_on());
67+
writeln!(Console::writer(), "Radio is on!\n").unwrap();
4568

4669
let mut counter = 0_usize;
4770
let mut buf = [

0 commit comments

Comments
 (0)