Fix PX4IO startup

This commit is contained in:
Lorenz Meier
2015-02-08 12:30:39 +01:00
parent 769df2ff47
commit 0fd11b78eb
5 changed files with 21 additions and 5 deletions
+8 -1
View File
@@ -622,8 +622,15 @@ PX4IO::init()
return ret;
/* get some parameters */
unsigned protocol = io_reg_get(PX4IO_PAGE_CONFIG, PX4IO_P_CONFIG_PROTOCOL_VERSION);
unsigned protocol;
hrt_abstime start_try_time = hrt_absolute_time();
do {
usleep(2000);
protocol = io_reg_get(PX4IO_PAGE_CONFIG, PX4IO_P_CONFIG_PROTOCOL_VERSION);
} while (protocol == _io_reg_get_error && (hrt_elapsed_time(&start_try_time) < 700U * 1000U));
/* if the error still persists after timing out, we give up */
if (protocol == _io_reg_get_error) {
mavlink_and_console_log_emergency(_mavlink_fd, "Failed to communicate with IO, abort.");
return -1;