Repository navigation
Embedded data pipe: decode a board's charts and pictures; simulated boards send them - #172
Open
david-firia wants to merge 6 commits into
Open
david-firia wants to merge 6 commits into
david-firia wants to merge 6 commits into
Conversation
CodeAIR's firmware writes charts, text and camera frames into its console output as length-prefixed records (C0DECAFE, a u32 length, a 16-byte descriptor, the payload). The console filter recognised them only to drop them; it now decodes each into a record (src/device/data-pipe.js, the format both ways) and the device dispatches it as a 'pipe' event, with 'pipe-progress' while a large one arrives and a failure when one stalls. It still answers the ping and acknowledges every 1 KiB, as the firmware's flow control expects. The simulated CodeAIR ran the device's own embedded_data.py, but its console_bytes stand-in wrote the bytes as text (each byte over 127 became two) and the worker added a CR before every LF, inside records too, so pipe.chart() printed garbage. console_bytes now writes raw bytes, the simulator device takes the records out before mending line endings, and headless runs return them. CodeX and CodeBot get the same module (src/sim/python/pipe/), so a program charts the same way on all three; a CodeX Bitmap can be sent as an image. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS5gJ3k8r2g6DZMxocZDyP
|
Visit the preview URL for this PR (updated for commit 1bc147e): https://firialabs-open-editor--pr172-data-pipe-d6owkfxp.web.app (expires Thu, 10 Dec 2026 17:28:44 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 81259a1fec315ca1af3747d225d9c7424890be3e |
# Conflicts: # CHANGELOG.md
…r byte A board's REPL with no data pipe records in it (banner, prompts, ANSI colours, line editing, a traceback, UTF-8 from every range) reaches the terminal unchanged, split anywhere, and raises no record or reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS5gJ3k8r2g6DZMxocZDyP
# Conflicts: # CHANGELOG.md # tests/sim.mjs
# Conflicts: # CHANGELOG.md
pipe.image(camera.take()) in the simulator gives one 160 x 120 RGB565 image record and leaves the terminal clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SS5gJ3k8r2g6DZMxocZDyP
This branch has not been deployed
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.
The embedded data pipe, both ways: BitsWorkbench now decodes the charts, pictures and messages a board sends inside its console output, and the simulated boards send them exactly as a real CodeAIR does. No new page yet; the data panel that shows them is the next pull request.
The format (from CodeAIR's
embedded_data.pyand its console's flow control):C0 DE CA FE, a big-endian u32 length, a 16-byte descriptor naming the type, then the payload. Text is UTF-8; an image is RGB565, high byte first, with its width and height in the descriptor; a chart carries its name, a zero-terminated series name and 8-byte points (float32 value, u32 milliseconds). A length whose top byte is01is a ping, answeredOK\r; the host acknowledges every 1 KiB with06. It is written up at the top ofsrc/device/data-pipe.js.What changes
src/device/data-pipe.js: the decoder for one record, and encoders that give the exact bytes a board sends (encodeText,encodeChart,encodeImage,encodePing), for the simulator and the tests.console-filter.jskeeps the records instead of dropping them: each becomes apipeevent on the device, withpipe-progresswhile a large one (a camera frame) arrives and a failure if one stalls for 2 seconds. A strayC0before a real record no longer hides it.pipe.chart()printed garbage. Itsconsole_bytesstand-in wrote the bytes as text (each byte over 127 became two) and the worker added a CR before every LF, inside records too.console_bytesnow writes raw bytes, the line endings are mended after the records are taken out, and headless runs return the records (result.records).embedded_datamodule (src/sim/python/pipe/), sofrom embedded_data import EmbeddedDataPipeworks on all three; a CodeXBitmapcan be sent as a picture.Tests:
tests/protocol.mjspins the encoders to the device's bytes (worked out from its struct formats), round-trips each type, splits a stream with every record type at every byte, checks the acks on a 160 x 120 frame and the 2-second stall.tests/sim.mjsrunspipe.chart,pipe.textandpipe.imageon all three simulated boards. The full suite passed locally against this build (one guided-tour check on the upright iPad failed once and passed when run again; it touches none of this).Screenshot: a simulated CodeAIR charting its height: the terminal shows only what was printed.
Design: the botblocks page "Data pipe and data panel: design".
🤖 Generated with Claude Code
https://claude.ai/code/session_01SS5gJ3k8r2g6DZMxocZDyP