fix(simulator): restore host serial port bridge in WASM simulator#7284
Open
raphaelcoeffic wants to merge 2 commits intomainfrom
Open
fix(simulator): restore host serial port bridge in WASM simulator#7284raphaelcoeffic wants to merge 2 commits intomainfrom
raphaelcoeffic wants to merge 2 commits intomainfrom
Conversation
PR #6435 ported the simulator plug-ins to WASM but did not bridge the aux serial ports across the WASM boundary, leaving AUX1/AUX2 backed by a no-op driver. Lua serialWrite() and any other code touching the aux serials was silently dropped, breaking host serial integration in Companion's simulator (#7283). Add a host bridge driver in simulib.cpp that forwards TX through new WASM imports (simuAuxSerialStart/Stop/SetBaudrate/SendBuffer) and serves RX from per-port mutex-protected queues, populated by a new simuAuxSerialReceive export. On the Companion side, register native callbacks that re-emit the existing SimulatorInterface aux serial signals so HostSerialConnector (already wired up in SimulatorMainWindow) drives the real host port, and implement WasmSimulatorInterface::receiveAuxSerialData() to push host bytes back into the firmware. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
b9496db to
ab03354
Compare
3 tasks
Contributor
|
Tested with real USB/serial adapter (and using a rx-as-tx) on 921KB. |
The host_drv bridge added in the previous commit calls four WASM imports (simuAuxSerialStart/Stop/SetBaudrate/SendBuffer). On WASM targets WASM_IMPORT resolves them via import_name attributes, but on native builds (gtests-radio, SDL simu) the macro is a no-op, leaving the declarations as plain externs with no definitions and breaking link of every target with AUX_SERIAL enabled. Provide no-op stubs for the four functions in simulib.cpp, guarded by !__wasm__, so native builds link cleanly. The WASM simulator path is untouched and Companion continues to resolve the symbols through WAMR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes #7283.
PR #6435 ported the simulator plug-ins to WASM but did not bridge the aux serial ports across the WASM boundary, leaving AUX1/AUX2 backed by a no-op driver. Lua
serialWrite()/serialRead()and any other firmware code touching the aux serials was silently dropped.This PR re-establishes the bridge across the WASM boundary; the existing Companion-side machinery (
HostSerialConnector,SimulatorInterfaceaux serial signals,SimulatorMainWindowwiring) was already in place and is reused as-is.WASM API additions
New imports (firmware → host):
simuAuxSerialStart(port_nr, baudrate, encoding)simuAuxSerialStop(port_nr)simuAuxSerialSetBaudrate(port_nr, baudrate)simuAuxSerialSendBuffer(port_nr, data, len)New export (host → firmware):
simuAuxSerialReceive(port_nr, data, len)Test plan
serialWrite("hello\n")→socatPTY pair → host terminal sees the bytesprintf 'line\n' > /dev/ttysXXX→ LuaserialRead()→ tool script displays the linesocatvirtual PTY pair)