forked from Archive/PX4-Autopilot
UAVCAN: Printing all known sensor bridge names with usage info
This commit is contained in:
parent
6870cd4d3d
commit
7132141cc4
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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[]);
|
||||
|
|
Loading…
Reference in New Issue