From d72155131044dac45f75a55e016eb460df1c5ad9 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 25 Jul 2024 15:19:08 -0400 Subject: [PATCH 1/5] Detect Terminal Closure with console.log --- src/resourceManager.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/resourceManager.ts b/src/resourceManager.ts index 602f2f0..21e33bc 100644 --- a/src/resourceManager.ts +++ b/src/resourceManager.ts @@ -319,6 +319,19 @@ export class KicCell extends EventEmitter { }) } + vscode.window.onDidCloseTerminal((t) => { + if ( + t.creationOptions.iconPath !== undefined && + t.creationOptions.iconPath.toString().search("keithley-logo") && + t.exitStatus !== undefined && + t.exitStatus.reason !== vscode.TerminalExitReason.Process + ) { + console.log( + "Closed terminal without .exit, instrument needs cleanup" + ) + } + }) + this.terminalPid = this._term.processId if (this._term != undefined) { From f33f955f42af6dcc3ec41c812c4cf2fa921dbf8b Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 25 Jul 2024 15:52:34 -0400 Subject: [PATCH 2/5] Call reset subcommand --- src/resourceManager.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/resourceManager.ts b/src/resourceManager.ts index 21e33bc..385a6d2 100644 --- a/src/resourceManager.ts +++ b/src/resourceManager.ts @@ -327,8 +327,17 @@ export class KicCell extends EventEmitter { t.exitStatus.reason !== vscode.TerminalExitReason.Process ) { console.log( - "Closed terminal without .exit, instrument needs cleanup" + `Terminal unexpectedly closed. Resetting with ${connType} ${unique_id}` ) + setTimeout(() => { + const output = child.spawnSync(EXECUTABLE, [ + "-v", + "reset", + connType, + unique_id, + ]) + console.log(`Reset output: ${output.stderr}`) + }, 500) } }) From 9f7d40cf448ff11df30586a3e9b4388d713b865a Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 25 Jul 2024 15:54:14 -0400 Subject: [PATCH 3/5] Remove logging --- src/resourceManager.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/resourceManager.ts b/src/resourceManager.ts index 385a6d2..b21fe8b 100644 --- a/src/resourceManager.ts +++ b/src/resourceManager.ts @@ -326,17 +326,13 @@ export class KicCell extends EventEmitter { t.exitStatus !== undefined && t.exitStatus.reason !== vscode.TerminalExitReason.Process ) { - console.log( - `Terminal unexpectedly closed. Resetting with ${connType} ${unique_id}` - ) setTimeout(() => { - const output = child.spawnSync(EXECUTABLE, [ + child.spawnSync(EXECUTABLE, [ "-v", "reset", connType, unique_id, ]) - console.log(`Reset output: ${output.stderr}`) }, 500) } }) From 6e6006f53c68bf8aa6f2da57bed48cbf478443d0 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Thu, 25 Jul 2024 15:54:58 -0400 Subject: [PATCH 4/5] Bump version --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd90d0a..3cd4a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,11 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how Security -- in case of vulnerabilities. --> +## [0.17.0] + +### Added +- Reset instrument if closed unexpectedly using the trashcan on the terminal (TSP-730) + ## [0.16.4] ### Changed diff --git a/package-lock.json b/package-lock.json index 95fbe79..87b86b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tsp-toolkit", - "version": "0.16.4", + "version": "0.17.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tsp-toolkit", - "version": "0.16.4", + "version": "0.17.0", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { diff --git a/package.json b/package.json index 0ffdd72..7e447e9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "publisher": "Tektronix", "displayName": "[Beta] Keithley TSP Toolkit", "description": "VSCode extension for Keithley Instruments' Test Script Processor", - "version": "0.16.4", + "version": "0.17.0", "icon": "./resources/TSP_Toolkit_128x128.png", "galleryBanner": { "color": "#EEEEEE", From 0892e68908ae27da98cebc3fbdb5b938b2a94be0 Mon Sep 17 00:00:00 2001 From: "Sarver, Edwin" Date: Wed, 31 Jul 2024 08:40:15 -0400 Subject: [PATCH 5/5] Update Deps --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 735a797..48df5b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@tektronix/keithley_instrument_libraries": "0.16.0", - "@tektronix/kic-cli": "0.17.0-1", + "@tektronix/kic-cli": "0.17.0-2", "@tektronix/web-help-documents": "0.15.3", "@types/cheerio": "^0.22.35", "cheerio": "^1.0.0-rc.12", @@ -1078,9 +1078,9 @@ "integrity": "sha512-Q9KBTHtLRTqLy5rzygqa722JmFm3dpY55X6UGml3U2Wo+cwcKycCtcT8C/2qtHLxldbT598h8tZ/8rsUhXgK8g==" }, "node_modules/@tektronix/kic-cli": { - "version": "0.17.0-1", - "resolved": "https://npm.pkg.github.com/download/@tektronix/kic-cli/0.17.0-1/97674e16b7ae85ed23a3d0e0fd5b13db61978f12", - "integrity": "sha512-0fUdet3wXk6EfvPaFiDhg5AMbKz9Lt84oO+v4KpR6TS3uuEug0BtVTHzpNY4zsz27iH1HIl3OYdD2409+mE6Mw==", + "version": "0.17.0-2", + "resolved": "https://npm.pkg.github.com/download/@tektronix/kic-cli/0.17.0-2/c6a88055d605071a60efc1384a7a25e5e557bbb3", + "integrity": "sha512-Ult5W7Ktop4edErWC0HSP0oMcfDEs1JwortP2xXwZsW4FLOLfLKARPM2ibt5B49WRwo2b95BuTxkEqIZVX01cg==", "bin": { "linux-kic": "bin/kic", "linux-kic-discover": "bin/kic-discover", diff --git a/package.json b/package.json index 78fb30d..36238e4 100644 --- a/package.json +++ b/package.json @@ -325,7 +325,7 @@ }, "dependencies": { "@tektronix/keithley_instrument_libraries": "0.16.0", - "@tektronix/kic-cli": "0.17.0-1", + "@tektronix/kic-cli": "0.17.0-2", "@tektronix/web-help-documents": "0.15.3", "@types/cheerio": "^0.22.35", "cheerio": "^1.0.0-rc.12",