Byte-accurate UART reads: read_uart_bytes() and bytes on uart_records() - #16
Draft
ShahriarAhnaf wants to merge 1 commit into
Draft
ShahriarAhnaf wants to merge 1 commit into
ShahriarAhnaf wants to merge 1 commit into
Conversation
…ords() simantic-core#352/#353 carries raw bytes on UartRecord (Session.Bytes) alongside the existing Text field. This exposes that on the Python side: - uart_records() dicts gain a "bytes" key (both the renode and rust backends), mirroring send_bytes()'s naming next to send(). - Sim.read_uart_bytes(from_start=False) -> bytes concatenates the raw UART bytes since the last read, for binary protocols (UBX, MAVLink) where read_uart()'s str would need an encoding round trip to recover the original bytes. Also fixes two things needed to actually drive a raw (non-.replx) .repl platform file through Sim(repl=...) in-process, both real gaps rather than task-specific workarounds: - _add_machine() now only asks the engine to render a platform when it is a .replx template; a ready .repl (SessionMachine's own doc comment already distinguishes the two) is loaded as-is, so relative `using` lines resolve against its own directory instead of a temp path the engine renders to. - load() registers an AssemblyResolve fallback that probes the engine directory for assemblies Renode loads dynamically outside Simantic.Core's own dependency graph (e.g. a platform's PythonPeripheral needing Microsoft.Dynamic/IronPython). The `sim` apphost finds these via its own directory-probing fallback; pythonnet's manual coreclr host does not get that fallback, so without this a repl containing a PythonPeripheral fails to start when hosted in-process. docs/session-api.md's method table updated accordingly. Co-Authored-By: Claude Sonnet 5 <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
UartRecord.Bytes,Session.ReadUartBytes) — merge order matters, core first.uart_records()dicts (bothrenodeandrustbackends) gain a"bytes"key alongside"text".Sim.read_uart_bytes(from_start=False) -> bytes, mirroringsend_bytes()'s naming next tosend().docs/session-api.md's method table updated (was text-only).Also two real fixes needed to drive a raw
.repl(not.replx) throughSim(repl=...)in-process at all, not workarounds specific to one test:_add_machine()only setsRenderPlatformwhen the file is a.replxtemplate. A ready.replwas being routed through the engine's render step regardless, which copies it to a temp path and breaks any relativeusingline —SessionMachine's own doc comment already draws this distinction, the code just didn't honor it.load()now registers aAssemblyResolvefallback that probes the engine directory for assemblies Renode loads dynamically outsideSimantic.Core's own dependency graph (e.g.Microsoft.Dynamic/IronPython for a platform'sPythonPeripheral). Thesimapphost finds these via the framework-dependent host's own directory-probing fallback; pythonnet's manual coreclr host doesn't get that fallback, so a repl with aPythonPeripheralfailed to start when hosted in-process without this.Why
send_bytes()was already byte-accurate on the way in; there was no byte-accurate way to read back out, which blocks testing firmware with binary UART protocols (UBX, MAVLink) from Python.Test plan
pytest tests/(153 passed, 7 skipped; 2 pre-existing failures only when$SIMANTIC_SIMpoints at the released engine that predates core#353 — pass once pointed at a build containing that PR)sim-fixturesWARG ZeroPilot GPS test (simantic-dev/sim-fixtures#200) from the MCP harness to this in-process API,xfailremoved, genuinely passing — see that PR.Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com