
API Fundamentals: IP & Serial Commands, Drivers & Feedback Parsing
Learning objectives
- Explain what an AV device API is.
- Distinguish IP and serial command patterns.
- Use a driver to encapsulate a device's command set.
- Parse feedback strings into state.
Vocabulary
- API
- The set of commands and responses a device accepts and returns.
- Driver
- A module that wraps a device's command set so logic can use it generically.
- Command string
- The bytes sent to a device (e.g. 'PON\r' to power on).
- Feedback parsing
- Turning a device's response string into usable state.
- Delimiter
- A character marking the end of a command or response (e.g. \r or \n).
Lesson content
Every controllable device speaks an API: a set of commands it accepts and responses it returns. You program by sending commands and reading responses — over serial or IP.
Command patterns
Serial display:
send "PON\r" // power on
send "POF\r" // power off
send "INP 1\r" // select input 1
reply "OK" // ack
IP codec (illustrative):
send JSON { "cmd": "dial", "uri": "meet@..." }
reply JSON { "ok": true, "callId": 123 }Drivers
- A driver wraps a device's commands and feedback so your logic can say
display.powerOn()instead of formatting strings. - Drivers handle delimiters, retries, and feedback parsing.
- Use the manufacturer's driver where available; write a clean one if not.
- Keep the driver's interface generic so you can swap device models with minimal logic changes.
Feedback parsing
- 1Read the response bytes as they arrive.
- 2Split on the delimiter to get complete messages.
- 3Match each message to a state field (power, input, volume).
- 4Update variables and the UI from the parsed state.
Serial/IP responses can arrive in fragments (one response split across packets). Buffer until the delimiter, then parse. Parsing a fragment drops state and causes the panel to lie.
Worked example
A display driver sends 'PON\r', waits for 'OK' or the power-state query response, sets displayPower = ON, and updates the panel. If no response in 3 seconds, it retries once, then reports a display error to the panel.
Implementation checklist
- ✓Device API documented per device.
- ✓Driver wraps commands and parsing; logic uses generic calls.
- ✓Feedback buffered until delimiter, then parsed.
- ✓Non-response handled with retry then error.
Downloadable study guide
01. API = commands + responses over serial or IP. 02. Driver wraps a device so logic calls display.powerOn(), not raw strings. 03. Buffer fragments until the delimiter; parse complete messages only. 04. Handle non-response with retry then a clear error state.