examples/Protobuf Example/README.md
This example shows how to ingest a Protocol Buffers (.proto) schema into
Serial Studio. The Project Editor reads the file and produces:
libprotobuf runtime dependency — the wire-format decoder is inline.accel, gyro).Works on both GPL and Pro builds.
The folder includes Protobuf Example.ssproj, the project this walkthrough
produces, already switched to UDP. Open it directly and click Connect:
its control loop launches sensor_simulator.py for you, so you can skip
the import and the manual python3 sensor_simulator.py step. Or follow the
import steps below to generate the project yourself.
Ctrl+E).examples/Protobuf Example/sensor.proto.sensor.ssproj.The generated project defaults to UART; the simulator speaks UDP. Open the project's source panel and set:
7878cd "examples/Protobuf Example"
python3 sensor_simulator.py
You should see a live status line like:
Sensor 54B | sent 123 (99 sensor + 24 vec3) | 24.7 Hz | 5.0s
And on the dashboard:
temperature, humidity animate; status bits
flip past thresholds; note carries the running frame counter.For each frame, the parser walks every top-level dispatch table:
.proto file
wins).Field slots written by the winning dispatcher get fresh values; slots belonging to other messages keep their last reading. This matches protobuf's "missing field = no value" semantics.
If two top-level messages share the same first few field tags AND wire
types, the auto-detect can't tell them apart. Wrap such messages in a
discriminator envelope or split them into separate UDP ports. The
example here is intentionally easy: Sensor starts with float (wire
type 5) at field 1, and so does Vec3 — but Sensor carries six
distinct tags vs. Vec3's three, so the score difference is decisive
once the second tag is seen.
sensor.proto — proto3 schema with Vec3 and Sensor.sensor_simulator.py — UDP simulator. Hand-encodes the wire
format with struct; no third-party Python packages needed.Protobuf Example.ssproj — the generated project, preconfigured
for UDP port 7878.README.md — this file.