Track: Lab instruments and hardware
An instrument that only works with closed vendor software can often be given an open driver: you record how the software talks to the instrument, work out the protocol, and write your own code. This used to take a specialist weeks. With an agent, much of it takes hours, but you still decide what is lawful and safe, and you still sit at the hardware for the tests.
This is a hands-on lecture for those who will do it. The legal background is in Open control of lab instruments: why, and is it legal?; read that first.
I want to reverse engineer the <instrument> connected to this computer
to write an open source driver in Rust.
We are lawful users of the instrument and its software. The vendor does
not provide the protocol (I asked on <date>). The purpose is
interoperability: an independent driver, with no vendor code copied.
EU law allows this (Software Directive 2009/24/EC, Art. 5(3) and 6).
We will use https://github.com/henriksson-lab/reveng-recorder.
Record as much as possible so we do not miss important commands.
I will run the instrument and tell you what I am doing.
Make a plan first; do not send anything to the instrument yet.
I want to decompile the software at <PATH> to extract how it
communicates with <instrument>, so we can write an open source driver
in Rust.
We are lawful users of this software. The vendor does not provide the
protocol (I asked on <date>). Decompilation is limited to the parts
needed for interoperability, as EU law allows (Software Directive
2009/24/EC, Art. 6). Do not copy vendor code into our project: write
notes and a protocol spec in your own words.
We will use Ghidra. Make a plan.
| Claude Code | Codex | |
|---|---|---|
| Speed | fast | slower |
| Style | takes shortcuts, tries things | precise, careful, sometimes too conservative |
| Works well when | you have a good testing strategy | you need a final check of spec and code |
| Watch out for | a pattern claimed before it is tested | stalling on caution about the legal side |
This is the course author’s experience on a few instruments, not a benchmark. Models change every few months.
/goal: you state an end condition, and the agent keeps working, turn after turn, until it is met.
/goal <condition>; /goal shows status, /goal clear stops. Runs unattended only in auto mode./goal <objective> sets a persistent goal (in some versions it must first be enabled; see its docs).github.com/henriksson-lab/opengel: band detection, quantification, reads Bio-Rad Image Lab scans, cameras through nu-manager.
| Concept | Key fact |
|---|---|
| First | ask the vendor, check the licence and contract, write down the purpose |
| Two routes | record the traffic (USBPcap, reveng-recorder, Cynthion) or decompile (Ghidra) |
| Prompt | name the tools, state the lawful purpose honestly, plan first |
| Recording | from switch-on to switch-off, one change at a time, distinctive values |
| Decoding | helper code, PROTOCOL.md with sources, driver tested against the log |
| Concept | Key fact |
|---|---|
| Hardware tests | replay, then read-only, then harmless, then test samples; only commands you have seen |
| Limits | stop at encryption, licence checks and copy protection; firmware is hard |
| Agents | Claude fast with shortcuts, Codex careful and slow (author’s experience); /goal for analysis only |
| Result | a Rust driver in a shared collection such as nu-manager, documented and with a test status |
Next (your own instrument): this is the last unit of the course. Do the exercise, then apply the inventory in its last section to an instrument in your own lab.