Skip to content

Commit

Permalink
Addressed PoE watchdog ping issues
Browse files Browse the repository at this point in the history
  • Loading branch information
themarpe committed Sep 5, 2022
1 parent ffe017a commit 74b699c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmake/Depthai/DepthaiDeviceSideConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set(DEPTHAI_DEVICE_SIDE_MATURITY "snapshot")

# "full commit hash of device side binary"
set(DEPTHAI_DEVICE_SIDE_COMMIT "154e46b348850ede50402af4bd2b99e39b47a003")
set(DEPTHAI_DEVICE_SIDE_COMMIT "2470bb3fb3855de1808cf3cc94509ee771bae7d5")

# "version if applicable"
set(DEPTHAI_DEVICE_SIDE_VERSION "")
2 changes: 1 addition & 1 deletion shared/depthai-shared
9 changes: 6 additions & 3 deletions src/device/DeviceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
pimpl->setPattern(fmt::format("[{}] [{}] {}", deviceInfo.mxid, deviceInfo.name, LOG_DEFAULT_PATTERN));

// Check if WD env var is set
std::chrono::milliseconds watchdogTimeout = device::XLINK_WATCHDOG_TIMEOUT;
std::chrono::milliseconds watchdogTimeout = device::XLINK_USB_WATCHDOG_TIMEOUT;
if(deviceInfo.protocol == X_LINK_TCP_IP) {
watchdogTimeout = device::XLINK_TCP_WATCHDOG_TIMEOUT;
}
auto watchdogMsStr = utility::getEnv("DEPTHAI_WATCHDOG");
if(!watchdogMsStr.empty()) {
// Try parsing the string as a number
Expand Down Expand Up @@ -637,8 +640,8 @@ void DeviceBase::init2(Config cfg, const dai::Path& pathToMvcmd, tl::optional<co
std::unique_lock<std::mutex> lock(lastWatchdogPingTimeMtx);
prevPingTime = lastWatchdogPingTime;
}
// Recheck if watchdogRunning wasn't already closed
if(watchdogRunning && std::chrono::steady_clock::now() - prevPingTime > watchdogTimeout) {
// Recheck if watchdogRunning wasn't already closed and close if more than twice of WD passed
if(watchdogRunning && std::chrono::steady_clock::now() - prevPingTime > watchdogTimeout * 2) {
spdlog::warn("Monitor thread (device: {} [{}]) - ping was missed, closing the device connection", deviceInfo.mxid, deviceInfo.name);
// ping was missed, reset the device
watchdogRunning = false;
Expand Down

0 comments on commit 74b699c

Please sign in to comment.