Repository navigation
Conversation
Add a transport for cutters that take their commands over a BLE GATT
service, such as the Silhouette Cameo 4. It uses bleak, running on the
application's asyncio event loop. Writes are serialized so commands
stay ordered, and status notifications are fed to protocol.data_received.
A BLE connect takes a while, and each jog asks to connect while one is
still running, so concurrent requests share the connect in progress;
otherwise two clients end up attached to one machine.
The service and characteristics are set by the transport config rather
than hard coded. Drivers provide them under
default_config['connection']['ble']: service_uuid and write_uuid are
required, notify_uuid is optional for machines that report status.
Nothing is detected from the device. They are not shown in the settings
view; the module docstring explains how to find the values for a new
cutter.
Cameo 4 gains 'ble' alongside 'printer' with its values, taken from a
GATT dump of a Cameo 4 Plus. Its service has two characteristics with
identical write/indicate properties; only testing showed which one
reports status.
Two settings are needed to make a Cameo respond, and the Cameo 4 driver
turns both on:
- writes must be made with a response. The machine ignores
write-without-response entirely.
- each write must end with ETX. The GPGL protocol puts ETX before each
command, so the latest one is not run until the next is sent.
The scan is filtered by name so the list shows cutters instead of every
phone and TV nearby. A BLE connection can only be made to a device that
is advertising, so connecting always finds the device by a scan first,
even with a saved address. A device connected elsewhere stops
advertising, and the error says so.
Tested against a Cameo 4 Plus: connects, homes, and reports busy/ready
status back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Cameo 4 Plus is the 15" model of the Cameo 4. It takes the same commands and has the same BLE service and characteristics (checked on a Cameo 4 Plus, which is where the Cameo 4 values came from), so only the cutting width differs: 38.1cm. Rather than copy the Cameo 4 entry, it is moved into a Cameo4Driver enamldef that both models declare, the Plus overriding model and length. Overrides replace an attribute whole, so a variant that needs a different default_config has to restate it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Cameo answers queries (FG for its name, ESC ENQ for its state, ESC NAK for the tools loaded) on a different characteristic from the one it reports status on, and the transport only subscribed to the status one, so a protocol could send a query but never see the answer. Add read_uuid for the reply characteristic. Replies on it go to protocol.data_received and last_read, like a serial port's input. The status characteristic is still subscribed but now only logged: the machine sends "1" (busy) and "0"/"2" (ready, with or without media) unasked whenever it moves, and passing those on would let a protocol take an unrelated "busy" as the answer to its query. A protocol that wants the state asks with ESC ENQ, which works the same over USB. A machine with no read_uuid answers on notify_uuid, which then stays the reply stream as before. Cameo 4 gets read_uuid 8dcf199a-..., found by subscribing to both characteristics on a Cameo 4 Plus and sending each query. The docstring's GATT table and status values are corrected to match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terminating each command with ETX is a GPGL matter, not a BLE one, so it moves from the BLE transport config to a new GPGLConfig, with a checkbox in the protocol settings. The Cameo 4 driver sets it under protocol/gpgl, and it now also applies over USB. The ETX characters GPGL already puts before each command were raw control characters in the source; they are written as \x03 escapes now so they can be seen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On macOS a checkbox is laid out at a smaller size than it is drawn, leaving room for its focus ring, so in a container with no padding the widget runs past the container's edge and is clipped: 9 px at the right of both checkboxes here, and 4 px at the bottom of the last. Pad those containers by as much. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inkcut sends a job one command per write, with delays between them estimated from the speed setting. Over BLE each write takes ~60 ms to be acknowledged whatever its size, so a curve made of 0.5 mm steps stops after every step: the Cameo draws faster than single commands arrive. With flow control on, a job's commands go out in writes of up to 180 bytes, each ending with an FG query. The Cameo answers a query only once it reaches it in its queue, after the commands before it, so the answers show how far it has got. At most 8 batches are left unanswered, which keeps its buffer fed without overfilling it, and the estimated delays are turned off. At the end of a job the protocol waits for the last answer, since disconnecting clears what the machine has yet to run. Nothing is sent while the Cameo is paused, as it silently discards what arrives then. The protocol checks its state (ESC ENQ) before each batch and also stops as soon as the machine reports a pause unasked, which the BLE transport now passes to the protocol. Batches still unanswered once the machine sits idle are logged and no longer waited on, so a job cannot hang. Batching only applies during a job, so jogging still sends each move at once, and not on spooled connections, which never answer. It is off by default and the Cameo 4 driver turns it on. DeviceProtocol gains start_job(), controls_flow() and status_received() for this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lagnat
force-pushed
the
gpgl-flow-control
branch
from
November 27, 2026 20:55
9790223 to
c6e08ed
Compare
lagnat
marked this pull request as draft
November 28, 2026 00:22
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.
Builds on #452 (Bluetooth LE transport). Until that is merged its commits show here too; only the last commit, Add flow control to the GPGL protocol, is new.
Problem
Inkcut sends a job one command per write, with delays between commands estimated from the speed setting. Over BLE each write takes ~60 ms to be acknowledged, whatever its size. Curves are sent as steps of about 0.5 mm, so on a Silhouette Cameo 4 the head draws a step, stops, and waits for the next: curves crawl and stutter.
What this does
An optional GPGL setting,
flow_control:FGquery.ESC ENQ) before each batch, and also stops as soon as the machine reports a pause unasked (the BLE transport now passes those reports to the protocol).Jogging still sends each move at once, and spooled connections (printer queue, file) are left alone, since they never answer. The setting is off by default; the Cameo 4 driver turns it on, and there is a checkbox for it in the protocol settings.
DeviceProtocolgains three small hooks for this:start_job(),controls_flow()andstatus_received().Measured on a Cameo 4 Plus over BLE
ESC ENQwhile paused, but not ordinary queries such asFG, and drops whatever is sent during a pause. With the pause button pressed 74 times during a job, every batch was answered and none was lost.Tests
New tests in
tests/test_protocols.pyuse a fake Cameo transport to cover batching, sending immediately when not in a job, spooled connections, the window, pausing, and lost batches.🤖 Generated with Claude Code