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.
audio_capabilities()
staticmethod
¶
Return icom-lan audio capabilities and deterministic defaults.
connect()
¶
Connect to the radio (blocking).
disconnect()
¶
Disconnect from the radio (blocking).
get_alc()
¶
Read the ALC meter (0-255).
get_attenuator()
¶
Read attenuator state.
get_attenuator_level()
¶
Read attenuator level in dB.
get_audio_stats()
¶
Return runtime audio stats for the active stream.
get_digisel()
¶
Read DIGI-SEL status.
get_filter()
¶
Get current filter number (1-3) when available.
get_frequency()
¶
Get the current operating frequency in Hz.
get_mode()
¶
Get the current operating mode.
get_mode_info()
¶
Get current mode and filter number (if reported).
get_power()
¶
Get the RF power level (0-255).
get_preamp()
¶
Read preamp level (0=off, 1=PREAMP1, 2=PREAMP2).
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)
¶
Deprecated alias for :meth:push_audio_tx_opus.
push_audio_tx_opus(opus_data)
¶
Send an Opus audio frame to the radio.
restore_state(state)
¶
Best-effort restore of snapshot_state().
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_attenuator_level(db)
¶
Set attenuator level in dB.
set_digisel(on)
¶
Set DIGI-SEL status.
set_filter(filter_width)
¶
Set filter number (1-3) while keeping current mode.
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.
snapshot_state()
¶
Best-effort snapshot of core rig state.
start_audio_rx(callback)
¶
Deprecated alias for :meth:start_audio_rx_opus.
start_audio_rx_opus(callback, *, jitter_depth=5)
¶
Start receiving Opus audio from the radio (blocking setup).
start_audio_tx()
¶
Deprecated alias for :meth:start_audio_tx_opus.
start_audio_tx_opus()
¶
Start Opus TX audio.
stop_audio_rx()
¶
Deprecated alias for :meth:stop_audio_rx_opus.
stop_audio_rx_opus()
¶
Stop Opus RX audio.
stop_audio_tx()
¶
Deprecated alias for :meth:stop_audio_tx_opus.
stop_audio_tx_opus()
¶
Stop Opus TX 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()}")
Common sync helpers¶
mode, filt = radio.get_mode_info()
radio.set_filter(2)
att_db = radio.get_attenuator_level() # dB (0–45)
att_on = radio.get_attenuator() # bool
pre = radio.get_preamp() # 0, 1, or 2
radio.set_attenuator_level(18) # 18 dB
radio.set_preamp(1) # PREAMP 1
state = radio.snapshot_state()
radio.restore_state(state)
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.