aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/px4io/px4io.cpp
diff options
context:
space:
mode:
authorJean Cyr <jcyr@dillobits.com>2013-08-11 21:16:55 -0400
committerJean Cyr <jcyr@dillobits.com>2013-08-11 21:16:55 -0400
commit0b935550439a17856f5218fdcd6be8b864cfd346 (patch)
tree48ff3d8052a0094268a9b3c51bf17e233c44587e /src/drivers/px4io/px4io.cpp
parent35ec651cee89081ceaca63a1641541d8ed0a1467 (diff)
downloadpx4-firmware-0b935550439a17856f5218fdcd6be8b864cfd346.tar.gz
px4-firmware-0b935550439a17856f5218fdcd6be8b864cfd346.tar.bz2
px4-firmware-0b935550439a17856f5218fdcd6be8b864cfd346.zip
Tell mavlink about bind results
Diffstat (limited to 'src/drivers/px4io/px4io.cpp')
-rw-r--r--src/drivers/px4io/px4io.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp
index 10ab10ef3..960ac06ff 100644
--- a/src/drivers/px4io/px4io.cpp
+++ b/src/drivers/px4io/px4io.cpp
@@ -577,9 +577,11 @@ void
PX4IO::task_main()
{
hrt_abstime last_poll_time = 0;
+ int mavlink_fd = ::open(MAVLINK_LOG_DEVICE, 0);
log("starting");
+
/*
* Subscribe to the appropriate PWM output topic based on whether we are the
* primary PWM output or not.
@@ -679,16 +681,24 @@ PX4IO::task_main()
*/
if (fds[3].revents & POLLIN) {
parameter_update_s pupdate;
- int32_t dsm_bind_param;
+ int32_t dsm_bind_val;
+ param_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);
+ param_get(dsm_bind_param = param_find("RC_DSM_BIND"), &dsm_bind_val);
+ if (dsm_bind_val) {
+ if (!_system_armed) {
+ if ((dsm_bind_val == 1) || (dsm_bind_val == 2)) {
+ mavlink_log_info(mavlink_fd, "[IO] binding dsm%c rx", dsm_bind_val == 1 ? '2' : 'x');
+ ioctl(nullptr, DSM_BIND_START, dsm_bind_val == 1 ? 3 : 7);
+ } else {
+ mavlink_log_info(mavlink_fd, "[IO] invalid bind type, bind request rejected");
+ }
+ } else {
+ mavlink_log_info(mavlink_fd, "[IO] system armed, bind request rejected");
}
- dsm_bind_param = 0;
- param_set(param_find("RC_DSM_BIND"), &dsm_bind_param);
+ dsm_bind_val = 0;
+ param_set(dsm_bind_param, &dsm_bind_val);
}
/* copy to reset the notification */