Event Handling
This page covers the K3/K3S auto-information (AI) system, which allows the radio to push status changes to your application in real time. Understanding AI modes is key to building responsive software without resorting to constant polling.
For complete command syntax and all parameter details, see the K3/K3S/KX3/KX2 CAT Command Reference.
1. The Auto-Information System
Section titled “1. The Auto-Information System”The K3 can notify the computer when the operator changes settings on the front panel. This avoids constant polling and lets your application react immediately to operator actions.
AI Modes
Section titled “AI Modes”The AI command selects one of three notification modes:
- AI0 (default): Radio sends nothing unsolicited. You must poll for every piece of info.
- AI1: On any front-panel change, the radio sends the
IFresponse (the all-in-one status string). Simple but less granular — you must parse the IF response to determine what changed. - AI2 (recommended): On a front-panel change, the radio sends the specific response for what changed. If the operator changes frequency, you receive
FA00014200000;. If they change mode, you receiveMD2;. Much easier to handle programmatically.
2. Event Flow with AI2
Section titled “2. Event Flow with AI2”The following diagram shows how AI2 mode delivers targeted events for each front-panel action:
Key behavior:
- Auto-info responses are sent only for changes made via front panel (knobs, buttons).
- Changes made via CAT commands from the computer do not trigger auto-info responses.
- This prevents echo loops: PC sends command, K3 changes, K3 does not send a response back.
3. Polling Strategy (AI0)
Section titled “3. Polling Strategy (AI0)”When using AI0 mode (polling only), you must explicitly request every piece of information:
- Poll at a reasonable rate: 5—10 times per second is typically sufficient.
- Don’t flood the serial port — the K3 has a limited command buffer.
- Common polling pattern: cycle through
FA;,MD;,SM;,TQ;.
Loop every 200ms: FA; → read frequency MD; → read mode SM; → read S-meter TQ; → read TX state4. Handling Unsolicited Responses
Section titled “4. Handling Unsolicited Responses”When AI1 or AI2 is active, your serial read loop must handle data arriving at any time:
- Buffer incoming data — responses may arrive mid-command or between your polls.
- Parse on semicolons — split the input buffer on
;to isolate complete responses. - Identify the command prefix — the first 2—3 characters indicate which command/parameter changed.
- Route to handlers — dispatch to the appropriate handler based on the command prefix.
Pseudocode pattern:
buffer = ""while connected: buffer += serial.read() while ";" in buffer: message, buffer = buffer.split(";", 1) message += ";" prefix = message[0:2] handle_response(prefix, message)5. Common Auto-Info Events
Section titled “5. Common Auto-Info Events”The following table lists the most frequently seen auto-info responses in AI2 mode:
| Event | AI2 Response | Meaning |
|---|---|---|
| VFO A tuned | FA...; | Frequency changed |
| VFO B tuned | FB...; | VFO B frequency changed |
| Mode changed | MD.; | Operating mode changed |
| Band changed | BN..; then FA...; | Band switch + new frequency |
| Filter adjusted | BW....; or FW.......; | Bandwidth changed |
| AF gain adjusted | AG...; | Volume changed |
| Preamp toggled | PA.; | Preamp on/off |
| TX/RX change | TQ.; | Transmit state changed |
6. Combining Polling and Events
Section titled “6. Combining Polling and Events”Best practice: use AI2 for real-time updates, but still poll periodically for:
- S-meter readings (
SM;) — not sent as auto-info - SWR readings (
SW;) during transmit - Power meter readings (
BG;)
These metering values must always be polled since they change continuously and would flood the serial link if sent automatically.
7. The IF Command in Detail
Section titled “7. The IF Command in Detail”For AI1 mode, all events arrive as the IF response. Its fields (38 characters total):
IF[freq 11][5 spaces][rit offset 5][rit on][xit on][tx][mode][vfo][scan][split][tone][tone#][000];While AI2 is simpler for event-driven programming, the IF; command remains useful as a single-command snapshot of the radio’s complete state. Send IF; at connection time to initialize all your display fields at once, then rely on AI2 events for ongoing updates.
For the full field-by-field breakdown of the IF response, see the K3/K3S/KX3/KX2 CAT Command Reference.