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");