Skip to content

Commit

Permalink
Add 'kic-visa' Executable and call into it if visa is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
esarver committed Aug 22, 2024
1 parent 5ff35ba commit b8c25b7
Show file tree
Hide file tree
Showing 9 changed files with 1,248 additions and 90 deletions.
153 changes: 97 additions & 56 deletions Cargo.lock

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[workspace]
members = [
"kic",
"kic-visa",
"kic-discover",
"instrument-repl",
]
Expand Down Expand Up @@ -44,6 +45,9 @@ 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", branch = "task/implement-visa" }

[workspace.features]
visa = ["tsp-toolkit-kic-lib/visa"]

[workspace.lints.rust]
warnings = "deny"

Expand All @@ -56,3 +60,6 @@ arithmetic_side_effects = "deny"
[workspace.lints.rustdoc]
all = "warn"
missing_doc_code_examples = "warn"

[patch."https://github.com/tektronix/tsp-toolkit-kic-lib.git"]
tsp-toolkit-kic-lib = { path="../tsp-toolkit-kic-lib" }
11 changes: 1 addition & 10 deletions instrument-repl/src/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,16 +633,7 @@ impl Repl {
});
};
let file = file.clone();
let Ok(file) = file.parse::<PathBuf>() else {
return Ok(Request::Usage(
InstrumentReplError::CommandError {
details: format!(
"expected file path, but unable to parse from \"{file}\""
),
}
.to_string(),
));
};
let file = file.parse::<PathBuf>().unwrap(); //PathBuf::parse is infallible so unwrapping is OK here.

if !file.is_file() {
return Ok(Request::Usage(
Expand Down
2 changes: 2 additions & 0 deletions kic-discover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tsp-toolkit-kic-lib = { workspace = true }

[features]
visa=["tsp-toolkit-kic-lib/visa"]
26 changes: 26 additions & 0 deletions kic-visa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "kic-visa"
description = "Keithley Instruments TSP® communications commandline application with VISA support."
version = { workspace = true }
authors = { workspace = true }
edition = { workspace = true }
repository = { workspace = true }

[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
colored = { workspace = true }
instrument-repl = { workspace = true }
rpassword = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
tsp-toolkit-kic-lib = { workspace = true, features=["visa"] }
regex = "1.10.3"
windows-sys = { version = "0.52.0", features = [
"Win32_System_Console",
"Win32_Foundation",
] }

18 changes: 18 additions & 0 deletions kic-visa/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use thiserror::Error;

/// Define errors that originate from this crate
#[derive(Error, Debug)]
#[allow(clippy::module_name_repetitions)]
pub enum KicError {
/// The user didn't provide required information or the information provided was
/// invalid
#[error("Error parsing arguments: {details}")]
ArgParseError {
/// The reason why the arguments failed to parse.
details: String,
},

/// Another user must relinquish the instrument before it can be logged into.
#[error("there is another session connected to the instrument that must logout")]
InstrumentLogoutRequired,
}
Loading

0 comments on commit b8c25b7

Please sign in to comment.