diff options
author | Pavel Kirienko <pavel.kirienko@gmail.com> | 2014-08-22 20:33:35 +0400 |
---|---|---|
committer | Pavel Kirienko <pavel.kirienko@gmail.com> | 2014-08-22 20:33:35 +0400 |
commit | 7132141cc478e1b9cdde41207c03f2c622f7831a (patch) | |
tree | bbd3bdc055bef9445b321af499a1ad3de57f923b | |
parent | 6870cd4d3d68941945d303b707c4b05bd5d1e6e4 (diff) | |
download | px4-firmware-7132141cc478e1b9cdde41207c03f2c622f7831a.tar.gz px4-firmware-7132141cc478e1b9cdde41207c03f2c622f7831a.tar.bz2 px4-firmware-7132141cc478e1b9cdde41207c03f2c622f7831a.zip |
UAVCAN: Printing all known sensor bridge names with usage info
-rw-r--r-- | src/modules/uavcan/sensors/sensor_bridge.cpp | 12 | ||||
-rw-r--r-- | src/modules/uavcan/sensors/sensor_bridge.hpp | 5 | ||||
-rw-r--r-- | src/modules/uavcan/uavcan_main.cpp | 3 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/modules/uavcan/sensors/sensor_bridge.cpp b/src/modules/uavcan/sensors/sensor_bridge.cpp index f826c8fd2..5752d5524 100644 --- a/src/modules/uavcan/sensors/sensor_bridge.cpp +++ b/src/modules/uavcan/sensors/sensor_bridge.cpp @@ -36,12 +36,17 @@ */ #include "sensor_bridge.hpp" +#include <systemlib/err.h> + #include "gnss.hpp" #include "mag.hpp" #include "baro.hpp" IUavcanSensorBridge* IUavcanSensorBridge::make(uavcan::INode &node, const char *bridge_name) { + /* + * TODO: make a linked list of known implementations at startup? + */ if (!std::strncmp(UavcanGnssBridge::NAME, bridge_name, MAX_NAME_LEN)) { return new UavcanGnssBridge(node); } else if (!std::strncmp(UavcanMagnetometerBridge::NAME, bridge_name, MAX_NAME_LEN)) { @@ -52,3 +57,10 @@ IUavcanSensorBridge* IUavcanSensorBridge::make(uavcan::INode &node, const char * return nullptr; } } + +void IUavcanSensorBridge::print_known_names(const char *prefix) +{ + printf("%s%s\n", prefix, UavcanGnssBridge::NAME); + printf("%s%s\n", prefix, UavcanMagnetometerBridge::NAME); + printf("%s%s\n", prefix, UavcanBarometerBridge::NAME); +} diff --git a/src/modules/uavcan/sensors/sensor_bridge.hpp b/src/modules/uavcan/sensors/sensor_bridge.hpp index 7bd811813..976d9a03d 100644 --- a/src/modules/uavcan/sensors/sensor_bridge.hpp +++ b/src/modules/uavcan/sensors/sensor_bridge.hpp @@ -67,4 +67,9 @@ public: * @return nullptr if such bridge can't be created. */ static IUavcanSensorBridge* make(uavcan::INode &node, const char *bridge_name); + + /** + * Prints all valid bridge names into stdout via printf(), one name per line with prefix. + */ + static void print_known_names(const char *prefix); }; diff --git a/src/modules/uavcan/uavcan_main.cpp b/src/modules/uavcan/uavcan_main.cpp index aca4587ff..8607af145 100644 --- a/src/modules/uavcan/uavcan_main.cpp +++ b/src/modules/uavcan/uavcan_main.cpp @@ -590,6 +590,9 @@ static void print_usage() "\tuavcan start <node_id> [can_bitrate]\n" "\tuavcan sensor enable <sensor name>\n" "\tuavcan sensor list"); + + warnx("known sensor bridges:"); + IUavcanSensorBridge::print_known_names("\t"); } extern "C" __EXPORT int uavcan_main(int argc, char *argv[]); |