From 188a087c512bca3fece5705d37dd414223bcd96d Mon Sep 17 00:00:00 2001 From: Emily Brooks Date: Mon, 7 Aug 2023 18:32:28 -0400 Subject: [PATCH] Device: Wait longer to receive message in heart beat thread --- device/device.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/device/device.cpp b/device/device.cpp index 0f23f4f..b3ce976 100644 --- a/device/device.cpp +++ b/device/device.cpp @@ -280,8 +280,11 @@ bool Device::open(OpenFlags flags, OpenStatusHandler handler) { // No heartbeat received, request a status com->sendCommand(Command::RequestStatusUpdate); - // The response should come back quickly if the com is quiet - std::this_thread::sleep_for(std::chrono::milliseconds(50)); + + // Wait until we either received the message or reach max wait time + for (uint32_t sleepTime = 0; sleepTime < 3500 && !receivedMessage; sleepTime += 50) + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + // Check if we got a message, and if not, if settings are being applied if(receivedMessage) { receivedMessage = false;