Sync API - icom-lan
Description: Python library for controlling Icom transceivers over LAN

Skip to content

# Synchronous API

Blocking wrapper around the async `IcomRadio` for use without `async/await`.

### `icom_lan.sync.IcomRadio`

Synchronous (blocking) wrapper for Icom radio LAN control.

Wraps the async :class:`~icom_lan.radio.IcomRadio` with a dedicated event loop. All methods block until the operation completes.

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`host` | `str` | Radio IP address or hostname. | required
`port` | `int` | Control port (default 50001). | `50001`
`username` | `str` | Authentication username. | `''`
`password` | `str` | Authentication password. | `''`
`radio_addr` | `int` | CI-V address of the radio (default IC-7610 = 0x98). | `152`
`timeout` | `float` | Operation timeout in seconds. | `5.0`
`audio_codec` | `AudioCodec | int` | Audio codec (default PCM 1ch 16-bit). | `PCM_1CH_16BIT`
`audio_sample_rate` | `int` | Audio sample rate in Hz. | `48000`

#### `audio_codec` `property`

Configured audio codec.

#### `audio_sample_rate` `property`

Configured audio sample rate.

#### `connected` `property`

Whether the radio is currently connected.

#### `connect()`

Connect to the radio (blocking).

#### `disconnect()`

Disconnect from the radio (blocking).

#### `get_alc()`

Read the ALC meter (0-255).

#### `get_frequency()`

Get the current operating frequency in Hz.

#### `get_mode()`

Get the current operating mode.

#### `get_power()`

Get the RF power level (0-255).

#### `get_s_meter()`

Read the S-meter value (0-255).

#### `get_swr()`

Read the SWR meter (0-255).

#### `power_control(on)`

Power on/off the radio.

#### `push_audio_tx(opus_data)`

Send an audio frame to the radio.

#### `select_vfo(vfo='A')`

Select VFO (A, B, MAIN, SUB).

#### `send_cw_text(text)`

Send CW text.

#### `set_attenuator(on)`

Enable or disable the attenuator.

#### `set_frequency(freq_hz)`

Set the operating frequency in Hz.

#### `set_mode(mode, filter_width=None)`

Set the operating mode.

#### `set_power(level)`

Set the RF power level (0-255).

#### `set_preamp(level=1)`

Set preamp level (0=off, 1=PREAMP1, 2=PREAMP2).

#### `set_ptt(on)`

Enable or disable PTT.

#### `set_split_mode(on)`

Enable or disable split mode.

#### `start_audio_rx(callback)`

Start receiving audio from the radio (blocking setup).

#### `start_audio_tx()`

Start transmitting audio.

#### `stop_audio_rx()`

Stop receiving audio.

#### `stop_audio_tx()`

Stop transmitting audio.

#### `stop_cw_text()`

Stop CW sending.

#### `vfo_equalize()`

Copy VFO A to VFO B.

#### `vfo_exchange()`

Swap VFO A and B.

## Usage

    from icom_lan.sync import IcomRadio

    with IcomRadio("192.168.1.100", username="u", password="p") as radio:
        freq = radio.get_frequency()
        print(f"Frequency: {freq:,} Hz")

        radio.set_frequency(14_074_000)
        radio.set_mode("USB")

        print(f"S-meter: {radio.get_s_meter()}")
        print(f"SWR: {radio.get_swr()}")

When to use sync vs async

Use the sync API for simple scripts, CLI tools, and Jupyter notebooks. Use the async API for applications that need concurrent operations, real-time audio streaming, or integration with async frameworks.