Protocol
The section Station-Pod Communication Protocol below establishes the Station-Pod link as a request-response protocol with the Station as sole initiator, and names three conceptual message categories: commands, status queries, and events. This page defines the wire-level realization of that model: the frame layout, how a request is correlated with its response, and the concrete communication patterns built on top of that correlation. The decision for the request-response model and the decision to generate the protocol code with commsdsl are recorded in ADRs. See SYS-003 and SYS-006.
The protocol is defined as a single schema shared by the Station and every Pod, so both sides agree on the same frame layout, message set, and field encoding by construction. Schema: cocktail-maker-protocol.
Station-Pod Communication Protocol
The Station and every Pod communicate through a request-response protocol. The Station is the sole initiator of communication. A Pod never sends unsolicited commands. Every Pod is addressed by a unique identifier assigned at connection time, allowing the Station to route commands to a specific Pod and to attribute status and events back to their origin. This request-response model, including the Station’s role as sole initiator, is decided in SYS-003.
The protocol distinguishes three conceptual message categories:
-
Commands: issued by the Station to trigger an action on a Pod, e.g. dispense a given volume.
-
Status queries: issued by the Station to poll a Pod’s current state, e.g. connected, idle, dispensing, fault.
-
Events: emitted by a Pod in response to a command or an internal condition, e.g. dispensing completed, calibration done, error raised.
This section defines the protocol’s role and message categories at a conceptual level. The exact wire format, framing, and versioning strategy are defined in Framing and Versioning.
Physical Transport
The Station and Pods are physically connected via USB, using the USB CDC class to carry the protocol described above. The USB data link is hot-pluggable, so the USB cable of a Pod can be replugged while the machine runs. The Pod supply is not, so an Operator switches the machine off before connecting or disconnecting the supply of a Pod (IF-03).
Framing
Every exchange between the Station and a Pod is carried in a single frame:
| Field | Type | Purpose |
|---|---|---|
Sync |
|
Fixed marker that lets a receiver find the start of the next frame on the raw USB CDC byte stream. |
Size |
|
Number of bytes from MsgId through Payload, used to know when a full frame has been received. |
MsgId |
|
Identifies which message the payload contains (e.g. |
TransactionId |
|
Correlates this frame with the request it belongs to. See Transaction Correlation. |
Payload |
message-specific |
The fields of the message identified by |
Checksum |
|
Computed over Size through Payload. Protects the frame’s integrity on the wire. |
There is no byte-stuffing or escaping layer. Framing relies on Sync, Size, and the CRC alone.
Transaction Correlation
TransactionId is not a field of any individual message.
It is a transport-level field carried by every frame, regardless of which message it holds.
The Station generates a TransactionId for each request it sends and reuses it for every frame that belongs to the same exchange.
This includes an immediate Ack/Nak, a dedicated response, and any event that concludes a longer-running action later on.
A Pod must echo the TransactionId of the request it is reacting to on every frame it sends back for that exchange.
Because a TransactionId is only required to be unique among requests that are currently pending, the Station is free to reuse a value once its exchange has concluded.
How does the Station match a frame from a Pod to its request?
This is the only correlation mechanism the protocol has.
There is no separate request or session identifier.
TransactionId scopes exactly one request/response exchange.
It does not identify any higher-level operation a caller of the protocol may be carrying out, and such an operation may itself require several such exchanges.
Communication Patterns
Every message exchange follows one of three patterns, distinguished by how many frames a Pod sends back for a single request and how far apart in time they arrive.
Request / Response
The simplest pattern: a request is answered by exactly one dedicated response message, carrying the same TransactionId.
Used by Ping/Pong (keep-alive), DeviceInfoRequest/DeviceInfoResponse, and LoadCellWeightRequest/LoadCellWeightResponse.
A LoadCellWeightRequest is answered by a Nak instead if the load cell can’t be read.
How does a Pod answer a request with one dedicated response?
Request / Acknowledgement
A request that only needs to confirm it was carried out is answered by the generic Ack, or Nak if it could not be executed.
Nak carries an ErrorCode explaining the reason, rather than each command defining its own failure message.
Used by EmergencyStop, LoadCellCalibrateWithRefWeight, LoadCellTare, and HighlightDispenser.
LoadCellTare and LoadCellCalibrateWithRefWeight take a little over a second.
The Pod samples the load first, then waits until the load cell’s weight shows the result, and only then replies.
How does a Pod confirm a command, or refuse it?
| Value | Meaning |
|---|---|
|
A field of the command has a value the Pod can’t use. |
|
This Pod has no dispenser with the given |
|
The Pod can’t do this in its current state. |
|
An actuator or sensor failed or didn’t answer, or an |
|
The dispenser is already running another action. Retry once that has ended. |
|
The action needs a calibration that hasn’t been done yet. |
|
An unexpected error inside the Pod. |
|
Next to nothing came out of the dispenser, most likely because its bottle is empty. |
|
This dispenser has no load cell, which is normal for some dispensers. Everything that weighs gets
this, including |
|
The load moved while the load cell measured it. Keep the scale still and retry. |
|
A load cell calibration needs a tare of the empty scale shortly before. Tare and retry. |
|
The reference weight gave an implausible reading, most likely because it wasn’t on the scale. |
Request / Acknowledgement / Event
Some requests trigger a physical action whose duration cannot be bounded tightly enough to hold a single response open.
Dispensing a liquid and running a dispenser calibration are both examples of this.
These are acknowledged immediately with Ack/Nak, and once the underlying action completes, the Pod sends a dedicated event carrying the same TransactionId as the original request.
This is the mechanism that lets the Station attribute an event arriving seconds later back to the exact request that caused it, even though other exchanges may have started and finished with different transaction ids in the meantime.
Used by Dispense (followed by DispenseFinished) and DispenserStartCalibration (followed by DispenserFinishedCalibrationResponse).
The completion event must reuse the TransactionId of the request that triggered it.
While the action runs, the Pod sends a DispenseProgress about four times a second under the same TransactionId.
It only comes between the Ack and the final reply, and it is only for display.
The final reply alone holds the real amount.
The Station drops it for now, so that it can’t crowd out the final reply.
How does a Pod report the end of a long action under the TransactionId of its request?
A Nak can still arrive in place of the event if the action fails after having been accepted, so a caller of this pattern must be prepared to receive either outcome under the same TransactionId.
DispenseFinished says how the pour ended:
| Value | Meaning |
|---|---|
|
The requested amount came out, within the Pod’s tolerance. |
|
The weight stopped falling while the dispenser ran, most likely because the bottle is empty. A blocked hose looks the same. |
|
The pour hit its time limit of 30 s (provisional, to be confirmed on the assembled machine) while the weight was still falling. |
|
All trims are used up and the amount is still below the target. |
Only Completed reaches the requested amount.
None of them is an error, so a pour that came up short still ends with DispenseFinished and not with a Nak.
Reply Times
The Station’s timeouts must be longer than the Pod’s worst case for each of these:
| Request | Allow | Why |
|---|---|---|
|
2 s |
The Pod replies once it has finished, after a little over a second. |
|
35 s |
The Pod stops a pour after 30 s at the latest (provisional, to be confirmed on the assembled machine) and then measures it at rest. |
|
Run time plus 3 s |
The dispenser has to stop first, then the Pod measures at rest. |
|
500 ms |
The Pod reads the load cell before it starts. The longest reply measured is 2.7 ms. |
|
500 ms |
One read of the load cell. The longest reply measured is 2.6 ms. |
|
500 ms |
It can wait behind a read of the load cell. The longest reply measured is 2.6 ms. |
|
100 ms |
The longest reply measured is 4.6 ms. |
The measured times come from a Pod’s hardware test with three other dispensers running.
They include USB and the host, and the Station keeps the rest as a margin.
The Station doesn’t repeat a tare, a load cell calibration, a Dispense or a DispenserStartCalibration on its own.
Load Cell Weights
LoadCellWeightResponse reports the weight relative to the load cell’s zero point, so it can be negative.
LoadCellTare sets that zero point, and so does every power up of the load cell.
The reading therefore says how far the weight has moved, not how full a bottle is.
The Station keeps the fill level.
See the Station runtime view and SYS-007.
Versioning
The schema is released with semantic version numbers.
Its version attribute carries the same number as 0xMMmmpp, so 0x020100 is release 2.1.0.
DeviceInfoResponse starts with ProtocolVersion in that form, and it stays the first field in every release.
The Station accepts exactly the release it was built against.
A Pod on another release stays unused, and the Station names both releases.
A Pod on 2.0.0 has no ProtocolVersion yet, so its DeviceInfoResponse doesn’t decode at all.
The Station then only sees no answer and logs a hint that the Pod may speak another release.
Messages
| Message | Direction | Category | Purpose |
|---|---|---|---|
|
Station → Pod |
Request / Response |
Checks that the Pod is alive. |
|
Pod → Station |
Request / Response |
The Pod’s reply to a |
|
Pod → Station |
Request / Acknowledgement |
The Pod accepted a command. For a command that reports its end with a message of its own, this only says that the action has started. For any other command it says that the command has been carried out. |
|
Pod → Station |
Request / Acknowledgement |
The Pod refused a command or couldn’t finish it, with an |
|
Station → Pod |
Request / Response |
Asks a Pod to describe itself. |
|
Pod → Station |
Request / Response |
Protocol release, hardware revision, firmware version, number of pumps and valves, and the Pod’s name. |
|
Station → Pod |
Request / Acknowledgement |
Stops every pump and valve of the Pod at once. Every |
|
Station → Pod |
Request / Acknowledgement |
Calibrates a dispenser’s load cell with a known weight resting on the scale. The empty scale must
have had a |
|
Station → Pod |
Request / Acknowledgement |
Makes the current load the zero point of a dispenser’s load cell. The load must stay still meanwhile. |
|
Station → Pod |
Request / Response |
Asks for the current weight on a dispenser’s load cell. |
|
Pod → Station |
Request / Response |
The current weight relative to the zero point, which can be negative. |
|
Station → Pod |
Request / Acknowledgement / Event |
Runs a dispenser for a set time and measures what came out with its load cell. The run time must be
greater than 0 and at most 30 s (provisional, to be confirmed on the assembled machine). The load cell must already be calibrated, and real liquid comes out.
After a |
|
Pod → Station |
Request / Acknowledgement / Event |
Reports the amount that came out, measured at rest. The Pod uses the new calibration from now on and keeps it across power cycles. |
|
Station → Pod |
Request / Acknowledgement |
Shows a light effect on a dispenser’s LEDs. A duration of 0 keeps it on until the next
|
|
Station → Pod |
Request / Acknowledgement / Event |
Pours a given amount of liquid from a dispenser. The amount must be greater than 0. |
|
Pod → Station |
Request / Acknowledgement / Event |
Reports the amount poured, measured at rest, and how the pour ended as a |
|
Pod → Station |
Request / Acknowledgement / Event |
The amount so far during a pour or a calibration run. Never negative and only for display. |