summaryrefslogtreecommitdiff
path: root/util/term.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-09-23 20:20:38 +0200
committerUros Majstorovic <majstor@majstor.org>2022-09-23 20:20:38 +0200
commitf30abc1f75f483ffe78d92d5109b6c1d700925a3 (patch)
treeede5f6a35200f5bfe95d4fdea5cb41ac66e6a0fc /util/term.c
parent522a419a4139db2023e97e1a9ff2774011f069c9 (diff)
added x230x programming and switching utility; fe310 flash utility;
Diffstat (limited to 'util/term.c')
-rw-r--r--util/term.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/util/term.c b/util/term.c
new file mode 100644
index 0000000..a9861d5
--- /dev/null
+++ b/util/term.c
@@ -0,0 +1,40 @@
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <fcntl.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "tty.h"
+
+void usage(char *p) {
+ fprintf(stderr, "Usage: %s <tty>\n", p);
+ exit(1);
+}
+
+int main(int argc, char *argv[]) {
+ int tty_fd;
+
+ if (argc != 2) {
+ usage(argv[0]);
+ }
+
+ tty_fd = tty_open(argv[1]);
+ if (tty_fd < 0) {
+ fprintf(stderr, "ERROR %i: %s\n", errno, strerror(errno));
+ return 1;
+ }
+
+ while (1) {
+ char buf[256];
+ int rv;
+
+ rv = read(tty_fd, buf, sizeof(buf));
+ if (rv < 0) continue;
+
+ write(STDOUT_FILENO, buf, rv);
+ fflush(stdout);
+ }
+}