From e3f0afc4273ec2d9ad9edff5001cd798b7034bb7 Mon Sep 17 00:00:00 2001 From: esarver Date: Fri, 20 Dec 2024 10:00:40 -0500 Subject: [PATCH] Remove TSP Command Calls When Getting Info (#35) We are unsure of whether the info command will be done when the instrument is in a TSP command mode. In TTI, the instrument could be in a SCPI mode. In which case the instrument needs to have the language switched before attempting to run TSP commands. --- CHANGELOG.md | 10 ++++++- Cargo.lock | 60 +++++++++++++++++++++--------------------- Cargo.toml | 2 +- src/instrument/info.rs | 8 +++--- src/instrument/mod.rs | 6 +++++ 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe22a9b..7a40768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,13 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how Security -- in case of vulnerabilities. --> +## [0.19.1] + +### Fixed + +- Don't call tsp commands in `get-info` because the `*LANG` of the instrument + might be set to something besides `TSP` + ## [0.19.0] ### Added @@ -113,7 +120,8 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how - Using `read_password` instead of `prompt_password` of rpassword crate (TSP-517) -[Unreleased]: https://github.com/tektronix/tsp-toolkit-kic-lib/compare/v0.19.0..HEAD +[Unreleased]: https://github.com/tektronix/tsp-toolkit-kic-lib/compare/v0.19.1..HEAD +[0.19.1]: https://github.com/tektronix/tsp-toolkit-kic-lib/releases/tag/v0.19.1 [0.19.0]: https://github.com/tektronix/tsp-toolkit-kic-lib/releases/tag/v0.19.0 [0.18.4]: https://github.com/tektronix/tsp-toolkit-kic-lib/releases/tag/v0.18.4 [0.18.3]: https://github.com/tektronix/tsp-toolkit-kic-lib/releases/tag/v0.18.3 diff --git a/Cargo.lock b/Cargo.lock index f9b2a94..1314662 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,9 +97,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" [[package]] name = "cc" -version = "1.2.3" +version = "1.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27f657647bcff5394bf56c7317665bbf790a137a50eaaa5c6bfbb9e27a518f2d" +checksum = "c31a0499c1dc64f458ad13872de75c0eb7e3fdb0e67964610c914b034fc5956e" dependencies = [ "shlex", ] @@ -126,12 +126,12 @@ dependencies = [ [[package]] name = "colored" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -368,9 +368,9 @@ checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "hyper" -version = "1.5.1" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97818827ef4f364230e16705d4706e2897df2bb60617d6ca15d598025a3c481f" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.3" +version = "0.27.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +checksum = "f6884a48c6826ec44f524c7456b163cebe9e55a18d7b5e307cb4f100371cc767" dependencies = [ "futures-util", "http", @@ -640,9 +640,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.168" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "linux-raw-sys" @@ -685,9 +685,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394" dependencies = [ "adler2", ] @@ -904,9 +904,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "predicates" -version = "3.1.2" +version = "3.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" +checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" dependencies = [ "anstyle", "predicates-core", @@ -914,15 +914,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8177bee8e75d6846599c6b9ff679ed51e882816914eec639944d7c9aa11931" +checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" [[package]] name = "predicates-tree" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b740d195ed3166cd147c8047ec98db0e22ec019eb8eeb76d343b795304fb13" +checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" dependencies = [ "predicates-core", "termtree", @@ -1093,9 +1093,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37" [[package]] name = "rustls-webpki" @@ -1155,9 +1155,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" +checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" dependencies = [ "core-foundation-sys", "libc", @@ -1357,24 +1357,24 @@ dependencies = [ [[package]] name = "termtree" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" [[package]] name = "thiserror" -version = "2.0.6" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" +checksum = "08f5383f3e0071702bf93ab5ee99b52d26936be9dedd9413067cbdcddcb6141a" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.6" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" +checksum = "f2f357fcec90b3caef6623a099691be676d033b40a058ac95d2a6ade6fa0c943" dependencies = [ "proc-macro2", "quote", @@ -1501,7 +1501,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tsp-toolkit-kic-lib" -version = "0.19.0" +version = "0.19.1" dependencies = [ "anyhow", "bytes", diff --git a/Cargo.toml b/Cargo.toml index e3a08be..000dd83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tsp-toolkit-kic-lib" description = "A library specifically enabling communication to the Keithley product-line of instruments" -version = "0.19.0" +version = "0.19.1" authors = ["Keithley Instruments, LLC"] edition = "2021" repository = "https://github.com/tektronix/tsp-toolkit-kic-lib" diff --git a/src/instrument/info.rs b/src/instrument/info.rs index 6b7b5ff..c789edd 100644 --- a/src/instrument/info.rs +++ b/src/instrument/info.rs @@ -1,6 +1,6 @@ //! Define the trait and datatypes necessary to describe an instrument. use minidom::Element; -use tracing::{instrument, trace}; +use tracing::{debug, instrument, trace}; use crate::{error::Result, InstrumentError}; use std::{ @@ -11,8 +11,6 @@ use std::{ use crate::interface::connection_addr::ConnectionAddr; -use super::clear_output_queue; - /// The information about an instrument. #[allow(clippy::module_name_repetitions)] #[derive(serde::Serialize, Debug, Default, Clone, PartialEq, Eq, Hash)] @@ -40,11 +38,13 @@ pub struct InstrumentInfo { #[allow(clippy::module_name_repetitions)] #[instrument(skip(rw))] pub fn get_info(rw: &mut T) -> Result { + debug!("Sending abort"); rw.write_all(b"abort\n")?; std::thread::sleep(Duration::from_millis(100)); + debug!("Sending *CLS"); rw.write_all(b"*CLS\n")?; std::thread::sleep(Duration::from_millis(100)); - clear_output_queue(rw, 1000, Duration::from_millis(1))?; + debug!("Sending *IDN?"); rw.write_all(b"*IDN?\n")?; let mut info: Option = None; for _ in 0..100 { diff --git a/src/instrument/mod.rs b/src/instrument/mod.rs index 8b2df0c..e801843 100644 --- a/src/instrument/mod.rs +++ b/src/instrument/mod.rs @@ -21,6 +21,7 @@ pub use language::{CmdLanguage, Language}; pub use login::{Login, State}; pub use reset::Reset; pub use script::Script; +use tracing::debug; /// A marker trait that defines the traits any [`Instrument`] needs to have. pub trait Instrument: @@ -30,6 +31,10 @@ pub trait Instrument: /// Read from a 'rw' until we are sure we have cleared the output queue. /// +/// # Warning +/// This functions calls a TSP command and therefore should not be used before +/// we know whether the instrument is in TSP mode (only applicable for TTI) +/// /// # Errors /// Whatever can errors can occur with [`std::io::Read`], [`std::io::Write`] or /// [`tsp_toolkit_kic_lib::interface::NonBlock`]. @@ -40,6 +45,7 @@ pub fn clear_output_queue( ) -> Result<()> { let timestamp = chrono::Utc::now().to_string(); + debug!("Sending print({timestamp})"); rw.write_all(format!("print(\"{timestamp}\")\n").as_bytes())?; let mut accumulate = String::new();