diff sw/sniff-rx/main.c @ 22:b112c2df6c43

sw: simtrace3-sniff-rx program written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 22 Aug 2023 06:16:44 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sw/sniff-rx/main.c	Tue Aug 22 06:16:44 2023 +0000
@@ -0,0 +1,33 @@
+/*
+ * Main module for simtrace3-sniff-rx program.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+FILE *main_outf;
+int logfile_flag;
+
+main(argc, argv)
+	char **argv;
+{
+	if (argc < 2 || argc > 3) {
+		fprintf(stderr, "usage: %s ttyport [logfile]\n", argv[0]);
+		exit(1);
+	}
+	open_serial_port(argv[1]);
+	set_serial_baudrate(3000000);
+	init_serial_flush();
+	if (argv[2]) {
+		main_outf = fopen(argv[2], "a");
+		if (!main_outf) {
+			perror(argv[2]);
+			exit(1);
+		}
+		logfile_flag = 1;
+	} else {
+		main_outf = stdout;
+		logfile_flag = 0;
+	}
+	main_loop();		/* does not return */
+}