Skip to content

Commit

Permalink
Registering observer before starting ASH reset. Fixes a race conditio…
Browse files Browse the repository at this point in the history
…n for #23
  • Loading branch information
Lionel AINS committed Mar 3, 2020
1 parent f7d20b7 commit 31a2e16
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/ezsp/lib-ezsp-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,17 @@ void CLibEzspMain::start()
if (this->uartDriver == nullptr) {
clogW << "Start invoked without an effective UART driver\n";
}
if( dongle.open(this->uartDriver) ) {
this->dongle.registerObserver(this);
this->gp_sink.registerObserver(this);
if (this->dongle.open(this->uartDriver) ) {
clogI << "EZSP serial port opened\n";
dongle.registerObserver(this);
gp_sink.registerObserver(this);
setState(CLibEzspInternalState::WAIT_DONGLE_READY); /* Because the dongle observer has been set to ourselves just above, our handleDongleState() method will be called back as soon as the dongle is detected */
}
else {
clogE << "EZSP failed opening serial port\n";
this->dongle.unregisterObserver(this);
this->gp_sink.registerObserver(this);
}
}

void CLibEzspMain::forceFirmwareUpgradeOnInitTimeout()
Expand Down

0 comments on commit 31a2e16

Please sign in to comment.