aboutsummaryrefslogtreecommitdiff
path: root/apps/px4io/sbus.c
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-11-30 00:02:47 -0800
committerpx4dev <px4@purgatory.org>2012-11-30 00:02:47 -0800
commit9fa794a8faa2d30023d9943beae55a05ed4e48a0 (patch)
treecc05d6eafae584fb6c5cdfc731ece7f8be5f8f82 /apps/px4io/sbus.c
parente153476950a3fbda230c6bddd9ad35018cfda559 (diff)
downloadpx4-firmware-9fa794a8faa2d30023d9943beae55a05ed4e48a0.tar.gz
px4-firmware-9fa794a8faa2d30023d9943beae55a05ed4e48a0.tar.bz2
px4-firmware-9fa794a8faa2d30023d9943beae55a05ed4e48a0.zip
Rework the PX4IO software architecture:
- Use a separate thread for handing R/C inputs and outputs. - Remove all PX4IO R/C receiver configuration; it's all automatic now. - Rework the main loop, dedicate it to PX4FMU communications after startup. - Fix several issues in the px4io driver that would cause a crash if PX4IO was not responding.
Diffstat (limited to 'apps/px4io/sbus.c')
-rw-r--r--apps/px4io/sbus.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/apps/px4io/sbus.c b/apps/px4io/sbus.c
index e363a0a78..a91e37b5c 100644
--- a/apps/px4io/sbus.c
+++ b/apps/px4io/sbus.c
@@ -41,18 +41,39 @@
#include <fcntl.h>
#include <unistd.h>
+#include <termios.h>
#include <drivers/drv_hrt.h>
+#define DEBUG
#include "px4io.h"
-#include "protocol.h"
-void
-sbus_init(unsigned mode)
+static int sbus_fd = -1;
+
+int
+sbus_init(const char *device)
{
+ if (sbus_fd < 0)
+ sbus_fd = open(device, O_RDONLY);
+
+ if (sbus_fd >= 0) {
+ struct termios t;
+
+ /* 100000bps, even parity, two stop bits */
+ tcgetattr(sbus_fd, &t);
+ cfsetspeed(&t, 100000);
+ t.c_cflag |= (CSTOPB | PARENB);
+ tcsetattr(sbus_fd, TCSANOW, &t);
+
+ debug("Sbus: ready");
+ } else {
+ debug("Sbus: open failed");
+ }
+
+ return sbus_fd;
}
void
-sbus_input(int fd)
+sbus_input(void)
{
}