Skip to content

Do not let a console message kill the radio model - #3

Closed
A13xB0 wants to merge 4 commits into
mainfrom
fix-console-msg
Closed

A13xB0 wants to merge 4 commits into
mainfrom
fix-console-msg

Conversation

@A13xB0

@A13xB0 A13xB0 commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

The radio model treated any engine message it did not recognise as a desynchronised stream and exited. kConsoleIn (0x06) is sent to every node the moment anything touches the fleet console, so an emulated node died seconds after boot and reported:

ERROR: radio init failed: -2

which is RadioLib for chip not found. That points squarely at wiring — pins, SPI controller, chip select — and none of it was wrong. What had happened was:

radioserver: unknown engine message 0x06
radioserver: the engine went away
radioserver: 0 transactions, 0 bytes

The chip was fine; the model had gone.

Console input belongs to the firmware's serial port, and an emulated node's serial port is the emulator's rather than this socket, so ignoring it is the whole handling. What mattered was that it not be fatal.

Unknown kinds are now skipped rather than fatal. The framing is length-prefixed and the payload has already been read before dispatch, so an unrecognised message cannot desynchronise the stream — whereas exiting takes the node down for a message it did not need. The old comment claiming otherwise was wrong about its own protocol.

This file existed only as a working copy and had never been committed; it lands here with the fix.

Verified in the application, not just in a test: an emulated Generic_E22_sx1262 running published v1.17.0 on the ScotMesh CAD study had its advert decoded by 38 nodes, from Blantyre02 at 40.7 dB down to Bishop Hill at -8.9 dB.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TGXGCDQQHLL9Bqo9GBsyrw

LargeSpark and others added 4 commits August 11, 2026 20:29
The radio model treated any engine message it did not recognise as a
desynchronised stream and exited. kConsoleIn (0x06) is sent to every node
the moment anything touches the fleet console, so an emulated node died
seconds after boot and reported

    ERROR: radio init failed: -2

which is RadioLib for "chip not found" and points squarely at wiring. It
took a packet capture of the socket to see that the chip was fine and the
model had gone.

Console input belongs to the firmware's serial port, and an emulated
node's serial port is the emulator's rather than this socket, so ignoring
it is the whole handling. Unknown kinds are now skipped rather than
fatal: the framing is length-prefixed and the payload has already been
read, so an unrecognised message cannot desynchronise anything - whereas
exiting takes the node down for something it did not need.

This file was only ever a working copy; it is committed here with the fix.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGXGCDQQHLL9Bqo9GBsyrw
Renode runs on Mono, whose Unix domain socket support has been unreliable
for long enough that betting an emulated node on it is a poor trade for
one path separator. A leading colon asks for TCP on loopback, and port 0
prints the port it was given - which is what a harness starting several
nodes at once needs, rather than picking a number and hoping.

QEMU keeps the socket path it already used. Nothing else changes: both
emulators reach the same VirtualSX1262 a native node reaches in process.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGXGCDQQHLL9Bqo9GBsyrw
QEMU never needed it - the ESP32 firmware polls the chip's IRQ register
over SPI - but an nRF52 waits on the pin, and a pin nothing drives is a
node that configures its radio and then sits there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGXGCDQQHLL9Bqo9GBsyrw
The same chip serves a native node, an emulated ESP32 and an emulated
nRF52, so when one of them will not bring its radio up, a diff of the
three traces says which command got an answer it did not like. That is
how the nRF52 chip-select fault was found: 3,320 bytes and zero
transactions.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TGXGCDQQHLL9Bqo9GBsyrw
A13xB0 added a commit that referenced this pull request Aug 14, 2026
The radio model sits between an emulated MCU and the engine, and every
emulated node needs one - so a bundle without it ships two emulators
that cannot be driven. This file could not be built for Windows: it
included <sys/un.h> unconditionally and used read/write/poll on socket
handles, none of which mingw has.

Confined to the same five-line compat block bridge/main.cpp already
uses, plus WSAPoll for waiting on two sockets. Windows takes the TCP
half only - its AF_UNIX is unreachable without <sys/un.h>, and the
simulator already asks for ":0" there for both emulators - and says so
rather than listening nowhere.

Includes the TCP transport and the console-message fix from #3, which
this supersedes.
@A13xB0

A13xB0 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Obsolete: this fixes bridge/radioserver.cpp, and radioserver was retired in #18 - the emulators hold the chip model now, linked into the process rather than served from a separate binary. The console and the radio model are separate paths in the current architecture, so the failure this addressed is not reachable there. Closing rather than rebasing onto a file that no longer exists.

@A13xB0 A13xB0 closed this Sep 9, 2026
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