Python API Reference
The Python bindings provide a high-level interface to the libadrv9002-iio profile generator. Configuration is done through structured objects that mirror the underlying C API, and profile generation is a single function call that returns the profile JSON and stream binary as byte strings.
Installation
pip install adrv9002
Configuration Objects
adrv9002.rx_radio_channel_config
RX channel configuration structure.
Field |
Type |
Description |
|---|---|---|
|
bool |
Enable RX channel |
|
bool |
Enable ADC high performance mode |
|
bool |
Enable frequency offset correction |
|
int |
Analog filter power mode (0=low, 1=med, 2=high) |
|
bool |
Enable analog filter biquad |
|
int |
Analog filter bandwidth in Hz |
|
int |
Channel bandwidth in Hz |
|
int |
Sample rate in Hz |
|
bool |
Enable NCO |
|
int |
NCO frequency in Hz |
|
int |
RF port (0=RX-A, 1=RX-B) |
adrv9002.tx_radio_channel_config
TX channel configuration structure.
Field |
Type |
Description |
|---|---|---|
|
bool |
Enable TX channel |
|
int |
Sample rate in Hz |
|
bool |
Enable frequency offset correction |
|
int |
Analog filter power mode (0=low, 1=med, 2=high) |
|
int |
Channel bandwidth in Hz |
|
bool |
Enable observation receiver |
|
int |
External loopback type |
adrv9002.radio_config
Radio configuration structure containing SSI interface settings and channel configs.
Field |
Type |
Description |
|---|---|---|
|
int |
Number of SSI lanes (1, 2, or 4) |
|
bool |
Enable double data rate |
|
bool |
Enable short strobe mode |
|
bool |
LVDS (True) or CMOS (False) interface |
|
int |
ADC rate mode (0=LP, 1=MP, 2=HP, 3=UHP) |
|
bool |
Frequency Division Duplex mode |
|
list |
Array of 2 |
|
list |
Array of 2 |
adrv9002.clock_config
Clock configuration structure.
Field |
Type |
Description |
|---|---|---|
|
int |
Device clock input frequency (kHz) |
|
bool |
Enable device clock output |
|
int |
Device clock output divider |
|
bool |
PLL high performance mode |
|
int |
Clock PLL power mode |
|
int |
Processor clock divider (1-256, powers of 2) |
adrv9002.adrv9002_config
Top-level configuration structure combining radio and clock settings.
Field |
Type |
Description |
|---|---|---|
|
|
Radio configuration |
|
|
Clock configuration |
Functions
adrv9002.generate_profile(cfg)
Generate a profile and stream image from configuration.
Parameters:
cfg(adrv9002_config) — Fully populated configuration structure
Returns:
tuple[bytes, bytes]—(profile_json, stream_image)where:profile_json: JSON profile as bytes (UTF-8 encoded)stream_image: Binary stream image (may be empty if stream resources unavailable)
Raises:
OSError— If profile generation fails (checkerrnofor error code)
Example:
import adrv9002
cfg = adrv9002.adrv9002_config()
# ... populate cfg ...
profile_json, stream_bin = adrv9002.generate_profile(cfg)
adrv9002.generate_load_profile_iio(cfg, uri)
Generate a profile and load it directly onto hardware via IIO.
Note
Only available when the library is built with IIO support.
Parameters:
cfg(adrv9002_config) — Fully populated configuration structureuri(str) — IIO context URI (e.g.,"ip:192.168.2.1")
Returns:
None
Raises:
OSError— If generation or loading fails
Example:
import adrv9002
cfg = adrv9002.adrv9002_config()
# ... populate cfg ...
adrv9002.generate_load_profile_iio(cfg, "ip:192.168.2.1")