diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2014-03-08 22:19:18 +0400 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2014-03-08 22:19:18 +0400 |
commit | b165e6ba2000f89b1220393e469911f3e3a73286 (patch) | |
tree | d01b603f884389aef6975a5e6532b9c1524bcc74 /src/modules/commander/state_machine_helper.cpp | |
parent | e0fbb0fb6079cffe1e3ab254caa4fd07906e9f7d (diff) | |
parent | 501dc0cfa7259a1916522e5b70a5fd31cb7d20e1 (diff) | |
download | px4-firmware-b165e6ba2000f89b1220393e469911f3e3a73286.tar.gz px4-firmware-b165e6ba2000f89b1220393e469911f3e3a73286.tar.bz2 px4-firmware-b165e6ba2000f89b1220393e469911f3e3a73286.zip |
Merge branch 'master' into acro2
Diffstat (limited to 'src/modules/commander/state_machine_helper.cpp')
-rw-r--r-- | src/modules/commander/state_machine_helper.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/modules/commander/state_machine_helper.cpp b/src/modules/commander/state_machine_helper.cpp index 2516d4c68..d5ecd9647 100644 --- a/src/modules/commander/state_machine_helper.cpp +++ b/src/modules/commander/state_machine_helper.cpp @@ -42,6 +42,8 @@ #include <unistd.h> #include <stdint.h> #include <stdbool.h> +#include <dirent.h> +#include <fcntl.h> #include <uORB/uORB.h> #include <uORB/topics/vehicle_status.h> @@ -50,6 +52,7 @@ #include <systemlib/param/param.h> #include <systemlib/err.h> #include <drivers/drv_hrt.h> +#include <drivers/drv_device.h> #include <mavlink/mavlink_log.h> #include "state_machine_helper.h" @@ -336,6 +339,33 @@ int hil_state_transition(hil_state_t new_state, int status_pub, struct vehicle_s mavlink_log_critical(mavlink_fd, "Switched to ON hil state"); valid_transition = true; + + // Disable publication of all attached sensors + + /* list directory */ + DIR *d; + struct dirent *direntry; + d = opendir("/dev"); + if (d) { + + while ((direntry = readdir(d)) != NULL) { + + int sensfd = ::open(direntry->d_name, 0); + int block_ret = ::ioctl(sensfd, DEVIOCSPUBBLOCK, 0); + close(sensfd); + + printf("Disabling %s\n: %s", direntry->d_name, (!block_ret) ? "OK" : "FAIL"); + } + + closedir(d); + + warnx("directory listing ok (FS mounted and readable)"); + + } else { + /* failed opening dir */ + warnx("FAILED LISTING DEVICE ROOT DIRECTORY"); + return 1; + } } break; |