scaffold_driver
Generates a standalone Python/pyusb driver from a captured USB protocol, creating set/query methods, handshake replay, and image sending for the device.
Instructions
Generate a standalone Python/pyusb driver source for the inferred protocol.
One set_() per command; when the device replies, also query_() methods that send the command/poll (or GET_REPORT), read the reply and return it decoded as a dict (readings named by 'seen' markers come back scaled and modes as words, e.g. {'rpm': 1180, 'temp': 34, 'mode': 'turbo', 'ok': True}). When the capture has a handshake, Device() replays it in open() before any command and checks the fixed reply bytes. A command the app only sent in one mode first calls the mode setter (Device(auto_state=False) raises StateError instead). A capture with an image stream to a screen adds send_image(image), which takes JPEG bytes (or, for a raw stream, a Pillow image or RGB565/RGB888 bytes, optionally a region at x, y), chunks it behind the captured header and returns the device's ack.
Read-only analysis that returns driver source as text (does not write a file or open the device). Same capture/markers/labels inputs as report. Prefer wireshark_dissector when the goal is to keep decoding traffic in Wireshark; use replay_packet only after the human approved a specific packet from this driver.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"capture": "<capture>"
},
"name": "scaffold_driver"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device | No | USB device address to analyse; default = bus address with the most host→device payloads | |
| labels | No | Marker-free mode: ';'-separated labels in click order, or a text file path (one label per line) | |
| capture | Yes | Path to a usbmon or USBPcap pcap/pcapng file | |
| markers | No | Markers JSON path; default <capture>.actions.json. Ignored when labels is set |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |