Skip to content

Commit

Permalink
fix: --firmware-version not opening port (#176)
Browse files Browse the repository at this point in the history
* Call port.open() before querying it

* Close the port
  • Loading branch information
alexrudd2 authored Oct 26, 2023
1 parent 62b7ef0 commit 09ccd5f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ebb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class EBB {

public constructor(port: SerialPort) {
this.port = port;
this.writer = this.port.writable.getWriter()
this.writer = this.port.writable.getWriter();
this.commandQueue = [];
this.readableClosed = port.readable
.pipeThrough(new RegexParser({ regex: /[\r\n]+/ }))
Expand Down Expand Up @@ -66,7 +66,7 @@ export class EBB {
}

public async close(): Promise<void> {
throw new Error("TODO")
return await this.port.close()
}

private write(str: string): Promise<void> {
Expand Down
6 changes: 4 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,13 @@ async function* ebbs(path?: string) {

export async function connectEBB(path: string | undefined): Promise<EBB | null> {
if (path) {
return new EBB(new SerialPortSerialPort(path));
const port = await tryOpen(path);
return new EBB(port);
} else {
const ebbs = await listEBBs();
if (ebbs.length) {
return new EBB(new SerialPortSerialPort(ebbs[0]));
const port = await tryOpen(ebbs[0]);
return new EBB(port);
} else {
return null;
}
Expand Down

0 comments on commit 09ccd5f

Please sign in to comment.