Firmio: Improve exit from Find loop
Device: Null check return from std::dynamic_pointer_cast136-add-android-support
parent
cc7cffe068
commit
e0cef880f0
|
|
@ -1878,7 +1878,7 @@ bool Device::subscribeLiveData(std::shared_ptr<LiveDataCommandMessage> message)
|
||||||
|
|
||||||
if(response) {
|
if(response) {
|
||||||
auto statusMsg = std::dynamic_pointer_cast<LiveDataStatusMessage>(response);
|
auto statusMsg = std::dynamic_pointer_cast<LiveDataStatusMessage>(response);
|
||||||
if(statusMsg->requestedCommand == message->cmd) {
|
if(statusMsg && statusMsg->requestedCommand == message->cmd) {
|
||||||
switch(statusMsg->status) {
|
switch(statusMsg->status) {
|
||||||
case LiveDataStatus::SUCCESS:
|
case LiveDataStatus::SUCCESS:
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,13 @@ void FirmIO::Find(std::vector<FoundDevice>& found) {
|
||||||
Decoder decoder([](APIEvent::Type, APIEvent::Severity) {});
|
Decoder decoder([](APIEvent::Type, APIEvent::Severity) {});
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
const auto start = steady_clock::now();
|
const auto start = steady_clock::now();
|
||||||
auto timeout = milliseconds(50);
|
// Get an absolute wall clock to compare to
|
||||||
while(temp.readWait(payload, timeout)) {
|
const auto overallTimeout = start + milliseconds(500);
|
||||||
timeout -= duration_cast<milliseconds>(steady_clock::now() - start);
|
while(temp.readWait(payload, milliseconds(50))) {
|
||||||
|
if(steady_clock::now() > overallTimeout) {
|
||||||
|
// failed to read out a serial number reponse in time
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(!packetizer.input(payload))
|
if(!packetizer.input(payload))
|
||||||
continue; // A full packet has not yet been read out
|
continue; // A full packet has not yet been read out
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue