feat(sim): mock the RFM69 radio and drive remote loads over it - #171
Merged
Merged
Conversation
grid_sim gets a model of the RFM69 on the SPI bus (chip select D10): the register file, operating modes and a FIFO that goes on air in TX mode, with PacketSent raised after the frame's real air time. Remote loads, declared with 'remote <node> <bit> <phase> <W>', follow the frames sent to their node through an ideal receiver, and drop out after the 500 ms link timeout like RemoteLoadReceiver. New expectations: 'expect <t> remote <node> <bit> on|off' and 'expect rf_max_gap <node> <s>'. Frames go to the events CSV and the summary. scenarios/rf run against the rf environment with configs/remote_loads.patch applied (third load on remote unit 15); CI builds it and runs make check-rf. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Remote loads can now be tested without hardware or sun:
grid_simmodels the RFM69 radio on the SPI bus, and remote loads follow the frames the router sends them.What's new
sim/rfm69.c/.h: a model of the RFM69, covering just what the LowPowerLab library uses to send in packet mode:initialize();PacketSent rises after the frame's real air time at the programmed bit rate (1.73 ms here), so
send()blocks the main loop as long as it does on the board. The channel always looks free.Remote loads:
remote <node> <bit> <phase> <W>declares a load driven by an ideal receiver:rf_timeoutwithout frames (500 ms by default, likeRemoteLoadReceiver).Its power is drawn from the simulated grid, so the router regulates through the RF link.
Expectations:
expect <t> remote <node> <bit> on|offandexpect rf_max_gap <node> <s>. Frames are logged in the events CSV (RF15,01), and the summary has one line per node.sim/configs/remote_loads.patch: a two-lineconfig.hchange that moves the third load to remote unit 15. It's applied withgit apply --unidiff-zero, which fails loudly ifconfig.hdrifts.Scenarios:
scenarios/rf/remote_step.scnandremote_override.scn, run withmake check-rf.CI: the Grid simulation job applies the patch, builds
rfand runsmake -C sim check-rf.Results
On
dev, with the patched config:The refresh is every 5 mains cycles (100 ms). It is delayed while the main loop prints a datalog line, which is real firmware behaviour and well within the receiver's 500 ms timeout.
#160, configured with remote units 1 and 2, passes the same kind of scenario:
Once this is merged, #160 needs its own version of the patch for the
Load::remote()config format.Notes
0, not'0'.RemoteLoadReceiverfirmware in extra simavr instances linked by the radio model, and inject frame loss.🤖 Generated with Claude Code