aboutsummaryrefslogtreecommitdiff
path: root/src/modules/commander/state_machine_helper.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-03-16 19:16:18 +0100
committerLorenz Meier <lm@inf.ethz.ch>2014-03-16 19:16:18 +0100
commit2fe9f65c45ba3aaad549b30e3b34568d07ab2b20 (patch)
treebde33367cb8ba506a9fc3e684ab8de5595d64071 /src/modules/commander/state_machine_helper.cpp
parent6db2191a71ed0ea38e1fd18886371f099c14d593 (diff)
downloadpx4-firmware-2fe9f65c45ba3aaad549b30e3b34568d07ab2b20.tar.gz
px4-firmware-2fe9f65c45ba3aaad549b30e3b34568d07ab2b20.tar.bz2
px4-firmware-2fe9f65c45ba3aaad549b30e3b34568d07ab2b20.zip
commander: Fixed compile error and some stupidity in usage of path names
Diffstat (limited to 'src/modules/commander/state_machine_helper.cpp')
-rw-r--r--src/modules/commander/state_machine_helper.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/modules/commander/state_machine_helper.cpp b/src/modules/commander/state_machine_helper.cpp
index 9178bcc5a..e6f245cf9 100644
--- a/src/modules/commander/state_machine_helper.cpp
+++ b/src/modules/commander/state_machine_helper.cpp
@@ -44,6 +44,7 @@
#include <stdbool.h>
#include <dirent.h>
#include <fcntl.h>
+#include <string.h>
#include <uORB/uORB.h>
#include <uORB/topics/vehicle_status.h>
@@ -341,37 +342,52 @@ int hil_state_transition(hil_state_t new_state, int status_pub, struct vehicle_s
if (d) {
struct dirent *direntry;
+ char devname[24];
while ((direntry = readdir(d)) != NULL) {
- int sensfd = ::open(direntry->d_name, 0);
-
- if (sensfd < 0) {
- warn("failed opening device");
- return 1;
- }
-
/* skip serial ports */
- if (!strncmp("tty", direntry-d_name, 3)) {
+ if (!strncmp("tty", direntry->d_name, 3)) {
continue;
}
/* skip mtd devices */
- if (!strncmp("mtd", direntry-d_name, 3)) {
+ if (!strncmp("mtd", direntry->d_name, 3)) {
continue;
}
/* skip ram devices */
- if (!strncmp("ram", direntry-d_name, 3)) {
+ if (!strncmp("ram", direntry->d_name, 3)) {
+ continue;
+ }
+ /* skip MMC devices */
+ if (!strncmp("mmc", direntry->d_name, 3)) {
continue;
}
/* skip mavlink */
- if (!strcmp("mavlink", direntry-d_name)) {
+ if (!strcmp("mavlink", direntry->d_name)) {
+ continue;
+ }
+ /* skip console */
+ if (!strcmp("console", direntry->d_name)) {
+ continue;
+ }
+ /* skip null */
+ if (!strcmp("null", direntry->d_name)) {
+ continue;
+ }
+
+ snprintf(devname, sizeof(devname), "/dev/%s", direntry->d_name);
+
+ int sensfd = ::open(devname, 0);
+
+ if (sensfd < 0) {
+ warn("failed opening device %s", devname);
continue;
}
int block_ret = ::ioctl(sensfd, DEVIOCSPUBBLOCK, 1);
close(sensfd);
- printf("Disabling %s: %s\n", direntry->d_name, (block_ret == OK) ? "OK" : "ERROR");
+ printf("Disabling %s: %s\n", devname, (block_ret == OK) ? "OK" : "ERROR");
}
closedir(d);