From 36528965f7c3f1f8e415aa72868950d16382ee1c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Apr 2016 08:09:25 +1000 Subject: [PATCH] AP_BoardConfig: added 7s timeout on uavcan startup --- libraries/AP_BoardConfig/AP_BoardConfig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/AP_BoardConfig/AP_BoardConfig.cpp b/libraries/AP_BoardConfig/AP_BoardConfig.cpp index 19527d17ff..ce36c3724a 100644 --- a/libraries/AP_BoardConfig/AP_BoardConfig.cpp +++ b/libraries/AP_BoardConfig/AP_BoardConfig.cpp @@ -191,13 +191,15 @@ void AP_BoardConfig::init() if (ret != 0) { hal.console->printf("UAVCAN: failed to start servers\n"); } else { + uint32_t start_wait_ms = AP_HAL::millis(); fd = open("/dev/uavcan/esc", 0); // design flaw of uavcan driver, this should be /dev/uavcan/node one day if (fd == -1) { AP_HAL::panic("Configuration invalid - unable to open /dev/uavcan/esc"); } // delay startup, UAVCAN still discovering nodes - while (ioctl(fd, UAVCAN_IOCG_NODEID_INPROGRESS,0) == OK) { + while (ioctl(fd, UAVCAN_IOCG_NODEID_INPROGRESS,0) == OK && + AP_HAL::millis() - start_wait_ms < 7000) { hal.scheduler->delay(500); } hal.console->printf("UAVCAN: node discovery complete\n");