simu: let the host see what a module transmits - #7606
Open
nikklaswallerstedt wants to merge 1 commit into
Open
Conversation
A SIMU build wires every module port to a stub serial driver whose sendBuffer does nothing, so nothing the RF module transmits can be observed by the simulator host. The inbound direction already exists: simuSendTelemetry() feeds processCrossfireTelemetryFrame(). With only half the link there is no way to answer the module. Anything that talks to it over serial waits forever for a reply nobody could know it had asked for -- ExpressLRS's own SCRIPTS/TOOLS/elrs.lua, run off a real card, sits on "Loading..." indefinitely, because its CRSF requests go nowhere. Add the missing half as one import, simuModuleSendBuffer(module, data, len), and route the internal module's UART through it. The external module is left on the stub: a port nobody listens to is better left obviously silent than half-wired. Both internal-port variants are routed, the UART one and the soft-serial one, because which is compiled depends on INTMODULE_USART and getting it wrong is silent -- an unreferenced driver is dead-stripped, the import vanishes from the module, and the only symptom is that no frames ever arrive. Measured on tx12mk2, which takes the soft-serial branch.
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.
Fixes #
Summary of changes:
The WASM/SIMU target can be told what a module receives but not what it
sends, so a host has no way to answer the radio's RF module. This adds the
missing direction.
The gap.
radio/src/targets/simu/module_drivers.cpppoints every moduleport at
_fakeSerialDriver, whosesendBufferdiscards its argument. Theinbound half is already there —
simuSendTelemetry()hands bytes toprocessCrossfireTelemetryFrame()— so a host can inject telemetry, butanything the firmware writes to the module is dropped before it leaves the
simulator.
The consequence. Nothing that expects a reply from the module can work.
Concretely: ExpressLRS ships
SCRIPTS/TOOLS/elrs.lua, and running it off areal SD card in a SIMU build gets as far as "Loading..." and stays there
forever. The script's CRSF
DEVICE_PINGis written to the module port anddiscarded, so no host could know a reply was wanted, let alone what to reply.
The script is correct and the radio is correct; there is simply no wire.
The change.
simulib.h: one new import,simuModuleSendBuffer(uint8_t module, const uint8_t* data, uint32_t len)—moduleis 0 for internal, 1 for external —documented as the reverse of the existing
simuSendTelemetry().module_drivers.cpp:_intmoduleSerialDriver, identical to the existingstub except that
sendByte/sendBufferhand their bytes to the host, andthe internal module's port entries use it.
Two deliberate choices, both easy to change if you would rather they were
different:
_fakeSerialDriver. Only theinternal path has been exercised, and a port nobody listens to seemed better
left obviously silent than half-wired.
INTMODULE_USARTselects which of the twoETX_MOD_PORT_*entries is compiled, and picking only one fails silently:the driver goes unreferenced, is dead-stripped, the import never appears in
the
.wasm, and the sole symptom is that no frames ever arrive. Routing bothcosts nothing and removes a very confusing failure mode.
Tested on
tx12mk2(PCB=X7), which takes the soft-serial branch. With theimport in place, unmodified
elrs.luaoff a stock ExpressLRS SD card finds theinternal CRSF module, draws its parameter menu, and writes packet rate and
transmit power back to a host-side module implementation. Nothing else about
the build changes; on targets whose host does not provide the import, the
behaviour is the same as before.