replace mag_report with sensor_mag_s

This commit is contained in:
Daniel Agar
2020-01-10 11:08:28 -05:00
parent e19e0bd616
commit ceec0238c4
20 changed files with 61 additions and 62 deletions

View File

@@ -276,7 +276,7 @@ int DfAK8963Wrapper::_publish(struct mag_sensor_data &data)
/* Publish mag first. */
perf_begin(_mag_sample_perf);
mag_report mag_report = {};
sensor_mag_s mag_report = {};
mag_report.timestamp = hrt_absolute_time();
mag_report.is_external = true;

View File

@@ -256,7 +256,7 @@ int DfLsm9ds1Wrapper::start()
}
if (_mag_enabled) {
mag_report mag_report = {};
sensor_mag_s mag_report = {};
_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mag_report,
&_mag_orb_class_instance, ORB_PRIO_DEFAULT);
@@ -593,7 +593,7 @@ int DfLsm9ds1Wrapper::_publish(struct imu_sensor_data &data)
sensor_accel_s accel_report = {};
sensor_gyro_s gyro_report = {};
mag_report mag_report = {};
sensor_mag_s mag_report = {};
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
mag_report.timestamp = accel_report.timestamp;

View File

@@ -587,7 +587,7 @@ int DfMpu9250Wrapper::_publish(struct imu_sensor_data &data)
sensor_accel_s accel_report = {};
sensor_gyro_s gyro_report = {};
mag_report mag_report = {};
sensor_mag_s mag_report = {};
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();

View File

@@ -50,7 +50,6 @@
#define MAG2_DEVICE_PATH "/dev/mag2"
#include <uORB/topics/sensor_mag.h>
#define mag_report sensor_mag_s
/** mag scaling factors; Vout = (Vin * Vscale) + Voffset */
struct mag_calibration_s {

View File

@@ -135,7 +135,7 @@ void test(bool external_bus)
{
int fd = -1;
const char *path = (external_bus ? BMM150_DEVICE_PATH_MAG_EXT : BMM150_DEVICE_PATH_MAG);
struct mag_report m_report;
sensor_mag_s m_report;
ssize_t sz;
@@ -338,7 +338,7 @@ int BMM150::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
goto out;
@@ -374,7 +374,7 @@ int BMM150::init()
}
/* advertise sensor topic, measure manually to initialize valid report */
struct mag_report mrb;
sensor_mag_s mrb;
_reports->get(&mrb);
/* measurement will have generated a report, publish */
@@ -425,8 +425,8 @@ BMM150::stop()
ssize_t
BMM150::read(struct file *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buflen / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -443,7 +443,7 @@ BMM150::read(struct file *filp, char *buffer, size_t buflen)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -474,7 +474,7 @@ BMM150::read(struct file *filp, char *buffer, size_t buflen)
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);
@@ -540,7 +540,7 @@ BMM150::collect()
bool mag_notify = true;
uint8_t mag_data[8], status;
uint16_t resistance, lsb, msb, msblsb;
mag_report mrb;
sensor_mag_s mrb{};
/* start collecting data */

View File

@@ -224,7 +224,7 @@ private:
unsigned _call_interval;
mag_report _report {};
sensor_mag_s _report {};
ringbuffer::RingBuffer *_reports;
bool _collect_phase;
@@ -265,7 +265,7 @@ private:
enum Rotation _rotation;
bool _got_duplicate;
mag_report _last_report {}; /**< used for info() */
sensor_mag_s _last_report {}; /**< used for info() */
int init_trim_registers(void);

View File

@@ -104,7 +104,7 @@ HMC5883::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
goto out;
@@ -243,8 +243,8 @@ void HMC5883::check_conf(void)
ssize_t
HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buflen / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -261,7 +261,7 @@ HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -291,7 +291,7 @@ HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
}
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);
@@ -498,7 +498,7 @@ HMC5883::collect()
uint8_t check_counter;
perf_begin(_sample_perf);
struct mag_report new_report;
sensor_mag_s new_report;
bool sensor_is_onboard = false;
float xraw_f;

View File

@@ -158,7 +158,7 @@ private:
enum Rotation _rotation;
struct mag_report _last_report {}; /**< used for info() */
sensor_mag_s _last_report {}; /**< used for info() */
uint8_t _range_bits;
uint8_t _conf_reg;

View File

