summaryrefslogtreecommitdiffstats
path: root/serial_keypad.c
diff options
context:
space:
mode:
authorroot <root@nolonger-other.tetra.james.local>2020-10-26 22:55:18 +0000
committerfishsoupisgood <github@madingley.org>2020-10-26 23:04:50 +0000
commitb11ae5cf86000bfce35b6ec511014d8f6b04416e (patch)
treed4f4caf8ecb8b14e62858d46d781af6886eb1b73 /serial_keypad.c
parent62bc1af6c6a1201db551e1ec523e757415464fd5 (diff)
downloadgalaxy_tools-b11ae5cf86000bfce35b6ec511014d8f6b04416e.tar.gz
galaxy_tools-b11ae5cf86000bfce35b6ec511014d8f6b04416e.tar.bz2
galaxy_tools-b11ae5cf86000bfce35b6ec511014d8f6b04416e.zip
add keypad
Diffstat (limited to 'serial_keypad.c')
-rw-r--r--serial_keypad.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/serial_keypad.c b/serial_keypad.c
new file mode 100644
index 0000000..91939e6
--- /dev/null
+++ b/serial_keypad.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <termios.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "util.h"
+#include "keypad.h"
+
+
+
+
+static int usage (const char *name)
+{
+ fprintf (stderr, "Usage:\n");
+ fprintf (stderr, "%s -p device [ -b baud ]\n", name);
+ fprintf (stderr, "\n");
+
+ return -1;
+}
+
+
+int main (int argc, char *argv[])
+{
+ unsigned opt;
+ const char *port = NULL;
+ unsigned baud = 9600;
+ int fd;
+
+ while ((opt = getopt (argc, argv, "h:p:z:USPRBFTAD")) != -1) {
+ switch (opt) {
+ case 'p':
+ port = optarg;
+ break;
+
+ case 'b':
+ baud = atoi (optarg);
+ break;
+
+ default: /* '?' */
+ return usage (argv[0]);
+ }
+ }
+
+ if (!port) return (usage (argv[0]));
+
+ fd = open_tty (port, baud);
+
+ set_blocking (fd);
+
+
+ if (fd < 0) {
+ perror ("open tcp port");
+ return -1;
+ }
+
+
+ return gd_keypad (fd);
+}
+
+