Skip to content

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.

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.

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 IF response (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 receive MD2;. Much easier to handle programmatically.

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.

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 state

When AI1 or AI2 is active, your serial read loop must handle data arriving at any time:

  1. Buffer incoming data — responses may arrive mid-command or between your polls.
  2. Parse on semicolons — split the input buffer on ; to isolate complete responses.
  3. Identify the command prefix — the first 2—3 characters indicate which command/parameter changed.
  4. 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)

The following table lists the most frequently seen auto-info responses in AI2 mode:

EventAI2 ResponseMeaning
VFO A tunedFA...;Frequency changed
VFO B tunedFB...;VFO B frequency changed
Mode changedMD.;Operating mode changed
Band changedBN..; then FA...;Band switch + new frequency
Filter adjustedBW....; or FW.......;Bandwidth changed
AF gain adjustedAG...;Volume changed
Preamp toggledPA.;Preamp on/off
TX/RX changeTQ.;Transmit state changed

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.

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.