diff options
author | Holger Steinhaus <holger@steinhaus-home.de> | 2014-11-11 11:13:08 +0100 |
---|---|---|
committer | Holger Steinhaus <holger@steinhaus-home.de> | 2014-11-11 11:29:35 +0100 |
commit | 51ffb887c39ecfd0cb94879475f032ee65505321 (patch) | |
tree | 49acb3996936fafd953cda26c6df5d338e9d3841 /src/modules/uavcan/sensors | |
parent | 88093ebf1af5483d8b5c218adb1ea0c4798ee21e (diff) | |
download | px4-firmware-51ffb887c39ecfd0cb94879475f032ee65505321.tar.gz px4-firmware-51ffb887c39ecfd0cb94879475f032ee65505321.tar.bz2 px4-firmware-51ffb887c39ecfd0cb94879475f032ee65505321.zip |
UAVCAN: initialize device id for mag and baro to allow DEVIOCGDEVICEID ioctl to return useful data
Diffstat (limited to 'src/modules/uavcan/sensors')
-rw-r--r-- | src/modules/uavcan/sensors/mag.cpp | 2 | ||||
-rw-r--r-- | src/modules/uavcan/sensors/sensor_bridge.cpp | 3 | ||||
-rw-r--r-- | src/modules/uavcan/sensors/sensor_bridge.hpp | 2 |
3 files changed, 7 insertions, 0 deletions
diff --git a/src/modules/uavcan/sensors/mag.cpp b/src/modules/uavcan/sensors/mag.cpp index 8e6a9a22f..0d9ea08c5 100644 --- a/src/modules/uavcan/sensors/mag.cpp +++ b/src/modules/uavcan/sensors/mag.cpp @@ -49,6 +49,8 @@ UavcanMagnetometerBridge::UavcanMagnetometerBridge(uavcan::INode& node) : UavcanCDevSensorBridgeBase("uavcan_mag", "/dev/uavcan/mag", MAG_DEVICE_PATH, MAG_TOPICS), _sub_mag(node) { + _device_id.devid_s.devtype = DRV_MAG_DEVTYPE_HMC5883; + _scale.x_scale = 1.0F; _scale.y_scale = 1.0F; _scale.z_scale = 1.0F; diff --git a/src/modules/uavcan/sensors/sensor_bridge.cpp b/src/modules/uavcan/sensors/sensor_bridge.cpp index 9608ce680..0999938fc 100644 --- a/src/modules/uavcan/sensors/sensor_bridge.cpp +++ b/src/modules/uavcan/sensors/sensor_bridge.cpp @@ -103,6 +103,9 @@ void UavcanCDevSensorBridgeBase::publish(const int node_id, const void *report) return; } + // update device id as we now know our device node_id + _device_id.devid_s.address = static_cast<uint8_t>(node_id); + // Ask the CDev helper which class instance we can take const int class_instance = register_class_devname(_class_devname); if (class_instance < 0 || class_instance >= int(_max_channels)) { diff --git a/src/modules/uavcan/sensors/sensor_bridge.hpp b/src/modules/uavcan/sensors/sensor_bridge.hpp index 1316f7ecc..04c59b77d 100644 --- a/src/modules/uavcan/sensors/sensor_bridge.hpp +++ b/src/modules/uavcan/sensors/sensor_bridge.hpp @@ -112,6 +112,8 @@ protected: _channels(new Channel[MaxChannels]) { memcpy(_orb_topics, orb_topics, sizeof(orb_id_t) * MaxChannels); + _device_id.devid_s.bus_type = DeviceBusType_UAVCAN; + _device_id.devid_s.bus = 1; // @TBD: insert UAVCAN bus no. here } /** |