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