@@ -428,7 +428,7 @@ IST8310::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
goto out;
@@ -515,8 +515,8 @@ void IST8310::check_conf(void)
ssize_t
IST8310::read(struct file *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buflen / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -533,7 +533,7 @@ IST8310::read(struct file *filp, char *buffer, size_t buflen)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -563,7 +563,7 @@ IST8310::read(struct file *filp, char *buffer, size_t buflen)
}
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);
@@ -781,7 +781,7 @@ IST8310::collect()
uint8_t check_counter;
perf_begin(_sample_perf);
struct mag_report new_report;
sensor_mag_s new_report;
const bool sensor_is_external = external();
float xraw_f;
@@ -899,7 +899,7 @@ out:
int IST8310::calibrate(struct file *filp, unsigned enable)
{
struct mag_report report {};
sensor_mag_s report {};
ssize_t sz;
int ret = 1;
float total_x = 0.0f;
@@ -1249,7 +1249,7 @@ void
test(enum IST8310_BUS busid)
{
struct ist8310_bus_option &bus = find_bus(busid);
struct mag_report report {};
sensor_mag_s report {};
ssize_t sz;
int ret;
const char *path = bus.devpath;

View File

@@ -116,7 +116,7 @@ LIS3MDL::~LIS3MDL()
int
LIS3MDL::calibrate(struct file *file_pointer, unsigned enable)
{
struct mag_report report;
sensor_mag_s report;
ssize_t sz;
int ret = 1;
uint8_t num_samples = 10;
@@ -348,7 +348,7 @@ LIS3MDL::collect()
float yraw_f;
float zraw_f;
struct mag_report new_mag_report;
sensor_mag_s new_mag_report;
bool sensor_is_onboard = false;
perf_begin(_sample_perf);
@@ -477,7 +477,7 @@ LIS3MDL::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
return PX4_ERROR;
@@ -631,8 +631,8 @@ LIS3MDL::reset()
int
LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
{
unsigned count = buffer_len / sizeof(struct mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buffer_len / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -649,7 +649,7 @@ LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -679,7 +679,7 @@ LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
}
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);

View File

@@ -145,7 +145,7 @@ private:
struct mag_calibration_s _scale;
struct mag_report _last_report {}; /**< used for info() */
sensor_mag_s _last_report {}; /**< used for info() */
orb_advert_t _mag_topic;

View File

@@ -160,7 +160,7 @@ lis3mdl::stop(struct lis3mdl_bus_option &bus)
int
lis3mdl::test(struct lis3mdl_bus_option &bus)
{
struct mag_report report;
sensor_mag_s report;
ssize_t sz;
int ret;
const char *path = bus.devpath;

View File

@@ -423,7 +423,7 @@ LSM303AGR::collect()
/* start the performance counter */
perf_begin(_mag_sample_perf);
mag_report mag_report = {};
sensor_mag_s mag_report = {};
mag_report.timestamp = hrt_absolute_time();
// switch to right hand coordinate system in place

View File

@@ -181,7 +181,7 @@ private:
enum Rotation _rotation;
struct mag_report _last_report {}; /**< used for info() */
sensor_mag_s _last_report {}; /**< used for info() */
uint8_t _range_bits;
uint8_t _conf_reg;
@@ -330,7 +330,7 @@ QMC5883::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
goto out;
@@ -378,8 +378,8 @@ void QMC5883::check_conf(void)
ssize_t
QMC5883::read(struct file *filp, char *buffer, size_t buflen)
{
unsigned count = buflen / sizeof(struct mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buflen / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -396,7 +396,7 @@ QMC5883::read(struct file *filp, char *buffer, size_t buflen)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -420,7 +420,7 @@ QMC5883::read(struct file *filp, char *buffer, size_t buflen)
}
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);
@@ -617,7 +617,7 @@ QMC5883::collect()
uint8_t check_counter;
perf_begin(_sample_perf);
struct mag_report new_report;
sensor_mag_s new_report;
bool sensor_is_onboard = false;
float xraw_f;
@@ -953,7 +953,7 @@ void
test(enum QMC5883_BUS busid)
{
struct qmc5883_bus_option &bus = find_bus(busid);
struct mag_report report;
sensor_mag_s report;
ssize_t sz;
int ret;
const char *path = bus.devpath;

View File

@@ -192,7 +192,7 @@ RM3100::collect()
float yraw_f;
float zraw_f;
struct mag_report new_mag_report;
sensor_mag_s new_mag_report;
bool sensor_is_onboard = false;
perf_begin(_sample_perf);
@@ -326,7 +326,7 @@ RM3100::init()
}
/* allocate basic report buffers */
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
if (_reports == nullptr) {
return PX4_ERROR;
@@ -500,8 +500,8 @@ RM3100::reset()
int
RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
{
unsigned count = buffer_len / sizeof(struct mag_report);
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
unsigned count = buffer_len / sizeof(sensor_mag_s);
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
int ret = 0;
/* buffer must be large enough */
@@ -518,7 +518,7 @@ RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
*/
while (count--) {
if (_reports->get(mag_buf)) {
ret += sizeof(struct mag_report);
ret += sizeof(sensor_mag_s);
mag_buf++;
}
}
@@ -548,7 +548,7 @@ RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
}
if (_reports->get(mag_buf)) {
ret = sizeof(struct mag_report);
ret = sizeof(sensor_mag_s);
}
} while (0);

View File

@@ -152,7 +152,7 @@ private:
struct mag_calibration_s _scale;
struct mag_report _last_report {}; /**< used for info() */
sensor_mag_s _last_report {}; /**< used for info() */
orb_advert_t _mag_topic;

View File

@@ -154,7 +154,7 @@ bool
rm3100::test(RM3100_BUS bus_id)
{
struct rm3100_bus_option &bus = find_bus(bus_id);
struct mag_report report;
sensor_mag_s report;
ssize_t sz;
int ret;
const char *path = bus.devpath;

View File

@@ -98,7 +98,7 @@ static int _mag_orb_class_instance; /**< instance handle for mag devices
static int _params_sub; /**< parameter update subscription */
static sensor_gyro_s _gyro; /**< gyro report */
static sensor_accel_s _accel; /**< accel report */
static struct mag_report _mag; /**< mag report */
static sensor_mag_s _mag; /**< mag report */
static struct gyro_calibration_s _gyro_sc; /**< gyro scale */
static struct accel_calibration_s _accel_sc; /**< accel scale */
static struct mag_calibration_s _mag_sc; /**< mag scale */
@@ -348,7 +348,7 @@ bool create_pubs()
// initialize the reports
memset(&_gyro, 0, sizeof(sensor_gyro_s));
memset(&_accel, 0, sizeof(sensor_accel_s));
memset(&_mag, 0, sizeof(struct mag_report));
memset(&_mag, 0, sizeof(sensor_mag_s));
_gyro_pub = orb_advertise_multi(ORB_ID(sensor_gyro), &_gyro,
&_gyro_orb_class_instance, ORB_PRIO_HIGH - 1);

View File

@@ -462,7 +462,7 @@ static calibrate_return mag_calibration_worker(detect_orientation_return orienta
prev_count[cur_mag] = worker_data->calibration_counter_total[cur_mag];
if (worker_data->sub_mag[cur_mag] >= 0) {
struct mag_report mag;
sensor_mag_s mag{};
orb_copy(ORB_ID(sensor_mag), worker_data->sub_mag[cur_mag], &mag);
@@ -606,7 +606,7 @@ calibrate_return mag_calibrate_all(orb_advert_t *mavlink_log_pub, int32_t cal_ma
for (unsigned i = 0; i < orb_mag_count && !found_cur_mag; i++) {
worker_data.sub_mag[cur_mag] = orb_subscribe_multi(ORB_ID(sensor_mag), i);
struct mag_report report;
sensor_mag_s report{};
orb_copy(ORB_ID(sensor_mag), worker_data.sub_mag[cur_mag], &report);
#ifdef __PX4_NUTTX

View File

@@ -417,7 +417,7 @@ void VotedSensorsUpdate::parametersUpdate()
for (int topic_instance = 0; topic_instance < MAG_COUNT_MAX
&& topic_instance < _mag.subscription_count; ++topic_instance) {
struct mag_report report;
sensor_mag_s report;
if (orb_copy(ORB_ID(sensor_mag), _mag.subscription[topic_instance], &report) != 0) {
continue;
@@ -779,7 +779,7 @@ void VotedSensorsUpdate::magPoll(vehicle_magnetometer_s &magnetometer)
orb_check(_mag.subscription[uorb_index], &mag_updated);
if (mag_updated) {
struct mag_report mag_report;
sensor_mag_s mag_report{};
int ret = orb_copy(ORB_ID(sensor_mag), _mag.subscription[uorb_index], &mag_report);