From 473d321af8bead4bd45299ad723b4c7beec94bce Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sun, 16 Aug 2015 23:04:41 +0300 Subject: [PATCH] UAVCAN Magnetometer driver update - no logical changes --- src/modules/uavcan/sensors/mag.cpp | 10 +++++----- src/modules/uavcan/sensors/mag.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/uavcan/sensors/mag.cpp b/src/modules/uavcan/sensors/mag.cpp index d08f5ed32b..ef9613b1f7 100644 --- a/src/modules/uavcan/sensors/mag.cpp +++ b/src/modules/uavcan/sensors/mag.cpp @@ -45,7 +45,7 @@ UavcanMagnetometerBridge::UavcanMagnetometerBridge(uavcan::INode &node) : UavcanCDevSensorBridgeBase("uavcan_mag", "/dev/uavcan/mag", MAG_BASE_DEVICE_PATH, ORB_ID(sensor_mag)), _sub_mag(node) { - _device_id.devid_s.devtype = DRV_MAG_DEVTYPE_HMC5883; + _device_id.devid_s.devtype = DRV_MAG_DEVTYPE_HMC5883; // <-- Why? _scale.x_scale = 1.0F; _scale.y_scale = 1.0F; @@ -141,16 +141,16 @@ int UavcanMagnetometerBridge::ioctl(struct file *filp, int cmd, unsigned long ar } } -void UavcanMagnetometerBridge::mag_sub_cb(const uavcan::ReceivedDataStructure +void UavcanMagnetometerBridge::mag_sub_cb(const uavcan::ReceivedDataStructure &msg) { lock(); _report.range_ga = 1.3F; // Arbitrary number, doesn't really mean anything _report.timestamp = msg.getMonotonicTimestamp().toUSec(); - _report.x = (msg.magnetic_field[0] - _scale.x_offset) * _scale.x_scale; - _report.y = (msg.magnetic_field[1] - _scale.y_offset) * _scale.y_scale; - _report.z = (msg.magnetic_field[2] - _scale.z_offset) * _scale.z_scale; + _report.x = (msg.magnetic_field_ga[0] - _scale.x_offset) * _scale.x_scale; + _report.y = (msg.magnetic_field_ga[1] - _scale.y_offset) * _scale.y_scale; + _report.z = (msg.magnetic_field_ga[2] - _scale.z_offset) * _scale.z_scale; unlock(); publish(msg.getSrcNodeID().get(), &_report); diff --git a/src/modules/uavcan/sensors/mag.hpp b/src/modules/uavcan/sensors/mag.hpp index b74afeb0be..a13883a494 100644 --- a/src/modules/uavcan/sensors/mag.hpp +++ b/src/modules/uavcan/sensors/mag.hpp @@ -40,7 +40,7 @@ #include "sensor_bridge.hpp" #include -#include +#include class UavcanMagnetometerBridge : public UavcanCDevSensorBridgeBase { @@ -57,14 +57,14 @@ private: ssize_t read(struct file *filp, char *buffer, size_t buflen); int ioctl(struct file *filp, int cmd, unsigned long arg) override; - void mag_sub_cb(const uavcan::ReceivedDataStructure &msg); + void mag_sub_cb(const uavcan::ReceivedDataStructure &msg); typedef uavcan::MethodBinder < UavcanMagnetometerBridge *, void (UavcanMagnetometerBridge::*) - (const uavcan::ReceivedDataStructure &) > + (const uavcan::ReceivedDataStructure &) > MagCbBinder; - uavcan::Subscriber _sub_mag; + uavcan::Subscriber _sub_mag; mag_scale _scale = {}; mag_report _report = {}; };