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
@@ -915,8 +915,7 @@ ACCELSIM::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);
@@ -946,6 +945,7 @@ ACCELSIM::mag_measure()
mag_report.timestamp = hrt_absolute_time();
mag_report.is_external = false;
mag_report.x_raw = (int16_t)(raw_mag_report.x / _mag_range_scale);
mag_report.y_raw = (int16_t)(raw_mag_report.y / _mag_range_scale);
@@ -278,6 +278,7 @@ int DfAK8963Wrapper::_publish(struct mag_sensor_data &data)
mag_report mag_report = {};
mag_report.timestamp = hrt_absolute_time();
mag_report.is_external = true;
// TODO: remove these (or get the values)
mag_report.x_raw = 0;
@@ -269,6 +269,7 @@ int DfHmc9250Wrapper::_publish(struct mag_sensor_data &data)
mag_report mag_report = {};
mag_report.timestamp = hrt_absolute_time();
mag_report.is_external = true;
/* The standard external mag by 3DR has x pointing to the
* right, y pointing backwards, and z down, therefore switch x
@@ -624,6 +624,7 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
mag_report.timestamp = accel_report.timestamp;
mag_report.is_external = false;
// TODO: get these right
gyro_report.scaling = -1.0f;
@@ -700,6 +700,7 @@ int DfMpu9250Wrapper::_publish(struct imu_sensor_data &data)
if (_mag_enabled) {
mag_report.timestamp = accel_report.timestamp;
mag_report.is_external = false;
mag_report.scaling = -1.0f;
mag_report.range_ga = -1.0f;