Change from list to info
This commit is contained in:
@@ -17,8 +17,8 @@ pub struct RtlSdrDevice {
|
||||
}
|
||||
|
||||
impl RtlSdrDevice {
|
||||
/// List devices
|
||||
pub fn list() {
|
||||
/// Display dongle information
|
||||
pub fn info(vid: u16, pid: u16) {
|
||||
let device_list = match DeviceList::new() {
|
||||
Ok(d) => d,
|
||||
Err(err) => {
|
||||
@@ -29,6 +29,9 @@ impl RtlSdrDevice {
|
||||
for device in device_list.iter() {
|
||||
match device.device_descriptor() {
|
||||
Ok(device_desc) => {
|
||||
if vid != device_desc.vendor_id() && pid != device_desc.product_id() {
|
||||
continue;
|
||||
}
|
||||
println!(
|
||||
"Bus: {:03}, Device: {:03} VID: 0x{:04X}, PID: 0x{:04X}",
|
||||
device.bus_number(),
|
||||
|
||||
@@ -21,9 +21,9 @@ struct ReceiverArgs {
|
||||
#[arg(short = 'c', long, action)]
|
||||
connect: bool,
|
||||
|
||||
/// List USB devices
|
||||
#[arg(short = 'l', long, action)]
|
||||
list: bool,
|
||||
/// Display ADS-B/Mode-S receiver info
|
||||
#[arg(short = 'i', long, action)]
|
||||
info: bool,
|
||||
|
||||
/// Enable debug logging
|
||||
#[arg(short = 'D', long, action)]
|
||||
@@ -41,15 +41,18 @@ fn main() -> Result<()> {
|
||||
|
||||
env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", default_filter));
|
||||
|
||||
let vid = 0x0BDA;
|
||||
let pid = 0x2832;
|
||||
|
||||
// Handle connection
|
||||
if args.connect {
|
||||
log::info!("Connecting to device");
|
||||
let mut device = RtlSdrDevice::open(0x0BDA, 0x2832)?;
|
||||
let mut device = RtlSdrDevice::open(vid, pid)?;
|
||||
device.read(TransferType::Bulk)
|
||||
}
|
||||
// List devices
|
||||
else if args.list {
|
||||
RtlSdrDevice::list();
|
||||
// Display dongle info
|
||||
else if args.info {
|
||||
RtlSdrDevice::info(vid, pid);
|
||||
Ok(())
|
||||
}
|
||||
// Handle decode mode
|
||||
|
||||
Reference in New Issue
Block a user