Skip to content

Commit 717dcd9

Browse files
committed
Fix interrupts of commands
Signed-off-by: paulober <[email protected]>
1 parent 2ba6730 commit 717dcd9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/serialHelper.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const BUFFER_R01 = Buffer.from("R\x01");
3535
const BUFFER_01 = Buffer.from("\x01");
3636
const BUFFER_03 = Buffer.from("\x03");
3737
const BUFFER_04 = Buffer.from("\x04");
38-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3938
const BUFFER_CR = Buffer.from("\r");
4039
const BUFFER_TAB = Buffer.from("\t");
4140

@@ -515,7 +514,10 @@ export async function executeCommandWithResult(
515514
// call exe without result and then call follow
516515
await executeCommandWithoutResult(port, command);
517516

518-
return follow(port, timeout, receiver);
517+
// needs to be awaited here, otherwise it will
518+
// return the promisse which will run the final block
519+
// of this try catch as the promisse is awaited somewhere else
520+
return await follow(port, timeout, receiver);
519521
} catch {
520522
if (interrupted) {
521523
return { data: "", error: "Interrupted" };

src/tests/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ async function handleCommand(command: string): Promise<void> {
342342
if (open) {
343343
relayInput = true;
344344
rl.resume();
345+
// for testing of interrupts
346+
setTimeout(() => {
347+
serialCom.interruptExecution();
348+
}, 5000);
345349
}
346350
},
347351
(data: Buffer) => {

0 commit comments

Comments
 (0)