Repository navigation
Adding a Protocol Decoder
Val edited this page Nov 17, 2026
·
2 revisions
Protocol decoders live in src/decode/ and include/openosc/decode/. This page shows where a new protocol plugs in. Open an issue first to agree on the scope.
- The scope publishes a finished record (both channels).
- A job (
decode/job.hpp) converts the samples of the source channels into logic transitions, using the per-channel threshold, hysteresis and minimum pulse (decode/threshold.hpp). - The job feeds the transitions to the protocol's state machine in record order, block by block.
- The machine writes events into a fixed-size
ResultSet(decode/result.hpp). A full set counts further events as lost. - The UI (table, strip, detail) and the CSV export (
decode/csv_export.hpp) read the published result.
All work is done in slices from the main loop; memory is fixed and lives in the decoder workspace in ITCM.
class ProtocolDecoder {
public:
virtual void start(ResultSet &result, int initialLevel) = 0; // new record
virtual void feed(const Transition *transitions, unsigned count, ResultSet &result) = 0; // a block
virtual void finish(uint32_t samples, ResultSet &result) = 0; // record end
};State is kept between feed() calls. An event never spans two records.
-
State machine: add
include/openosc/decode/protocols/<name>.hppandsrc/decode/protocols/<name>.cpp, implementingProtocolDecoder. It must be trivially destructible and fit the shared storage. -
Machine registry: add it to the
Storageunion and toProtocolMachine::configure()indecode/machine.hpp/machine.cpp. -
Settings: add the protocol to
enum class Protocoland its options todecoding::Settings(decode/settings.hpp), with validation,hash(), the source channels and JSON load/save. -
Panel: add its rows to
DecoderProperties::layout()(ui/editors/decoder_properties.cpp). -
Table and CSV: event text in
decode/table_text.*and the CSV columns indecode/export/. -
SCPI:
DECode:PROTocol?returns the protocol's name.
- Mark doubtful events with
?,CUTor an error flag. - Reject timing the record cannot resolve (too few samples per bit).
- Use static memory and small stack frames.
- Test with recorded and generated signals, and say in the pull request what you tested on hardware.
OpenOSC is licensed under the GPL-3.0. Found a mistake on this page? Tell us in Discussions.
Getting started
Instruments
Device
- Menu Map
- Settings Menu
- Calibration
- Screenshots and Captures
- Files on the Device
- Performance Profiles
Hardware Mods
PC connection
Help
Contributors