Skip to content

Commit

Permalink
Remove usbtmc
Browse files Browse the repository at this point in the history
  • Loading branch information
esarver committed Oct 9, 2024
1 parent 9e345c9 commit 20c6371
Show file tree
Hide file tree
Showing 15 changed files with 7 additions and 635 deletions.
40 changes: 1 addition & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ phf = { version = "0.11.2", features = ["macros"] }
regex = "1.10.3"
reqwest = "0.12.0"
rpassword = "7.3.1"
rusb = "0.9.3"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
thiserror = "1.0.58"
tmc = { git = "https://github.com/esarver/rusb-usbtmc" }
tracing = { version = "0.1.40", features = ["async-await"] }
tracing-subscriber = { version = "0.3.18", features = ["json"] }
tsp-toolkit-kic-lib = { git = "https://github.com/tektronix/tsp-toolkit-kic-lib.git", tag = "v0.18.2-0" }
tsp-toolkit-kic-lib = { git = "https://github.com/tektronix/tsp-toolkit-kic-lib.git", tag = "v0.18.2-1" }

[workspace.lints.rust]
warnings = "deny"
Expand Down
2 changes: 0 additions & 2 deletions kic-discover-visa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ mdns = { workspace = true } # until https://github.com/d
minidom = { workspace = true }
reqwest = { workspace = true }
rpassword = { workspace = true }
rusb = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tmc = { workspace = true }
tokio = { version = "1.36.0", features = ["full"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
Expand Down
22 changes: 0 additions & 22 deletions kic-discover-visa/src/instrument_discovery/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use tsp_toolkit_kic_lib::{
};

use crate::ethernet::{LxiDeviceInfo, COMM_PORT};
use crate::usbtmc::Usbtmc;
use crate::visa::visa_discover;

#[derive(Debug)]
Expand Down Expand Up @@ -62,27 +61,6 @@ impl InstrumentDiscovery {
Ok(discovery_results)
}

/// Discover instruments over USB
///
/// # Errors
/// If [`Usbtmc::usb_discover`] fails, and error will be returned.
pub async fn usb_discover(&self) -> anyhow::Result<HashSet<InstrumentInfo>> {
let mut discovery_results: HashSet<InstrumentInfo> = HashSet::new();

match Usbtmc::usb_discover(self.timeout).await {
Ok(instrs) => {
for inst in instrs {
discovery_results.insert(inst);
}
}
Err(e) => {
eprintln!("Unable to discover USB devices: {e}"); //TODO add color
return Err(e);
}
}
Ok(discovery_results)
}

pub async fn visa_discover(&self) -> anyhow::Result<HashSet<InstrumentInfo>> {
visa_discover(self.timeout).await
}
Expand Down
3 changes: 1 addition & 2 deletions kic-discover-visa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::{collections::HashSet, hash::Hash, io::Error, sync::Mutex};

pub mod ethernet;
pub mod instrument_discovery;
pub mod usbtmc;
pub mod visa;

#[macro_use]
Expand Down Expand Up @@ -128,6 +127,6 @@ pub fn insert_disc_device(device: &str) -> Result<(), Error> {
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Hash, serde::Serialize, serde::Deserialize)]
enum IoType {
Lan,
Usb,
Visa,
Usb,
}
46 changes: 0 additions & 46 deletions kic-discover-visa/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ struct Cli {
enum SubCli {
/// Look for all devices connected on LAN
Lan(DiscoverCmd),

/// Look for all devices connected on USB
//Usb(DiscoverCmd),

/// Look for all devices that can be connected to via the installed VISA driver
Visa(DiscoverCmd),
/// Look for all devices on all interface types.
Expand Down Expand Up @@ -264,24 +260,6 @@ async fn main() -> anyhow::Result<()> {
trace!("Discovered instruments: {lan_instruments:?}");
lan_instruments
}
//SubCli::Usb(args) => {
// start_logger(&args.verbose, &args.log_file, &args.log_socket)?;
// info!("Discovering USB instruments");
// #[allow(clippy::mutable_key_type)]
// let usb_instruments = match discover_usb().await {
// Ok(i) => i,
// Err(e) => {
// error!("Error in USB discovery: {e}");
// return Err(e);
// }
// };
// info!("USB Discovery complete");
// trace!("Discovered {} USB instruments", usb_instruments.len());
// trace!("Discovered instruments: {usb_instruments:?}");
// for instrument in usb_instruments {
// println!("{instrument}");
// }
//}
SubCli::Visa(args) => {
start_logger(&args.verbose, &args.log_file, &args.log_socket)?;
info!("Discovering VISA instruments");
Expand All @@ -300,22 +278,6 @@ async fn main() -> anyhow::Result<()> {
}
SubCli::All(args) => {
start_logger(&args.verbose, &args.log_file, &args.log_socket)?;
//info!("Discovering USB instruments");
//#[allow(clippy::mutable_key_type)]
//let usb_instruments = match discover_usb().await {
// Ok(i) => i,
// Err(e) => {
// error!("Error in USB discovery: {e}");
// return Err(e);
// }
//};
//info!("USB Discovery complete");
//trace!("Discovered {} USB instruments", usb_instruments.len());
//println!("Discovered {} USB instruments", usb_instruments.len());
//trace!("Discovered USB instruments: {usb_instruments:?}");
//for instrument in usb_instruments {
// println!("{instrument}");
//}

info!("Discovering VISA instruments");
#[allow(clippy::mutable_key_type)]
Expand Down Expand Up @@ -424,11 +386,3 @@ async fn discover_visa(args: DiscoverCmd) -> anyhow::Result<HashSet<InstrumentIn

Ok(instruments)
}

//async fn discover_usb() -> anyhow::Result<HashSet<InstrumentInfo>> {
// let dur = Duration::from_secs(5); //Not used in USB
// let discover_instance = InstrumentDiscovery::new(dur);
// let instruments = discover_instance.usb_discover().await?;
//
// Ok(instruments)
//}
Loading

0 comments on commit 20c6371

Please sign in to comment.