rfe 0.1.0

Communicate with RF Explorer spectrum analyzers and signal generators over USB serial
Documentation

rfe

crates.io docs.rs CI MSRV: 1.88

rfe is a Rust library for communicating with RF Explorer spectrum analyzers and signal generators over a USB virtual serial port.

Usage

Add the following to your Cargo.toml:

[dependencies]
rfe = "0.1.0"

Connecting to an RF Explorer

rfe can search for an attached RF Explorer without knowing its port name or baud rate. It tries USB serial ports with the VID and PID used by the RF Explorer's Silicon Labs CP210x USB-to-UART bridge.

use rfe::{SignalGenerator, SpectrumAnalyzer};

let spectrum_analyzer = SpectrumAnalyzer::connect()?;
let signal_generator = SignalGenerator::connect()?;

You can also connect to a known serial port and baud rate.

use rfe::{SignalGenerator, SpectrumAnalyzer};

let spectrum_analyzer = SpectrumAnalyzer::connect_with_name_and_baud_rate("COM2", 500_000)?;
let signal_generator = SignalGenerator::connect_with_name_and_baud_rate("COM1", 500_000)?;

Collecting spectrum analyzer sweeps

rfe provides three APIs for reading spectrum analyzer sweeps.

Waiting for the next sweep

SpectrumAnalyzer::wait_for_next_sweep() blocks until the device reports a new sweep or the timeout elapses.

use rfe::SpectrumAnalyzer;

let rfe = SpectrumAnalyzer::connect()?;
let sweep = rfe.wait_for_next_sweep()?;
println!("{:?}", sweep);

Reading the latest cached sweep

SpectrumAnalyzer::sweep() returns the most recently measured sweep, or None if no sweep has been received yet.

use rfe::SpectrumAnalyzer;

let rfe = SpectrumAnalyzer::connect()?;
let sweep = rfe.sweep();

Receiving sweeps with a callback

SpectrumAnalyzer::set_sweep_callback() registers a callback that runs on a separate thread whenever a sweep is received.

use rfe::SpectrumAnalyzer;

let rfe = SpectrumAnalyzer::connect()?;
rfe.set_sweep_callback(|sweep, start_freq, stop_freq| {
    println!("Received sweep from {}-{} MHz", start_freq.as_mhz(), stop_freq.as_mhz());
    println!("{sweep:?}");
});

Generating a signal with an RF Explorer Signal Generator

use rfe::{
    signal_generator::{Attenuation, PowerLevel, SignalGenerator},
    Frequency,
};

let rfe = SignalGenerator::connect()?;
rfe.start_cw(Frequency::from_mhz(2412), Attenuation::Off, PowerLevel::Low)?;

Examples

Run the included examples with:

cargo run -p rfe --example rfe_info
cargo run -p rfe --example rfe_sweep
cargo run -p rfe --example rfe_sweep_with_callback

Troubleshooting

rfe uses the tracing crate to emit structured, event-based diagnostic information that can be collected by executables using the rfe library.

On Linux, the current user usually needs serial port access through the dialout or uucp group. See the top-level README for platform setup details.

License

This project is dual-licensed under the MIT License or Apache 2.0 License.