From 9e345c9b4e5354fa2afc4eef4c9c9a210ffa5fdc Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Wed, 9 Oct 2024 12:42:43 -0400 Subject: [PATCH 1/3] Add macOS support for LAN --- .github/workflows/pr.yml | 21 ++-- CHANGELOG.md | 4 + Cargo.lock | 205 +++++++++++++++++++-------------------- Cargo.toml | 2 +- 4 files changed, 118 insertions(+), 114 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9c11818..529118e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -174,9 +174,9 @@ jobs: - runner: windows-latest triple: x86_64-pc-windows-msvc vscode-platform: win32-x64 - # - runner: macos-latest - # triple: x86_64-apple-darwin - # vscode-platform: darwin-arm64 + - runner: macos-latest + triple: aarch64-apple-darwin + vscode-platform: darwin-arm64 runs-on: ${{matrix.runner}} env: RUSTFLAGS: "-L ${{github.workspace}}" @@ -198,11 +198,16 @@ jobs: repository: tektronix/libvisa-stub latest: true fileName: '*' - - name: Build + - name: Build LAN-only run: | git config --global credential.helper store echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials cargo build --target "${{matrix.triple}}" --release --package kic --package kic-discover + - name: Build VISA + if: ${{ matrix.runner != 'macos-latest' }} + run: | + git config --global credential.helper store + echo "https://${{vars.SERVICE_ACCOUNT_USER}}:${{secrets.SERVICE_ACCOUNT_PAT}}@github.com" > ~/.git-credentials cargo build --target "${{matrix.triple}}" --release --package kic-visa --package kic-discover-visa - name: Upload Artifacts uses: actions/upload-artifact@v4 @@ -235,9 +240,11 @@ jobs: vscode-platform: win32-x64 os: win32 arch: x64 - # - runner: macos-latest - # triple: x86_64-apple-darwin - # vscode-platform: darwin-arm64 + - runner: macos-latest + triple: aarch64-apple-darwin + vscode-platform: darwin-arm64 + os: darwin + arch: arm64 steps: - name: Update ClamAV run: freshclam diff --git a/CHANGELOG.md b/CHANGELOG.md index d1de152..6108a6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ## [0.18.3] +### Added + +- Add support for macOS (LAN only) + ### Changed - .script , .upgrade and .exit commands descriptions updated diff --git a/Cargo.lock b/Cargo.lock index 9ab8ac6..077bdf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -281,13 +281,13 @@ checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -298,9 +298,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -386,9 +386,9 @@ checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "cc" -version = "1.1.21" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "shlex", ] @@ -421,9 +421,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.18" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -431,9 +431,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.18" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -450,7 +450,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -644,9 +644,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -659,9 +659,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -669,15 +669,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" @@ -705,32 +705,32 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -767,9 +767,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "gloo-timers" @@ -823,9 +823,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.5" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "heck" @@ -903,9 +903,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -991,9 +991,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -1004,7 +1004,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -1044,9 +1043,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", "hashbrown", @@ -1070,9 +1069,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is_terminal_polyfill" @@ -1282,9 +1281,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libusb1-sys" @@ -1482,23 +1481,23 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -1529,7 +1528,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1621,7 +1620,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1635,22 +1634,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1741,9 +1740,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -1795,18 +1794,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -1816,9 +1815,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -1827,15 +1826,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64 0.22.1", "bytes", @@ -1954,9 +1953,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "once_cell", "rustls-pki-types", @@ -1967,19 +1966,18 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.22.1", "rustls-pki-types", ] [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-webpki" @@ -2023,9 +2021,9 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -2076,7 +2074,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2235,9 +2233,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -2288,9 +2286,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if 1.0.0", "fastrand", @@ -2316,7 +2314,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2380,7 +2378,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2438,9 +2436,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", @@ -2453,11 +2451,6 @@ version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", "tower-layer", "tower-service", "tracing", @@ -2495,7 +2488,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2554,8 +2547,8 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tsp-toolkit-kic-lib" -version = "0.18.1" -source = "git+https://github.com/tektronix/tsp-toolkit-kic-lib.git?tag=v0.18.1#b4d8b51a31236279eb148e86c8cb1a372a59cd88" +version = "0.18.2" +source = "git+https://github.com/tektronix/tsp-toolkit-kic-lib.git?tag=v0.18.2-0#ba3aa64d1740cdf3d967ae3629ff56d90e50afbd" dependencies = [ "bytes", "chrono", @@ -2580,9 +2573,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -2720,7 +2713,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -2754,7 +2747,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -2986,9 +2979,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -3011,7 +3004,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b30e376..87dd60e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,7 @@ 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.1" } +tsp-toolkit-kic-lib = { git = "https://github.com/tektronix/tsp-toolkit-kic-lib.git", tag = "v0.18.2-0" } [workspace.lints.rust] warnings = "deny" From 20c637143d0a77099c0811a9aa996fa36ac67193 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Wed, 9 Oct 2024 13:55:19 -0400 Subject: [PATCH 2/3] Remove usbtmc --- Cargo.lock | 40 +--- Cargo.toml | 4 +- kic-discover-visa/Cargo.toml | 2 - .../src/instrument_discovery/mod.rs | 22 --- kic-discover-visa/src/lib.rs | 3 +- kic-discover-visa/src/main.rs | 46 ----- kic-discover-visa/src/usbtmc/mod.rs | 179 ------------------ kic-discover/Cargo.toml | 2 - kic-discover/src/instrument_discovery/mod.rs | 41 ---- kic-discover/src/lib.rs | 2 - kic-discover/src/main.rs | 45 ----- kic-discover/src/usbtmc/mod.rs | 179 ------------------ kic-visa/src/main.rs | 38 +--- kic/src/main.rs | 38 +--- tests/typescript/config.ts | 1 - 15 files changed, 7 insertions(+), 635 deletions(-) delete mode 100644 kic-discover-visa/src/usbtmc/mod.rs delete mode 100644 kic-discover/src/usbtmc/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 077bdf5..af16422 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1203,11 +1203,9 @@ dependencies = [ "minidom", "reqwest", "rpassword", - "rusb", "serde", "serde_json", "thiserror", - "tmc", "tokio", "tracing", "tracing-subscriber", @@ -1233,11 +1231,9 @@ dependencies = [ "minidom", "reqwest", "rpassword", - "rusb", "serde", "serde_json", "thiserror", - "tmc", "tokio", "tracing", "tracing-subscriber", @@ -1285,18 +1281,6 @@ version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" -[[package]] -name = "libusb1-sys" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da050ade7ac4ff1ba5379af847a10a10a8e284181e060105bf8d86960ce9ce0f" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -1916,16 +1900,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "rusb" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab9f9ff05b63a786553a4c02943b74b34a988448671001e9a27e2f0565cc05a4" -dependencies = [ - "libc", - "libusb1-sys", -] - [[package]] name = "rustc-demangle" version = "0.1.24" @@ -2342,16 +2316,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" -[[package]] -name = "tmc" -version = "0.1.1" -source = "git+https://github.com/esarver/rusb-usbtmc#0ed58c406a9ec7f1c48672a74531d8cd70957ac7" -dependencies = [ - "byteorder", - "rusb", - "thiserror", -] - [[package]] name = "tokio" version = "1.40.0" @@ -2548,7 +2512,7 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tsp-toolkit-kic-lib" version = "0.18.2" -source = "git+https://github.com/tektronix/tsp-toolkit-kic-lib.git?tag=v0.18.2-0#ba3aa64d1740cdf3d967ae3629ff56d90e50afbd" +source = "git+https://github.com/tektronix/tsp-toolkit-kic-lib.git?tag=v0.18.2-1#7005210fcc77668dafc5a5a48b809dfe3cedb0f1" dependencies = [ "bytes", "chrono", @@ -2556,11 +2520,9 @@ dependencies = [ "phf", "reqwest", "rpassword", - "rusb", "serde", "serde_json", "thiserror", - "tmc", "tracing", "visa-rs", ] diff --git a/Cargo.toml b/Cargo.toml index 87dd60e..983291e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/kic-discover-visa/Cargo.toml b/kic-discover-visa/Cargo.toml index 463ce44..75809af 100644 --- a/kic-discover-visa/Cargo.toml +++ b/kic-discover-visa/Cargo.toml @@ -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 } diff --git a/kic-discover-visa/src/instrument_discovery/mod.rs b/kic-discover-visa/src/instrument_discovery/mod.rs index 50d86e6..91760a0 100644 --- a/kic-discover-visa/src/instrument_discovery/mod.rs +++ b/kic-discover-visa/src/instrument_discovery/mod.rs @@ -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)] @@ -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> { - let mut discovery_results: HashSet = 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> { visa_discover(self.timeout).await } diff --git a/kic-discover-visa/src/lib.rs b/kic-discover-visa/src/lib.rs index 7f8b06b..e6fb5fa 100644 --- a/kic-discover-visa/src/lib.rs +++ b/kic-discover-visa/src/lib.rs @@ -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] @@ -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, } diff --git a/kic-discover-visa/src/main.rs b/kic-discover-visa/src/main.rs index 7e20611..4f3b8fc 100644 --- a/kic-discover-visa/src/main.rs +++ b/kic-discover-visa/src/main.rs @@ -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. @@ -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"); @@ -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)] @@ -424,11 +386,3 @@ async fn discover_visa(args: DiscoverCmd) -> anyhow::Result anyhow::Result> { -// 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) -//} diff --git a/kic-discover-visa/src/usbtmc/mod.rs b/kic-discover-visa/src/usbtmc/mod.rs deleted file mode 100644 index 743a10e..0000000 --- a/kic-discover-visa/src/usbtmc/mod.rs +++ /dev/null @@ -1,179 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashSet, hash::Hash, time::Duration}; -use tmc::{list_instruments, Instrument, InstrumentHandle, TMCError, TMCResult}; -use tsp_toolkit_kic_lib::{ - instrument::info::InstrumentInfo, interface::connection_addr::ConnectionAddr, - usbtmc::UsbtmcAddr, -}; - -use crate::{insert_disc_device, model_check, IoType}; - -pub struct Usbtmc { - device: rusb::Device, - #[allow(dead_code)] - handle: Option>, - pub unique_string: String, -} - -impl Usbtmc { - /// Construct a new [`Usbtmc`] device that holds the details of a USB - /// device. - /// - /// # Errors - /// This will return a [`TMCResult`] error if the details of the device - /// cannot be fetched from the USB subsystem. This can occur for platform - /// dependent reasons such as the device being assigned an unsupported - /// USB driver in Windows or the device not having proper udev rules created - /// in Linux. - pub fn new(device: rusb::Device) -> TMCResult { - let vendor = device.device_descriptor()?.vendor_id(); - let product = device.device_descriptor()?.product_id(); - let address = device.address(); - Ok(Self { - device, - handle: None, - unique_string: format!("{vendor:X}:{product:X}:{address}"), - }) - } - - /// Discover instruments connected via USB. - /// - /// # Errors - /// Errors can occur if - /// - [`rusb::Context`] has an error during construction - /// - [`list_instruments`] has an error - #[allow(clippy::unused_async)] // to keep API consistent - pub async fn usb_discover( - _timeout: Option, - ) -> anyhow::Result> { - let context = match rusb::Context::new() { - Ok(x) => x, - Err(e) => { - return Err(Box::new(e).into()); - } - }; - let instruments = match list_instruments(context) { - Ok(x) => x, - Err(e) => { - return Err(Box::new(e).into()); - } - }; - let mut discovered_instrs: HashSet = HashSet::new(); - - if instruments.is_empty() { - eprintln!("No instruments found"); - //return Ok(()); - } - - // We allow the unused mut here because it is only unused in release mode. - #[allow(unused_mut)] - for mut instrument in instruments { - #[cfg(debug_assertions)] - eprintln!( - "Found instrument: {}", - instrument - .read_resource_string() - .unwrap_or_else(|_| String::from("[UNKNOWN]")) - ); - let manufacturer = instrument - .read_manufacturer_string()? - .unwrap_or_else(|| String::from("NA")); - let firmware_revision = instrument - .read_device_version()? - .map_or_else(|| String::from("NA"), |version| version.to_string()); - let model = String::from(model_lut(instrument.device_desc.product_id())); - let serial_number = instrument - .read_serial_number()? - .unwrap_or_else(|| String::from("NA")) - .clone(); - - let tmc_instr: Result = instrument.try_into(); - - //ToDo: test versatest when it's discoverable - let res = model_check(model.as_str()); - if manufacturer.to_ascii_lowercase().contains("keithley") && res.0 { - if let Ok(mut instr) = tmc_instr { - let usb_info = UsbDeviceInfo { - io_type: IoType::Usb, - instr_address: instr.unique_string.clone(), - manufacturer, - model, - serial_number, - firmware_revision, - instr_categ: res.1.to_string(), - }; - if let Ok(out_str) = serde_json::to_string(&usb_info) { - insert_disc_device(out_str.as_str())?; - } - let usbtmc_addr = UsbtmcAddr { - device: instr.device, - model: usb_info.model.clone(), - serial: usb_info.serial_number.clone(), - }; - let disc_usb_inst = InstrumentInfo { - vendor: Some(usb_info.manufacturer), - model: Some(usb_info.model), - serial_number: Some(usb_info.serial_number.clone()), - firmware_rev: Some(usb_info.firmware_revision), - address: Some(ConnectionAddr::Usbtmc(usbtmc_addr.clone())), - }; - discovered_instrs.insert(disc_usb_inst); - } - } - } - Ok(discovered_instrs) - } -} - -impl TryFrom> for Usbtmc { - type Error = TMCError; - - fn try_from(value: Instrument) -> Result { - Self::new(value.device) - } -} - -const fn model_lut(pid: u16) -> &'static str { - match pid { - 0x3706 => "3706", - 0xCA7C => "4210-CVU-ACU", - 0x707A => "707A", - 0x707B => "707B", - 0x2100 => "2100", - 0x2110 => "2110", - 0x3390 => "3390", - 0x488B => "K-USB-488B", - 0x2450 => "2450", - 0x2460 => "2460", - 0x2461 => "2461", - 0x1642 => "2461-SYS", - 0x2470 => "2470", - 0x2601 => "2601", - 0x26F1 => "2601B-PULSE", - 0x2602 => "2602B", - 0x2604 => "2604B", - 0x2611 => "2611B", - 0x2612 => "2612B", - 0x2614 => "2614B", - 0x2634 => "2634B", - 0x2635 => "2635B", - 0x2636 => "2636B", - 0x426C => "4200A-CVIV", - 0x6500 => "DMM6500", - 0x6510 => "DAQ6510", - 0x7500 => "DMM7500", - 0x7512 => "DMM7512", - _ => "UNKNOWN", - } -} - -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)] -pub struct UsbDeviceInfo { - io_type: IoType, - instr_address: String, - manufacturer: String, - model: String, - serial_number: String, - firmware_revision: String, - instr_categ: String, -} diff --git a/kic-discover/Cargo.toml b/kic-discover/Cargo.toml index 618cac3..25e3678 100644 --- a/kic-discover/Cargo.toml +++ b/kic-discover/Cargo.toml @@ -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 } diff --git a/kic-discover/src/instrument_discovery/mod.rs b/kic-discover/src/instrument_discovery/mod.rs index 0cdc3cb..7198ed0 100644 --- a/kic-discover/src/instrument_discovery/mod.rs +++ b/kic-discover/src/instrument_discovery/mod.rs @@ -6,7 +6,6 @@ use tsp_toolkit_kic_lib::{ }; use crate::ethernet::{LxiDeviceInfo, COMM_PORT}; -use crate::usbtmc::Usbtmc; #[derive(Debug)] pub struct InstrumentDiscovery { @@ -21,25 +20,6 @@ impl InstrumentDiscovery { } } - // pub async fn discover(&self) -> anyhow::Result> - // where - // T: Discover, - // { - // let mut discovery_results: HashSet = HashSet::new(); - // match T::discover(self.timeout).await { - // Ok(instrs) => { - // for inst in instrs { - // discovery_results.insert(inst); - // } - // } - // Err(e) => { - // eprintln!("Unable to discover LXI devices: {e}"); //TODO add color - // return Err(e); - // } - // }; - // Ok(discovery_results) - // } - /// Discover instruments on the network. /// /// # Errors @@ -60,27 +40,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> { - let mut discovery_results: HashSet = 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) - } } impl From for InstrumentInfo { diff --git a/kic-discover/src/lib.rs b/kic-discover/src/lib.rs index bd4d176..f0f4ddd 100644 --- a/kic-discover/src/lib.rs +++ b/kic-discover/src/lib.rs @@ -2,7 +2,6 @@ use std::{collections::HashSet, hash::Hash, io::Error, sync::Mutex}; pub mod ethernet; pub mod instrument_discovery; -pub mod usbtmc; #[macro_use] extern crate lazy_static; @@ -127,5 +126,4 @@ pub fn insert_disc_device(device: &str) -> Result<(), Error> { #[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Hash, serde::Serialize, serde::Deserialize)] enum IoType { Lan, - Usb, } diff --git a/kic-discover/src/main.rs b/kic-discover/src/main.rs index 3830035..3c98a2d 100644 --- a/kic-discover/src/main.rs +++ b/kic-discover/src/main.rs @@ -48,8 +48,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 on all interface types. All(DiscoverCmd), } @@ -291,43 +289,8 @@ 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::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 LAN instruments"); #[allow(clippy::mutable_key_type)] let lan_instruments = match discover_lan(args.clone()).await { @@ -414,11 +377,3 @@ async fn discover_lan(args: DiscoverCmd) -> anyhow::Result anyhow::Result> { -// 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) -//} diff --git a/kic-discover/src/usbtmc/mod.rs b/kic-discover/src/usbtmc/mod.rs deleted file mode 100644 index 743a10e..0000000 --- a/kic-discover/src/usbtmc/mod.rs +++ /dev/null @@ -1,179 +0,0 @@ -use serde::{Deserialize, Serialize}; -use std::{collections::HashSet, hash::Hash, time::Duration}; -use tmc::{list_instruments, Instrument, InstrumentHandle, TMCError, TMCResult}; -use tsp_toolkit_kic_lib::{ - instrument::info::InstrumentInfo, interface::connection_addr::ConnectionAddr, - usbtmc::UsbtmcAddr, -}; - -use crate::{insert_disc_device, model_check, IoType}; - -pub struct Usbtmc { - device: rusb::Device, - #[allow(dead_code)] - handle: Option>, - pub unique_string: String, -} - -impl Usbtmc { - /// Construct a new [`Usbtmc`] device that holds the details of a USB - /// device. - /// - /// # Errors - /// This will return a [`TMCResult`] error if the details of the device - /// cannot be fetched from the USB subsystem. This can occur for platform - /// dependent reasons such as the device being assigned an unsupported - /// USB driver in Windows or the device not having proper udev rules created - /// in Linux. - pub fn new(device: rusb::Device) -> TMCResult { - let vendor = device.device_descriptor()?.vendor_id(); - let product = device.device_descriptor()?.product_id(); - let address = device.address(); - Ok(Self { - device, - handle: None, - unique_string: format!("{vendor:X}:{product:X}:{address}"), - }) - } - - /// Discover instruments connected via USB. - /// - /// # Errors - /// Errors can occur if - /// - [`rusb::Context`] has an error during construction - /// - [`list_instruments`] has an error - #[allow(clippy::unused_async)] // to keep API consistent - pub async fn usb_discover( - _timeout: Option, - ) -> anyhow::Result> { - let context = match rusb::Context::new() { - Ok(x) => x, - Err(e) => { - return Err(Box::new(e).into()); - } - }; - let instruments = match list_instruments(context) { - Ok(x) => x, - Err(e) => { - return Err(Box::new(e).into()); - } - }; - let mut discovered_instrs: HashSet = HashSet::new(); - - if instruments.is_empty() { - eprintln!("No instruments found"); - //return Ok(()); - } - - // We allow the unused mut here because it is only unused in release mode. - #[allow(unused_mut)] - for mut instrument in instruments { - #[cfg(debug_assertions)] - eprintln!( - "Found instrument: {}", - instrument - .read_resource_string() - .unwrap_or_else(|_| String::from("[UNKNOWN]")) - ); - let manufacturer = instrument - .read_manufacturer_string()? - .unwrap_or_else(|| String::from("NA")); - let firmware_revision = instrument - .read_device_version()? - .map_or_else(|| String::from("NA"), |version| version.to_string()); - let model = String::from(model_lut(instrument.device_desc.product_id())); - let serial_number = instrument - .read_serial_number()? - .unwrap_or_else(|| String::from("NA")) - .clone(); - - let tmc_instr: Result = instrument.try_into(); - - //ToDo: test versatest when it's discoverable - let res = model_check(model.as_str()); - if manufacturer.to_ascii_lowercase().contains("keithley") && res.0 { - if let Ok(mut instr) = tmc_instr { - let usb_info = UsbDeviceInfo { - io_type: IoType::Usb, - instr_address: instr.unique_string.clone(), - manufacturer, - model, - serial_number, - firmware_revision, - instr_categ: res.1.to_string(), - }; - if let Ok(out_str) = serde_json::to_string(&usb_info) { - insert_disc_device(out_str.as_str())?; - } - let usbtmc_addr = UsbtmcAddr { - device: instr.device, - model: usb_info.model.clone(), - serial: usb_info.serial_number.clone(), - }; - let disc_usb_inst = InstrumentInfo { - vendor: Some(usb_info.manufacturer), - model: Some(usb_info.model), - serial_number: Some(usb_info.serial_number.clone()), - firmware_rev: Some(usb_info.firmware_revision), - address: Some(ConnectionAddr::Usbtmc(usbtmc_addr.clone())), - }; - discovered_instrs.insert(disc_usb_inst); - } - } - } - Ok(discovered_instrs) - } -} - -impl TryFrom> for Usbtmc { - type Error = TMCError; - - fn try_from(value: Instrument) -> Result { - Self::new(value.device) - } -} - -const fn model_lut(pid: u16) -> &'static str { - match pid { - 0x3706 => "3706", - 0xCA7C => "4210-CVU-ACU", - 0x707A => "707A", - 0x707B => "707B", - 0x2100 => "2100", - 0x2110 => "2110", - 0x3390 => "3390", - 0x488B => "K-USB-488B", - 0x2450 => "2450", - 0x2460 => "2460", - 0x2461 => "2461", - 0x1642 => "2461-SYS", - 0x2470 => "2470", - 0x2601 => "2601", - 0x26F1 => "2601B-PULSE", - 0x2602 => "2602B", - 0x2604 => "2604B", - 0x2611 => "2611B", - 0x2612 => "2612B", - 0x2614 => "2614B", - 0x2634 => "2634B", - 0x2635 => "2635B", - 0x2636 => "2636B", - 0x426C => "4200A-CVIV", - 0x6500 => "DMM6500", - 0x6510 => "DAQ6510", - 0x7500 => "DMM7500", - 0x7512 => "DMM7512", - _ => "UNKNOWN", - } -} - -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Hash, Serialize, Deserialize)] -pub struct UsbDeviceInfo { - io_type: IoType, - instr_address: String, - manufacturer: String, - model: String, - serial_number: String, - firmware_revision: String, - instr_categ: String, -} diff --git a/kic-visa/src/main.rs b/kic-visa/src/main.rs index 6ec1df5..40d7184 100644 --- a/kic-visa/src/main.rs +++ b/kic-visa/src/main.rs @@ -36,11 +36,7 @@ use tracing::{debug, error, info, instrument, level_filters::LevelFilter, trace, use tracing_subscriber::{layer::SubscriberExt, Layer, Registry}; use tsp_toolkit_kic_lib::{ - instrument::Instrument, - interface::async_stream::AsyncStream, - protocol::Protocol, - usbtmc::{self, UsbtmcAddr}, - Interface, + instrument::Instrument, interface::async_stream::AsyncStream, protocol::Protocol, Interface, }; #[derive(Debug, Subcommand)] @@ -98,23 +94,13 @@ fn add_connection_subcommands( .required(true), ); - //TODO(Fix async USB): let mut usb = Command::new("usb") - // .about("Perform the given action over a USBTMC connection") - // .arg( - // Arg::new("addr") - // .help("The instrument address in the form of, for example, `USB:2461:012345` where the second part is the product id, and the third part is the serial number.") - // .required(true) - // .value_parser(value_parser!(UsbtmcAddr)), - // ); - for arg in additional_args { lan = lan.arg(arg.clone()); visa = visa.arg(arg.clone()); - //TODO(Fix async USB): usb = usb.arg(arg.clone()); } - command.subcommand(lan).subcommand(visa) //TODO(Fix async USB): .subcommand(usb) + command.subcommand(lan).subcommand(visa) } #[must_use] @@ -461,7 +447,6 @@ fn main() -> anyhow::Result<()> { #[derive(Debug)] enum ConnectionType { Lan(SocketAddr), - Usb(UsbtmcAddr), Visa(String), } @@ -491,16 +476,6 @@ impl ConnectionType { Ok(Self::Visa(visa_string)) } - Some(("usb", sub_matches)) => { - let usb_addr: UsbtmcAddr = sub_matches - .get_one::("addr") - .ok_or_else(|| KicError::ArgParseError { - details: "no USB address provided".to_string(), - })? - .clone(); - - Ok(Self::Usb(usb_addr)) - } Some((ct, _sub_matches)) => { println!(); Err(KicError::ArgParseError { @@ -520,9 +495,6 @@ fn connect_sync_instrument(t: ConnectionType) -> anyhow::Result { (Box::new(TcpStream::connect(addr)?) as Box).into() } - ConnectionType::Usb(addr) => { - (Box::new(usbtmc::Stream::try_from(addr)?) as Box).into() - } ConnectionType::Visa(r) => Protocol::try_from_visa(r)?, }; trace!("Synchronously connected to interface"); @@ -542,11 +514,6 @@ fn connect_async_instrument(t: ConnectionType) -> anyhow::Result)?)), - ConnectionType::Usb(addr) => { - tsp_toolkit_kic_lib::protocol::Protocol::Raw(Box::new(AsyncStream::try_from( - Arc::new(usbtmc::Stream::try_from(addr)?) as Arc, - )?)) - } ConnectionType::Visa(r) => Protocol::try_from_visa(r)?, }; @@ -930,7 +897,6 @@ fn terminate(args: &ArgMatches) -> anyhow::Result<()> { return Err(e.into()); } } - ConnectionType::Usb(_) => {} ConnectionType::Visa(_) => {} } diff --git a/kic/src/main.rs b/kic/src/main.rs index 28510ac..a56b84a 100644 --- a/kic/src/main.rs +++ b/kic/src/main.rs @@ -34,11 +34,7 @@ use tracing::{debug, error, info, instrument, level_filters::LevelFilter, trace, use tracing_subscriber::{layer::SubscriberExt, Layer, Registry}; use tsp_toolkit_kic_lib::{ - instrument::Instrument, - interface::async_stream::AsyncStream, - protocol::Protocol, - usbtmc::{self, UsbtmcAddr}, - Interface, + instrument::Instrument, interface::async_stream::AsyncStream, protocol::Protocol, Interface, }; #[derive(Debug, Subcommand)] @@ -88,21 +84,11 @@ fn add_connection_subcommands( .value_parser(value_parser!(IpAddr)), ); - //TODO(Fix async USB): let mut usb = Command::new("usb") - // .about("Perform the given action over a USBTMC connection") - // .arg( - // Arg::new("addr") - // .help("The instrument address in the form of, for example, `USB:2461:012345` where the second part is the product id, and the third part is the serial number.") - // .required(true) - // .value_parser(value_parser!(UsbtmcAddr)), - // ); - for arg in additional_args { lan = lan.arg(arg.clone()); - //TODO(Fix async USB): usb = usb.arg(arg.clone()); } - command.subcommand(lan) //TODO(Fix async USB): .subcommand(usb) + command.subcommand(lan) } #[must_use] @@ -469,7 +455,6 @@ fn main() -> anyhow::Result<()> { #[derive(Debug)] enum ConnectionType { Lan(SocketAddr), - Usb(UsbtmcAddr), } impl ConnectionType { @@ -489,16 +474,6 @@ impl ConnectionType { Ok(Self::Lan(socket_addr)) } - Some(("usb", sub_matches)) => { - let usb_addr: UsbtmcAddr = sub_matches - .get_one::("addr") - .ok_or_else(|| KicError::ArgParseError { - details: "no USB address provided".to_string(), - })? - .clone(); - - Ok(Self::Usb(usb_addr)) - } Some((ct, _sub_matches)) => { println!(); Err(KicError::ArgParseError { @@ -518,9 +493,6 @@ fn connect_sync_instrument(t: ConnectionType) -> anyhow::Result { (Box::new(TcpStream::connect(addr)?) as Box).into() } - ConnectionType::Usb(addr) => { - (Box::new(usbtmc::Stream::try_from(addr)?) as Box).into() - } }; trace!("Synchronously connected to interface"); @@ -539,11 +511,6 @@ fn connect_async_instrument(t: ConnectionType) -> anyhow::Result)?)), - ConnectionType::Usb(addr) => { - tsp_toolkit_kic_lib::protocol::Protocol::Raw(Box::new(AsyncStream::try_from( - Arc::new(usbtmc::Stream::try_from(addr)?) as Arc, - )?)) - } }; trace!("Asynchronously connected to interface"); @@ -926,7 +893,6 @@ fn terminate(args: &ArgMatches) -> anyhow::Result<()> { return Err(e.into()); } } - ConnectionType::Usb(_) => {} } info!("Operations terminated"); diff --git a/tests/typescript/config.ts b/tests/typescript/config.ts index 6e4d525..2d44910 100644 --- a/tests/typescript/config.ts +++ b/tests/typescript/config.ts @@ -66,7 +66,6 @@ export enum TrebInstrumentModel { } export enum ConnectionType { - USB = "USB", LAN = "LAN", VISA = "VISA", } From d317ea8541705a2f3a5fd0c4910418023ee7d730 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Wed, 9 Oct 2024 13:58:00 -0400 Subject: [PATCH 3/3] Remove workaround for rustc issue --- .github/workflows/pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 529118e..e25cf5e 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -185,7 +185,7 @@ jobs: - name: Tool Setup # 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 + run: rustup install nightly && rustup default nightly - name: Ensure Correct Target is Installed run: rustup target add ${{matrix.triple}} - name: Tool Versions