PX4Magnetometer implement MAGIOCGSCALE (copy out scale)

- fixes #12193
This commit is contained in:
Daniel Agar 2019-06-06 14:10:13 -04:00 committed by GitHub
parent ab0466eddf
commit 55c9786157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -72,6 +72,20 @@ int PX4Magnetometer::ioctl(cdev::file_t *filp, int cmd, unsigned long arg)
return PX4_OK; return PX4_OK;
case MAGIOCGSCALE: {
// copy out scale factors
mag_calibration_s cal{};
cal.x_offset = _calibration_offset(0);
cal.y_offset = _calibration_offset(1);
cal.z_offset = _calibration_offset(2);
cal.x_scale = _calibration_scale(0);
cal.y_scale = _calibration_scale(1);
cal.z_scale = _calibration_scale(2);
memcpy((mag_calibration_s *)arg, &cal, sizeof(cal));
}
return 0;
case DEVIOCGDEVICEID: case DEVIOCGDEVICEID:
return _sensor_mag_pub.get().device_id; return _sensor_mag_pub.get().device_id;