Skip to content

Embedded data pipe: decode a board's charts and pictures; simulated boards send them - #172

Open
david-firia wants to merge 6 commits into
mainfrom
data-pipe
Open

david-firia wants to merge 6 commits into
mainfrom
data-pipe

Conversation

@david-firia

@david-firia david-firia commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.py and 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 is 01 is a ping, answered OK\r; the host acknowledges every 1 KiB with 06. It is written up at the top of src/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.js keeps the records instead of dropping them: each becomes a pipe event on the device, with pipe-progress while a large one (a camera frame) arrives and a failure if one stalls for 2 seconds. A stray C0 before a real record no longer hides it.
  • A fault fixed in the simulator: a simulated CodeAIR's pipe.chart() printed garbage. 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. console_bytes now writes raw bytes, the line endings are mended after the records are taken out, and headless runs return the records (result.records).
  • The simulated CodeX and CodeBot get CodeAIR's own embedded_data module (src/sim/python/pipe/), so from embedded_data import EmbeddedDataPipe works on all three; a CodeX Bitmap can be sent as a picture.

Tests: tests/protocol.mjs pins 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.mjs runs pipe.chart, pipe.text and pipe.image on 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.

A simulated CodeAIR charting: 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

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
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

david-firia and others added 2 commits December 3, 2026 09:53
…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
david-firia and others added 3 commits December 3, 2026 10:57
# Conflicts:
#	CHANGELOG.md
#	tests/sim.mjs
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

No deployments
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.

1 participant