sensor_mag.msg: add is_external flag & set it in the mag drivers

With this we don't have to use the ioctl MAGIOCGEXTERNAL, which does not
work on POSIX (eg. RPi).
This commit is contained in:
Beat Küng
2017-06-14 11:19:29 +02:00
committed by Lorenz Meier
parent 19cdbcfd4f
commit ce7d8d2270
15 changed files with 35 additions and 27 deletions
+3 -3
View File
@@ -251,7 +251,6 @@ BMM150 :: BMM150(int bus, const char *path, bool external, enum Rotation rotatio
_external(false),
_running(false),
_call_interval(0),
_report{0},
_reports(nullptr),
_collect_phase(false),
_scale{},
@@ -344,7 +343,7 @@ int BMM150::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
if (_reports == nullptr) {
goto out;
@@ -433,7 +432,7 @@ BMM150::stop()
ssize_t
BMM150::read(struct file *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(_report);
unsigned count = buflen / sizeof(mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
int ret = 0;
@@ -684,6 +683,7 @@ BMM150::collect()
mrb.timestamp = hrt_absolute_time();
mrb.is_external = is_external();
// report the error count as the number of bad transfers.
// This allows the higher level code to decide if it
-1
View File
@@ -228,7 +228,6 @@ private:
unsigned _call_interval;
struct mag_report _report;
ringbuffer::RingBuffer *_reports;
bool _collect_phase;
+1
View File
@@ -997,6 +997,7 @@ HMC5883::collect()
// XXX revisit for SPI part, might require a bus type IOCTL
unsigned dummy;
sensor_is_onboard = !_interface->ioctl(MAGIOCGEXTERNAL, dummy);
new_report.is_external = !sensor_is_onboard;
if (sensor_is_onboard) {
// convert onboard so it matches offboard for the
+1
View File
@@ -913,6 +913,7 @@ IST8310::collect()
/* this should be fairly close to the end of the measurement, so the best approximation of the time */
new_report.timestamp = hrt_absolute_time();
new_report.is_external = !sensor_is_onboard;
new_report.error_count = perf_event_count(_comms_errors);
new_report.scaling = _range_scale;
new_report.device_id = _device_id.devid;
+1
View File
@@ -945,6 +945,7 @@ LIS3MDL::collect()
unsigned dummy;
sensor_is_onboard = !_interface->ioctl(MAGIOCGEXTERNAL, dummy);
new_report.is_external = !sensor_is_onboard;
/*
* RAW outputs
+2 -2
View File
@@ -1653,8 +1653,7 @@ LSM303D::mag_measure()
} raw_mag_report;
#pragma pack(pop)
mag_report mag_report;
memset(&mag_report, 0, sizeof(mag_report));
mag_report mag_report {};
/* start the performance counter */
perf_begin(_mag_sample_perf);
@@ -1680,6 +1679,7 @@ LSM303D::mag_measure()
*/
mag_report.timestamp = hrt_absolute_time();
mag_report.is_external = is_external();
mag_report.x_raw = raw_mag_report.x;
mag_report.y_raw = raw_mag_report.y;
+1
View File
@@ -205,6 +205,7 @@ MPU9250_mag::_measure(struct ak8963_regs data)
mag_report mrb;
mrb.timestamp = hrt_absolute_time();
mrb.is_external = false;
/*
* Align axes - note the accel & gryo are also re-aligned so this