Skip to content

update IEEE 802.15.4 example to have packets decode as data packets with appropriate frame control fields and header - #598

Open
potto216 wants to merge 1 commit into
tock:masterfrom
potto216:586-add-updated-examples-ieee802154_tx
Open

update IEEE 802.15.4 example to have packets decode as data packets with appropriate frame control fields and header#598
potto216 wants to merge 1 commit into
tock:masterfrom
potto216:586-add-updated-examples-ieee802154_tx

Conversation

@potto216

Copy link
Copy Markdown
Contributor

Overview

This closes issue #586 and updates the IEEE 802.15.4 tx example to have packets decode as data packets with appropriate frame control fields and header. The packet now decodes as an 802.15.4 data packet as shown below (The 6LoWPAN reference can be ignored since 802.15.4 packets don't have a payload protocol field so the analyzer has to guess at it)

image

Two issues to note, neither I think related to the libtock-rs code.

  1. As discussed in Unable to run examples/ieee802154_tx.rs on the nRF52840-DK #586 the delta time is 500 ms instead of 1000 ms. I plan on investigating this, but think it is not related to the example code being modified.
  2. For frame 157 with the seq number 163 the delta is 1000 ms. This is because now that transmit_frame_raw checks the status code, sometimes it is busy as seen in the tock console output
TX broadcast: src=0x1001, sequence=159, count=159
TX broadcast: src=0x1001, sequence=160, count=160
TX broadcast: src=0x1001, sequence=161, count=161
TX broadcast: src=0x1001, sequence=162, count=162
TX failed: BUSY
TX broadcast: src=0x1001, sequence=163, count=163
TX broadcast: src=0x1001, sequence=164, count=164
TX broadcast: src=0x1001, sequence=165, count=165
TX broadcast: src=0x1001, sequence=166, count=166
TX broadcast: src=0x1001, sequence=167, count=167

Codex thinks this is because:

The likely bug is in the Tock nRF52840 IEEE 802.15.4 radio driver, not your frame-building code.
The driver stores CCA/CSMA retry state here:
cca_count
cca_be
They are initialized once at boot in [ieee802154_radio.rs (line 697)](/home/user/workspace/tockos/pr/libtock-rs/tock/chips/nrf52840/src/ieee802154_radio.rs:697), but never reset when beginning a new transmission.

This is something I need to investigate in a separate issue, but I don't feel it is relevant to the code being committed in this PR.

I generated 621 packets and the sequence number rolled over multiple times correctly. I did not see any missing packets.

AI usage

I used OpenAI Codex for help with code generation and evaluation. I reviewed any code it generated.

Testing

make test passed

@jrvanwhy jrvanwhy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about the delayed review, I was busy and this one slipped through the cracks.

Comment on lines +103 to +109
match Ieee802154::transmit_frame_raw(&tx_frame) {
Ok(()) => {}
Err(error) => {
writeln!(Console::writer(), "TX failed: {:?}", error).unwrap();
continue;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, this could be an if let:

Suggested change
match Ieee802154::transmit_frame_raw(&tx_frame) {
Ok(()) => {}
Err(error) => {
writeln!(Console::writer(), "TX failed: {:?}", error).unwrap();
continue;
}
}
if let Err(error) = Ieee802154::transmit_frame_raw(&tx_frame) {
writeln!(Console::writer(), "TX failed: {:?}", error).unwrap();
continue;
}

It's totally up to stylistic preference though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants