diff options
author | Anton Babushkin <anton.babushkin@me.com> | 2013-09-27 18:29:16 +0200 |
---|---|---|
committer | Anton Babushkin <anton.babushkin@me.com> | 2013-09-27 18:29:16 +0200 |
commit | 45a95ab5e7110c4169d89fbdce61b91a36a05a8c (patch) | |
tree | 7ae52e18d0b5fdb223ebe95ae37cb9a2b3309c84 /src/drivers/px4fmu/fmu.cpp | |
parent | 4124417934932907d4663d23e44ab2f436064b58 (diff) | |
parent | 642081ddfe5857720c7b1df10743a627686b0ac3 (diff) | |
download | px4-firmware-45a95ab5e7110c4169d89fbdce61b91a36a05a8c.tar.gz px4-firmware-45a95ab5e7110c4169d89fbdce61b91a36a05a8c.tar.bz2 px4-firmware-45a95ab5e7110c4169d89fbdce61b91a36a05a8c.zip |
Merge branch 'master' into inav_fix
Diffstat (limited to 'src/drivers/px4fmu/fmu.cpp')
-rw-r--r-- | src/drivers/px4fmu/fmu.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 6d4019f24..b1dd55dd7 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -1096,10 +1096,11 @@ fmu_start(void) void test(void) { - int fd; + int fd; unsigned servo_count = 0; unsigned pwm_value = 1000; int direction = 1; + int ret; fd = open(PX4FMU_DEVICE_PATH, O_RDWR); @@ -1114,9 +1115,9 @@ test(void) warnx("Testing %u servos", (unsigned)servo_count); - int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY); - if (!console) - err(1, "failed opening console"); + struct pollfd fds; + fds.fd = 0; /* stdin */ + fds.events = POLLIN; warnx("Press CTRL-C or 'c' to abort."); @@ -1166,15 +1167,17 @@ test(void) /* Check if user wants to quit */ char c; - if (read(console, &c, 1) == 1) { - if (c == 0x03 || c == 0x63) { + ret = poll(&fds, 1, 0); + if (ret > 0) { + + read(0, &c, 1); + if (c == 0x03 || c == 0x63 || c == 'q') { warnx("User abort\n"); break; } } } - close(console); close(fd); exit(0); |