Skip to content

Commit

Permalink
fix: Ember: skip port re-init on reset retry (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec authored Mar 2, 2024
1 parent 882f2e4 commit 2a3a98b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/adapter/ember/uart/ash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export class UartAsh extends EventEmitter {
return false;
}

return this.serialPort != null ? this.serialPort.isOpen : !this.socketPort?.closed;
return SocketPortUtils.isTcpPath(this.portOptions.path) ? !this.socketPort?.closed : !!this.serialPort?.isOpen;
}

/**
Expand Down Expand Up @@ -365,8 +365,6 @@ export class UartAsh extends EventEmitter {
private initVariables(): void {
this.closing = false;

this.writer = null;
this.parser = null;
this.txSHBuffer = Buffer.alloc(SH_TX_BUFFER_LEN);
this.rxSHBuffer = Buffer.alloc(SH_RX_BUFFER_LEN);
this.ackTimer = 0;
Expand Down Expand Up @@ -627,7 +625,7 @@ export class UartAsh extends EventEmitter {
* - EzspStatus.ASH_NCP_FATAL_ERROR)
*/
public async start(): Promise<EzspStatus> {
if (this.closing || (this.flags & Flag.CONNECTED)) {
if (!this.portOpen || (this.flags & Flag.CONNECTED)) {
return EzspStatus.ERROR_INVALID_CALL;
}

Expand Down Expand Up @@ -719,7 +717,9 @@ export class UartAsh extends EventEmitter {

// ask ncp to reset itself using RST frame
try {
await this.initPort();
if (!this.portOpen) {
await this.initPort();
}

this.flags = Flag.RST | Flag.CAN;

Expand Down

0 comments on commit 2a3a98b

Please sign in to comment.