aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/px4io/px4io.cpp
diff options
context:
space:
mode:
authorJean Cyr <jcyr@dillobits.com>2013-08-11 17:19:54 -0400
committerJean Cyr <jcyr@dillobits.com>2013-08-11 17:19:54 -0400
commit1d408b80ad70bd8ea873ce7215c8a92a62461b0f (patch)
tree2b1452cb6f71385b0c61de5630ef0f9db9c319c8 /src/drivers/px4io/px4io.cpp
parent36679fbb39a57139c03cce85d7d0fbd25383a98a (diff)
downloadpx4-firmware-1d408b80ad70bd8ea873ce7215c8a92a62461b0f.tar.gz
px4-firmware-1d408b80ad70bd8ea873ce7215c8a92a62461b0f.tar.bz2
px4-firmware-1d408b80ad70bd8ea873ce7215c8a92a62461b0f.zip
Support DSM bind via QGroundControl
Diffstat (limited to 'src/drivers/px4io/px4io.cpp')
-rw-r--r--src/drivers/px4io/px4io.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index 5089ce3c7..cb61d4aae 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -189,6 +189,12 @@ private:
bool _dsm_vcc_ctl;
/**
+ * System armed
+ */
+
+ bool _system_armed;
+
+ /**
* Trampoline to the worker task
*/
static void task_main_trampoline(int argc, char *argv[]);
@@ -355,7 +361,8 @@ PX4IO::PX4IO() :
_battery_amp_bias(0),
_battery_mamphour_total(0),
_battery_last_timestamp(0),
- _dsm_vcc_ctl(false)
+ _dsm_vcc_ctl(false),
+ _system_armed(false)
{
/* we need this potentially before it could be set in task_main */
g_dev = this;
@@ -672,6 +679,17 @@ PX4IO::task_main()
*/
if (fds[3].revents & POLLIN) {
parameter_update_s pupdate;
+ int32_t dsm_bind_param;
+
+ // See if bind parameter has been set, and reset it to 0
+ param_get(param_find("RC_DSM_BIND"), &dsm_bind_param);
+ if (dsm_bind_param) {
+ if (((dsm_bind_param == 1) || (dsm_bind_param == 2)) && !_system_armed) {
+ ioctl(nullptr, DSM_BIND_START, dsm_bind_param == 1 ? 3 : 7);
+ }
+ dsm_bind_param = 0;
+ param_set(param_find("RC_DSM_BIND"), &dsm_bind_param);
+ }
/* copy to reset the notification */
orb_copy(ORB_ID(parameter_update), _t_param, &pupdate);
@@ -737,6 +755,8 @@ PX4IO::io_set_arming_state()
uint16_t set = 0;
uint16_t clear = 0;
+ _system_armed = vstatus.flag_system_armed;
+
if (armed.armed && !armed.lockdown) {
set |= PX4IO_P_SETUP_ARMING_FMU_ARMED;
} else {
@@ -1448,6 +1468,8 @@ PX4IO::ioctl(file * /*filep*/, int cmd, unsigned long arg)
io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_power_up);
usleep(50000);
io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_send_pulses | (arg << 4));
+ usleep(50000);
+ io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_DSM, dsm_bind_reinit_uart);
break;
case DSM_BIND_STOP:
@@ -1695,30 +1717,12 @@ bind(int argc, char *argv[])
else
errx(1, "unknown parameter %s, use dsm2 or dsmx", argv[2]);
- /* Open console directly to grab CTRL-C signal */
- int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY);
- if (!console)
- errx(1, "failed opening console");
-
warnx("This command will only bind DSM if satellite VCC (red wire) is controlled by relay 1.");
- warnx("Press CTRL-C or 'c' when done.");
g_dev->ioctl(nullptr, DSM_BIND_START, pulses);
- for (;;) {
- usleep(500000L);
- /* Check if user wants to quit */
- char c;
- if (read(console, &c, 1) == 1) {
- if (c == 0x03 || c == 0x63) {
- warnx("Done\n");
- g_dev->ioctl(nullptr, DSM_BIND_STOP, 0);
- g_dev->ioctl(nullptr, DSM_BIND_POWER_UP, 0);
- close(console);
- exit(0);
- }
- }
- }
+ exit(0);
+
}
void