mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 10:13:34 +08:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user