Connection
The handshake confirms the serial device is a Medius box speaking a supported protocol version: one request, one reply.
- No baud negotiation.
- No login.
- No
115200startup step or baud-switch command.
HandshakeOne round-trip
- Open the port at
6,000,000baud (Transport); framed binary from the first byte. - Catch the unsolicited hello (below) or send
QUERY(VERSION); both produce the sameRESP(VERSION)frame. - Check that reply's
proto_veris9.
| Reply | Meaning |
|---|---|
proto_ver == 9 | Speaks the protocol these pages describe. |
proto_ver != 9 | Speaks a protocol these pages don't cover; commands may behave otherwise. |
| No reply | Not a Medius box, or wrong port or baud. |
The check is mandatory. Firmware 3.1.x and earlier report 4. In proto 4, LOCK's last byte is a state (1 = lock, 0 = unlock), not a scale.
a proto-9 host talking to a proto-4 box scale = 100 (unlock) -> state = 100, non-zero -> LOCKS it scale = 0 (block) -> state = 0 -> UNLOCKS it
RESP(VERSION)
| Offset | Field | Type | Notes |
|---|---|---|---|
| 0 | what | u8 | selector, echoed; 0x00 = VERSION |
| 1 | proto_ver | u8 | protocol version, expected 9 |
| 2 | fw_major | u8 | firmware major |
| 3 | fw_minor | u8 | firmware minor |
| 4 | fw_patch | u8 | firmware patch |
| 5 | mac | u8[6] | box MAC, a stable per-box id |
| 11.. | name | ascii | human-readable box name (may be empty), delimited by the frame LEN |
Ready hello Unsolicited RESP(VERSION), twice per boot
Treat either hello as ready and skip the QUERY(VERSION).
| Trigger | When |
|---|---|
| Power-on | Once, as the device chip boots, before any other frame. |
| First contact | Once, on the first valid frame after boot, before that frame's reply. If another program has already sent a frame, a program opening the port gets neither hello and sends QUERY(VERSION). |
device chip boots --> hello, SEQ 0 first valid frame --> hello, SEQ 0, then that frame's reply every later frame --> no hello device chip restarts --> hello at boot, and again on the next frame
The hello carries SEQ=0 and the same payload as a queried reply. A hello mid-session means the device chip restarted and lost its session state, such as locks and rewrite rules.
The medius library's open and find do all of this: send QUERY(VERSION) up to 5 times, waiting 250 ms for each reply, and check proto_ver == 9 before returning a connection.