Skip to content

Commit edb1b66

Browse files
committed
Fix runFile(Remote) no error output + reconnecting after failed connection
Signed-off-by: paulober <44974737+paulober@users.noreply.github.com>
1 parent 8c6e03e commit edb1b66

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/picoMpyCom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class PicoMpyCom extends EventEmitter {
7171
* @param port The port to connect to.
7272
*/
7373
public async openSerialPort(port: string): Promise<void> {
74-
if (this.serialPort?.path === port) {
74+
if (this.serialPort?.path === port && this.serialPort.isOpen) {
7575
return;
7676
}
7777

src/serialHelper.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,17 @@ export async function runFile(
14181418
}
14191419

14201420
return true;
1421-
} catch {
1421+
} catch (error) {
1422+
receiver(
1423+
Buffer.from(
1424+
error instanceof Error
1425+
? error.message
1426+
: typeof error === "string"
1427+
? error
1428+
: "Unknown error"
1429+
)
1430+
);
1431+
14221432
return false;
14231433
} finally {
14241434
await fileHandle?.close();
@@ -1478,7 +1488,17 @@ export async function runRemoteFile(
14781488
}
14791489

14801490
return true;
1481-
} catch {
1491+
} catch (error) {
1492+
receiver(
1493+
Buffer.from(
1494+
error instanceof Error
1495+
? error.message
1496+
: typeof error === "string"
1497+
? error
1498+
: "Unknown error"
1499+
)
1500+
);
1501+
14821502
return false;
14831503
}
14841504
}

0 commit comments

Comments
 (0)