Added waits to ensure going online and offline succeed before returning
parent
451f0a9ac1
commit
71176137ca
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
using namespace icsneo;
|
using namespace icsneo;
|
||||||
|
|
||||||
|
|
@ -217,11 +218,19 @@ bool Device::goOnline() {
|
||||||
if(!com->sendCommand(Command::EnableNetworkCommunication, true))
|
if(!com->sendCommand(Command::EnableNetworkCommunication, true))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto startTime = std::chrono::system_clock::now();
|
||||||
|
|
||||||
ledState = LEDState::Online;
|
ledState = LEDState::Online;
|
||||||
|
|
||||||
online = true;
|
online = true;
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
|
|
||||||
|
// wait until communication is enabled or 10 seconds, whichever comes first
|
||||||
|
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds::duration(10)) {
|
||||||
|
if(latestResetStatus && latestResetStatus->comEnabled)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -229,11 +238,19 @@ bool Device::goOffline() {
|
||||||
if(!com->sendCommand(Command::EnableNetworkCommunication, false))
|
if(!com->sendCommand(Command::EnableNetworkCommunication, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto startTime = std::chrono::system_clock::now();
|
||||||
|
|
||||||
ledState = (latestResetStatus && latestResetStatus->cmRunning) ? LEDState::CoreMiniRunning : LEDState::Offline;
|
ledState = (latestResetStatus && latestResetStatus->cmRunning) ? LEDState::CoreMiniRunning : LEDState::Offline;
|
||||||
|
|
||||||
updateLEDState();
|
updateLEDState();
|
||||||
online = false;
|
online = false;
|
||||||
|
|
||||||
|
// wait until communication is disabled or 10 seconds, whichever comes first
|
||||||
|
while((std::chrono::system_clock::now() - startTime) < std::chrono::seconds::duration(10)) {
|
||||||
|
if(latestResetStatus && !latestResetStatus->comEnabled)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue