Compass: add dev_id for PX4

dev_id is retrieved from PX4Firmware via ioctl call
This commit is contained in:
Randy Mackay 2014-07-07 21:30:23 +09:00
parent b7f33d81ad
commit f42c9579d7
1 changed files with 4 additions and 0 deletions

View File

@ -30,6 +30,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <drivers/drv_device.h>
#include <drivers/drv_mag.h> #include <drivers/drv_mag.h>
#include <drivers/drv_hrt.h> #include <drivers/drv_hrt.h>
#include <stdio.h> #include <stdio.h>
@ -58,6 +59,9 @@ bool AP_Compass_PX4::init(void)
} }
for (uint8_t i=0; i<_num_instances; i++) { 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 // average over up to 20 samples
if (ioctl(_mag_fd[i], SENSORIOCSQUEUEDEPTH, 20) != 0) { if (ioctl(_mag_fd[i], SENSORIOCSQUEUEDEPTH, 20) != 0) {
hal.console->printf("Failed to setup compass queue\n"); hal.console->printf("Failed to setup compass queue\n");