diff options
author | px4dev <px4@purgatory.org> | 2012-12-29 16:01:24 -0800 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-12-29 16:01:24 -0800 |
commit | d81edb09cf29dd36d50ce7a7bcf55631fecc470f (patch) | |
tree | 63cb30938794a69981782ff666b9e181c2b286da /apps/px4io/comms.c | |
parent | f9520ee39d0e14bc67cce809375fb69de9a7f977 (diff) | |
download | px4-firmware-d81edb09cf29dd36d50ce7a7bcf55631fecc470f.tar.gz px4-firmware-d81edb09cf29dd36d50ce7a7bcf55631fecc470f.tar.bz2 px4-firmware-d81edb09cf29dd36d50ce7a7bcf55631fecc470f.zip |
whitespace/formatting
Diffstat (limited to 'apps/px4io/comms.c')
-rw-r--r-- | apps/px4io/comms.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/px4io/comms.c b/apps/px4io/comms.c index bc2142a4b..b815eda3c 100644 --- a/apps/px4io/comms.c +++ b/apps/px4io/comms.c @@ -110,6 +110,7 @@ comms_main(void) if (fds.revents & POLLIN) { char buf[32]; ssize_t count = read(fmu_fd, buf, sizeof(buf)); + for (int i = 0; i < count; i++) hx_stream_rx(stream, buf[i]); } @@ -123,7 +124,8 @@ comms_main(void) /* should we send a report to the FMU? */ now = hrt_absolute_time(); delta = now - last_report_time; - if ((delta > FMU_MIN_REPORT_INTERVAL) && + + if ((delta > FMU_MIN_REPORT_INTERVAL) && (system_state.fmu_report_due || (delta > FMU_MAX_REPORT_INTERVAL))) { system_state.fmu_report_due = false; @@ -132,6 +134,7 @@ comms_main(void) /* populate the report */ for (unsigned i = 0; i < system_state.rc_channels; i++) report.rc_channel[i] = system_state.rc_channel_data[i]; + report.channel_count = system_state.rc_channels; report.armed = system_state.armed; @@ -172,7 +175,7 @@ comms_handle_command(const void *buffer, size_t length) system_state.fmu_channel_data[i] = cmd->servo_command[i]; /* if the IO is armed and the FMU gets disarmed, the IO must also disarm */ - if(system_state.arm_ok && !cmd->arm_ok) { + if (system_state.arm_ok && !cmd->arm_ok) { system_state.armed = false; } @@ -185,7 +188,7 @@ comms_handle_command(const void *buffer, size_t length) // if (!system_state.arm_ok && system_state.armed) // system_state.armed = false; - /* XXX do relay changes here */ + /* XXX do relay changes here */ for (unsigned i = 0; i < PX4IO_RELAY_CHANNELS; i++) system_state.relays[i] = cmd->relay_state[i]; @@ -204,14 +207,17 @@ comms_handle_frame(void *arg, const void *buffer, size_t length) case F2I_MAGIC: comms_handle_command(buffer, length); break; + case F2I_CONFIG_MAGIC: comms_handle_config(buffer, length); break; + case F2I_MIXER_MAGIC: mixer_handle_text(buffer, length); break; + default: - frame_bad++; + frame_bad++; break; } } |