From f42c9579d751f948656f982402711df3c6b52285 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Mon, 7 Jul 2014 21:30:23 +0900 Subject: [PATCH] Compass: add dev_id for PX4 dev_id is retrieved from PX4Firmware via ioctl call --- libraries/AP_Compass/AP_Compass_PX4.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libraries/AP_Compass/AP_Compass_PX4.cpp b/libraries/AP_Compass/AP_Compass_PX4.cpp index 9696cd57fe..f4673cc4fb 100644 --- a/libraries/AP_Compass/AP_Compass_PX4.cpp +++ b/libraries/AP_Compass/AP_Compass_PX4.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -58,6 +59,9 @@ bool AP_Compass_PX4::init(void) } for (uint8_t i=0; i<_num_instances; i++) { + // get device id + _dev_id[i] = ioctl(_mag_fd[i], DEVIOCGDEVICEID, 0); + // average over up to 20 samples if (ioctl(_mag_fd[i], SENSORIOCSQUEUEDEPTH, 20) != 0) { hal.console->printf("Failed to setup compass queue\n");