Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.18.2 #35

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ jobs:
LIB_VISA_PATH: "${{github.workflow}}"
steps:
- name: Tool Setup
run: rustup update nightly && rustup default nightly
# rustc regression: https://github.com/rust-lang/rust/issues/130769
# Change to "update nightly" after resolved
run: rustup install nightly-2024-09-23 && rustup default nightly-2024-09-23
- name: Ensure Correct Target is Installed
run: rustup target add ${{matrix.triple}}
- name: Tool Versions
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
Security -- in case of vulnerabilities.
-->

## [0.18.2]

### Fixed

- Fix issue in discovering instruments when VISA errors

## [0.18.1]

### Fixed
Expand Down
38 changes: 19 additions & 19 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.18.1"
version = "0.18.2"
authors = ["Keithley Instruments, LLC"]
edition = "2021"
repository = "https://github.com/tektronix/tsp-toolkit-kic-cli"
Expand Down
34 changes: 27 additions & 7 deletions kic-discover-visa/src/visa.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{collections::HashSet, ffi::CString, time::Duration};

use async_std::fs::write;
use serde::{Deserialize, Serialize};
use tracing::trace;
use tracing::{error, trace};
use tsp_toolkit_kic_lib::{
instrument::info::{get_info, InstrumentInfo},
interface::connection_addr::ConnectionAddr,
Expand All @@ -14,19 +15,38 @@ use crate::{insert_disc_device, model_check, IoType};
pub async fn visa_discover(timeout: Option<Duration>) -> anyhow::Result<HashSet<InstrumentInfo>> {
let mut discovered_instruments: HashSet<InstrumentInfo> = HashSet::new();

let rm = visa_rs::DefaultRM::new()?;
let instruments = rm.find_res_list(&CString::new("?*")?.into())?;
let Ok(rm) = visa_rs::DefaultRM::new() else {
error!("Unable to get VISA Default Resource Manager");
return Ok(discovered_instruments);
};
let instruments = match rm.find_res_list(&CString::new("?*")?.into()) {
Ok(x) => x,
Err(e) => {
trace!("No VISA instruments found: {e}");
return Ok(discovered_instruments);
}
};
trace!("discovered: {instruments:?}");

for i in instruments {
let i = i?;
if i.to_string().contains("SOCKET") {
let Ok(i) = i else {
continue;
};
if i.to_string().contains("SOCKET") || i.to_string().contains("INTFC") {
continue;
}
trace!("Connecting to {i:?} to get info");
let mut connected = rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE)?;
let Ok(mut connected) = rm.open(&i, AccessMode::NO_LOCK, visa_rs::TIMEOUT_IMMEDIATE) else {
trace!("Resource {i} no longer available, skipping.");
continue;
};

trace!("Getting info from {connected:?}");
let mut info = get_info(&mut connected)?;
let Ok(mut info) = get_info(&mut connected) else {
trace!("Unable to write to {i}, skipping");
drop(connected);
continue;
};
info.address = Some(ConnectionAddr::Visa(i.clone()));
trace!("Got info: {info:?}");
let res = model_check(info.clone().model.unwrap_or("".to_string()).as_str());
Expand Down
Loading