diff options
author | Uros Majstorovic <majstor@majstor.org> | 2022-09-23 20:20:38 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2022-09-23 20:20:38 +0200 |
commit | f30abc1f75f483ffe78d92d5109b6c1d700925a3 (patch) | |
tree | ede5f6a35200f5bfe95d4fdea5cb41ac66e6a0fc /util/term.c | |
parent | 522a419a4139db2023e97e1a9ff2774011f069c9 (diff) |
added x230x programming and switching utility; fe310 flash utility;
Diffstat (limited to 'util/term.c')
-rw-r--r-- | util/term.c | 40 |
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); + } +} |