mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-01 02:55:07 +08:00
replace mag_report with sensor_mag_s
This commit is contained in:
@@ -276,7 +276,7 @@ int DfAK8963Wrapper::_publish(struct mag_sensor_data &data)
|
|||||||
/* Publish mag first. */
|
/* Publish mag first. */
|
||||||
perf_begin(_mag_sample_perf);
|
perf_begin(_mag_sample_perf);
|
||||||
|
|
||||||
mag_report mag_report = {};
|
sensor_mag_s mag_report = {};
|
||||||
mag_report.timestamp = hrt_absolute_time();
|
mag_report.timestamp = hrt_absolute_time();
|
||||||
mag_report.is_external = true;
|
mag_report.is_external = true;
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ int DfLsm9ds1Wrapper::start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_mag_enabled) {
|
if (_mag_enabled) {
|
||||||
mag_report mag_report = {};
|
sensor_mag_s mag_report = {};
|
||||||
_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mag_report,
|
_mag_topic = orb_advertise_multi(ORB_ID(sensor_mag), &mag_report,
|
||||||
&_mag_orb_class_instance, ORB_PRIO_DEFAULT);
|
&_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_accel_s accel_report = {};
|
||||||
sensor_gyro_s gyro_report = {};
|
sensor_gyro_s gyro_report = {};
|
||||||
mag_report mag_report = {};
|
sensor_mag_s mag_report = {};
|
||||||
|
|
||||||
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
|
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
|
||||||
mag_report.timestamp = accel_report.timestamp;
|
mag_report.timestamp = accel_report.timestamp;
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ int DfMpu9250Wrapper::_publish(struct imu_sensor_data &data)
|
|||||||
|
|
||||||
sensor_accel_s accel_report = {};
|
sensor_accel_s accel_report = {};
|
||||||
sensor_gyro_s gyro_report = {};
|
sensor_gyro_s gyro_report = {};
|
||||||
mag_report mag_report = {};
|
sensor_mag_s mag_report = {};
|
||||||
|
|
||||||
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
|
accel_report.timestamp = gyro_report.timestamp = hrt_absolute_time();
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@
|
|||||||
#define MAG2_DEVICE_PATH "/dev/mag2"
|
#define MAG2_DEVICE_PATH "/dev/mag2"
|
||||||
|
|
||||||
#include <uORB/topics/sensor_mag.h>
|
#include <uORB/topics/sensor_mag.h>
|
||||||
#define mag_report sensor_mag_s
|
|
||||||
|
|
||||||
/** mag scaling factors; Vout = (Vin * Vscale) + Voffset */
|
/** mag scaling factors; Vout = (Vin * Vscale) + Voffset */
|
||||||
struct mag_calibration_s {
|
struct mag_calibration_s {
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ void test(bool external_bus)
|
|||||||
{
|
{
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
const char *path = (external_bus ? BMM150_DEVICE_PATH_MAG_EXT : BMM150_DEVICE_PATH_MAG);
|
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;
|
ssize_t sz;
|
||||||
|
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ int BMM150::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
goto out;
|
goto out;
|
||||||
@@ -374,7 +374,7 @@ int BMM150::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* advertise sensor topic, measure manually to initialize valid report */
|
/* advertise sensor topic, measure manually to initialize valid report */
|
||||||
struct mag_report mrb;
|
sensor_mag_s mrb;
|
||||||
_reports->get(&mrb);
|
_reports->get(&mrb);
|
||||||
|
|
||||||
/* measurement will have generated a report, publish */
|
/* measurement will have generated a report, publish */
|
||||||
@@ -425,8 +425,8 @@ BMM150::stop()
|
|||||||
ssize_t
|
ssize_t
|
||||||
BMM150::read(struct file *filp, char *buffer, size_t buflen)
|
BMM150::read(struct file *filp, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned count = buflen / sizeof(mag_report);
|
unsigned count = buflen / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -443,7 +443,7 @@ BMM150::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -474,7 +474,7 @@ BMM150::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
|
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ BMM150::collect()
|
|||||||
bool mag_notify = true;
|
bool mag_notify = true;
|
||||||
uint8_t mag_data[8], status;
|
uint8_t mag_data[8], status;
|
||||||
uint16_t resistance, lsb, msb, msblsb;
|
uint16_t resistance, lsb, msb, msblsb;
|
||||||
mag_report mrb;
|
sensor_mag_s mrb{};
|
||||||
|
|
||||||
|
|
||||||
/* start collecting data */
|
/* start collecting data */
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ private:
|
|||||||
unsigned _call_interval;
|
unsigned _call_interval;
|
||||||
|
|
||||||
|
|
||||||
mag_report _report {};
|
sensor_mag_s _report {};
|
||||||
ringbuffer::RingBuffer *_reports;
|
ringbuffer::RingBuffer *_reports;
|
||||||
|
|
||||||
bool _collect_phase;
|
bool _collect_phase;
|
||||||
@@ -265,7 +265,7 @@ private:
|
|||||||
enum Rotation _rotation;
|
enum Rotation _rotation;
|
||||||
bool _got_duplicate;
|
bool _got_duplicate;
|
||||||
|
|
||||||
mag_report _last_report {}; /**< used for info() */
|
sensor_mag_s _last_report {}; /**< used for info() */
|
||||||
|
|
||||||
int init_trim_registers(void);
|
int init_trim_registers(void);
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ HMC5883::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
goto out;
|
goto out;
|
||||||
@@ -243,8 +243,8 @@ void HMC5883::check_conf(void)
|
|||||||
ssize_t
|
ssize_t
|
||||||
HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
|
HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned count = buflen / sizeof(struct mag_report);
|
unsigned count = buflen / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -261,7 +261,7 @@ HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ HMC5883::read(cdev::file_t *filp, char *buffer, size_t buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
@@ -498,7 +498,7 @@ HMC5883::collect()
|
|||||||
uint8_t check_counter;
|
uint8_t check_counter;
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
struct mag_report new_report;
|
sensor_mag_s new_report;
|
||||||
bool sensor_is_onboard = false;
|
bool sensor_is_onboard = false;
|
||||||
|
|
||||||
float xraw_f;
|
float xraw_f;
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ private:
|
|||||||
|
|
||||||
enum Rotation _rotation;
|
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 _range_bits;
|
||||||
uint8_t _conf_reg;
|
uint8_t _conf_reg;
|
||||||
|
|||||||
@@ -428,7 +428,7 @@ IST8310::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
goto out;
|
goto out;
|
||||||
@@ -515,8 +515,8 @@ void IST8310::check_conf(void)
|
|||||||
ssize_t
|
ssize_t
|
||||||
IST8310::read(struct file *filp, char *buffer, size_t buflen)
|
IST8310::read(struct file *filp, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned count = buflen / sizeof(struct mag_report);
|
unsigned count = buflen / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -533,7 +533,7 @@ IST8310::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -563,7 +563,7 @@ IST8310::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
@@ -781,7 +781,7 @@ IST8310::collect()
|
|||||||
uint8_t check_counter;
|
uint8_t check_counter;
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
struct mag_report new_report;
|
sensor_mag_s new_report;
|
||||||
const bool sensor_is_external = external();
|
const bool sensor_is_external = external();
|
||||||
|
|
||||||
float xraw_f;
|
float xraw_f;
|
||||||
@@ -899,7 +899,7 @@ out:
|
|||||||
|
|
||||||
int IST8310::calibrate(struct file *filp, unsigned enable)
|
int IST8310::calibrate(struct file *filp, unsigned enable)
|
||||||
{
|
{
|
||||||
struct mag_report report {};
|
sensor_mag_s report {};
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
float total_x = 0.0f;
|
float total_x = 0.0f;
|
||||||
@@ -1249,7 +1249,7 @@ void
|
|||||||
test(enum IST8310_BUS busid)
|
test(enum IST8310_BUS busid)
|
||||||
{
|
{
|
||||||
struct ist8310_bus_option &bus = find_bus(busid);
|
struct ist8310_bus_option &bus = find_bus(busid);
|
||||||
struct mag_report report {};
|
sensor_mag_s report {};
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
const char *path = bus.devpath;
|
const char *path = bus.devpath;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ LIS3MDL::~LIS3MDL()
|
|||||||
int
|
int
|
||||||
LIS3MDL::calibrate(struct file *file_pointer, unsigned enable)
|
LIS3MDL::calibrate(struct file *file_pointer, unsigned enable)
|
||||||
{
|
{
|
||||||
struct mag_report report;
|
sensor_mag_s report;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
uint8_t num_samples = 10;
|
uint8_t num_samples = 10;
|
||||||
@@ -348,7 +348,7 @@ LIS3MDL::collect()
|
|||||||
float yraw_f;
|
float yraw_f;
|
||||||
float zraw_f;
|
float zraw_f;
|
||||||
|
|
||||||
struct mag_report new_mag_report;
|
sensor_mag_s new_mag_report;
|
||||||
bool sensor_is_onboard = false;
|
bool sensor_is_onboard = false;
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
@@ -477,7 +477,7 @@ LIS3MDL::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
@@ -631,8 +631,8 @@ LIS3MDL::reset()
|
|||||||
int
|
int
|
||||||
LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
||||||
{
|
{
|
||||||
unsigned count = buffer_len / sizeof(struct mag_report);
|
unsigned count = buffer_len / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -649,7 +649,7 @@ LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -679,7 +679,7 @@ LIS3MDL::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ private:
|
|||||||
|
|
||||||
struct mag_calibration_s _scale;
|
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;
|
orb_advert_t _mag_topic;
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ lis3mdl::stop(struct lis3mdl_bus_option &bus)
|
|||||||
int
|
int
|
||||||
lis3mdl::test(struct lis3mdl_bus_option &bus)
|
lis3mdl::test(struct lis3mdl_bus_option &bus)
|
||||||
{
|
{
|
||||||
struct mag_report report;
|
sensor_mag_s report;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
const char *path = bus.devpath;
|
const char *path = bus.devpath;
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ LSM303AGR::collect()
|
|||||||
/* start the performance counter */
|
/* start the performance counter */
|
||||||
perf_begin(_mag_sample_perf);
|
perf_begin(_mag_sample_perf);
|
||||||
|
|
||||||
mag_report mag_report = {};
|
sensor_mag_s mag_report = {};
|
||||||
mag_report.timestamp = hrt_absolute_time();
|
mag_report.timestamp = hrt_absolute_time();
|
||||||
|
|
||||||
// switch to right hand coordinate system in place
|
// switch to right hand coordinate system in place
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ private:
|
|||||||
|
|
||||||
enum Rotation _rotation;
|
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 _range_bits;
|
||||||
uint8_t _conf_reg;
|
uint8_t _conf_reg;
|
||||||
@@ -330,7 +330,7 @@ QMC5883::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
goto out;
|
goto out;
|
||||||
@@ -378,8 +378,8 @@ void QMC5883::check_conf(void)
|
|||||||
ssize_t
|
ssize_t
|
||||||
QMC5883::read(struct file *filp, char *buffer, size_t buflen)
|
QMC5883::read(struct file *filp, char *buffer, size_t buflen)
|
||||||
{
|
{
|
||||||
unsigned count = buflen / sizeof(struct mag_report);
|
unsigned count = buflen / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -396,7 +396,7 @@ QMC5883::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -420,7 +420,7 @@ QMC5883::read(struct file *filp, char *buffer, size_t buflen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
@@ -617,7 +617,7 @@ QMC5883::collect()
|
|||||||
uint8_t check_counter;
|
uint8_t check_counter;
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
struct mag_report new_report;
|
sensor_mag_s new_report;
|
||||||
bool sensor_is_onboard = false;
|
bool sensor_is_onboard = false;
|
||||||
|
|
||||||
float xraw_f;
|
float xraw_f;
|
||||||
@@ -953,7 +953,7 @@ void
|
|||||||
test(enum QMC5883_BUS busid)
|
test(enum QMC5883_BUS busid)
|
||||||
{
|
{
|
||||||
struct qmc5883_bus_option &bus = find_bus(busid);
|
struct qmc5883_bus_option &bus = find_bus(busid);
|
||||||
struct mag_report report;
|
sensor_mag_s report;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
const char *path = bus.devpath;
|
const char *path = bus.devpath;
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ RM3100::collect()
|
|||||||
float yraw_f;
|
float yraw_f;
|
||||||
float zraw_f;
|
float zraw_f;
|
||||||
|
|
||||||
struct mag_report new_mag_report;
|
sensor_mag_s new_mag_report;
|
||||||
bool sensor_is_onboard = false;
|
bool sensor_is_onboard = false;
|
||||||
|
|
||||||
perf_begin(_sample_perf);
|
perf_begin(_sample_perf);
|
||||||
@@ -326,7 +326,7 @@ RM3100::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* allocate basic report buffers */
|
/* allocate basic report buffers */
|
||||||
_reports = new ringbuffer::RingBuffer(2, sizeof(mag_report));
|
_reports = new ringbuffer::RingBuffer(2, sizeof(sensor_mag_s));
|
||||||
|
|
||||||
if (_reports == nullptr) {
|
if (_reports == nullptr) {
|
||||||
return PX4_ERROR;
|
return PX4_ERROR;
|
||||||
@@ -500,8 +500,8 @@ RM3100::reset()
|
|||||||
int
|
int
|
||||||
RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
||||||
{
|
{
|
||||||
unsigned count = buffer_len / sizeof(struct mag_report);
|
unsigned count = buffer_len / sizeof(sensor_mag_s);
|
||||||
struct mag_report *mag_buf = reinterpret_cast<struct mag_report *>(buffer);
|
sensor_mag_s *mag_buf = reinterpret_cast<sensor_mag_s *>(buffer);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
/* buffer must be large enough */
|
/* buffer must be large enough */
|
||||||
@@ -518,7 +518,7 @@ RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
|||||||
*/
|
*/
|
||||||
while (count--) {
|
while (count--) {
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret += sizeof(struct mag_report);
|
ret += sizeof(sensor_mag_s);
|
||||||
mag_buf++;
|
mag_buf++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,7 +548,7 @@ RM3100::read(struct file *file_pointer, char *buffer, size_t buffer_len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_reports->get(mag_buf)) {
|
if (_reports->get(mag_buf)) {
|
||||||
ret = sizeof(struct mag_report);
|
ret = sizeof(sensor_mag_s);
|
||||||
}
|
}
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ private:
|
|||||||
|
|
||||||
struct mag_calibration_s _scale;
|
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;
|
orb_advert_t _mag_topic;
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ bool
|
|||||||
rm3100::test(RM3100_BUS bus_id)
|
rm3100::test(RM3100_BUS bus_id)
|
||||||
{
|
{
|
||||||
struct rm3100_bus_option &bus = find_bus(bus_id);
|
struct rm3100_bus_option &bus = find_bus(bus_id);
|
||||||
struct mag_report report;
|
sensor_mag_s report;
|
||||||
ssize_t sz;
|
ssize_t sz;
|
||||||
int ret;
|
int ret;
|
||||||
const char *path = bus.devpath;
|
const char *path = bus.devpath;
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ static int _mag_orb_class_instance; /**< instance handle for mag devices
|
|||||||
static int _params_sub; /**< parameter update subscription */
|
static int _params_sub; /**< parameter update subscription */
|
||||||
static sensor_gyro_s _gyro; /**< gyro report */
|
static sensor_gyro_s _gyro; /**< gyro report */
|
||||||
static sensor_accel_s _accel; /**< accel 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 gyro_calibration_s _gyro_sc; /**< gyro scale */
|
||||||
static struct accel_calibration_s _accel_sc; /**< accel scale */
|
static struct accel_calibration_s _accel_sc; /**< accel scale */
|
||||||
static struct mag_calibration_s _mag_sc; /**< mag scale */
|
static struct mag_calibration_s _mag_sc; /**< mag scale */
|
||||||
@@ -348,7 +348,7 @@ bool create_pubs()
|
|||||||
// initialize the reports
|
// initialize the reports
|
||||||
memset(&_gyro, 0, sizeof(sensor_gyro_s));
|
memset(&_gyro, 0, sizeof(sensor_gyro_s));
|
||||||
memset(&_accel, 0, sizeof(sensor_accel_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_pub = orb_advertise_multi(ORB_ID(sensor_gyro), &_gyro,
|
||||||
&_gyro_orb_class_instance, ORB_PRIO_HIGH - 1);
|
&_gyro_orb_class_instance, ORB_PRIO_HIGH - 1);
|
||||||
|
|||||||
@@ -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];
|
prev_count[cur_mag] = worker_data->calibration_counter_total[cur_mag];
|
||||||
|
|
||||||
if (worker_data->sub_mag[cur_mag] >= 0) {
|
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);
|
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++) {
|
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);
|
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);
|
orb_copy(ORB_ID(sensor_mag), worker_data.sub_mag[cur_mag], &report);
|
||||||
|
|
||||||
#ifdef __PX4_NUTTX
|
#ifdef __PX4_NUTTX
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ void VotedSensorsUpdate::parametersUpdate()
|
|||||||
for (int topic_instance = 0; topic_instance < MAG_COUNT_MAX
|
for (int topic_instance = 0; topic_instance < MAG_COUNT_MAX
|
||||||
&& topic_instance < _mag.subscription_count; ++topic_instance) {
|
&& 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) {
|
if (orb_copy(ORB_ID(sensor_mag), _mag.subscription[topic_instance], &report) != 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -779,7 +779,7 @@ void VotedSensorsUpdate::magPoll(vehicle_magnetometer_s &magnetometer)
|
|||||||
orb_check(_mag.subscription[uorb_index], &mag_updated);
|
orb_check(_mag.subscription[uorb_index], &mag_updated);
|
||||||
|
|
||||||
if (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);
|
int ret = orb_copy(ORB_ID(sensor_mag), _mag.subscription[uorb_index], &mag_report);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user