Linux: added builtins to show devices and topics

list_devices will list virtual devices starting with "/dev/".
list_topics will list topics ("/obj/")

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois
2015-04-20 11:37:50 -07:00
parent 694427e4ba
commit d2f0572ce6
7 changed files with 43 additions and 746 deletions
+21 -2
View File
@@ -461,16 +461,35 @@ void VDev::showDevices()
int i=0;
printf("Devices:\n");
for (; i<PX4_MAX_DEV; ++i) {
if (devmap[i]) {
if (devmap[i] && strncmp(devmap[i]->name, "/dev/", 5) == 0) {
printf(" %s\n", devmap[i]->name);
}
}
}
void VDev::showTopics()
{
int i=0;
printf("Devices:\n");
for (; i<PX4_MAX_DEV; ++i) {
if (devmap[i] && strncmp(devmap[i]->name, "/obj/", 5) == 0) {
printf(" %s\n", devmap[i]->name);
}
}
}
const char *VDev::topicList(unsigned int *next)
{
for (;*next<PX4_MAX_DEV; (*next)++)
if (devmap[*next] && strncmp(devmap[(*next)]->name, "/obj/", 5) == 0)
return devmap[(*next)++]->name;
return NULL;
}
const char *VDev::devList(unsigned int *next)
{
for (;*next<PX4_MAX_DEV; (*next)++)
if (devmap[*next])
if (devmap[*next] && strncmp(devmap[(*next)]->name, "/dev/", 5) == 0)
return devmap[(*next)++]->name;
return NULL;
}
+2
View File
@@ -334,7 +334,9 @@ public:
static VDev *getDev(const char *path);
static void showDevices(void);
static void showTopics(void);
static const char *devList(unsigned int *next);
static const char *topicList(unsigned int *next);
protected:
+10
View File
@@ -274,10 +274,20 @@ void px4_show_devices()
VDev::showDevices();
}
void px4_show_topics()
{
VDev::showTopics();
}
const char * px4_get_device_names(unsigned int *handle)
{
return VDev::devList(handle);
}
const char * px4_get_topic_names(unsigned int *handle)
{
return VDev::topicList(handle);
}
}