FreeCalypso > hg > fc-sim-sniff
annotate sw/sniff-rx/main.c @ 35:695ca51e1564
doc/Sniffer-FPGA-design: update for finished work
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 30 Aug 2023 01:09:00 +0000 |
parents | b112c2df6c43 |
children |
rev | line source |
---|---|
22
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Main module for simtrace3-sniff-rx program. |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 FILE *main_outf; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 int logfile_flag; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 main(argc, argv) |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char **argv; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 if (argc < 2 || argc > 3) { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 fprintf(stderr, "usage: %s ttyport [logfile]\n", argv[0]); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 exit(1); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 } |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 open_serial_port(argv[1]); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 set_serial_baudrate(3000000); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 init_serial_flush(); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (argv[2]) { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 main_outf = fopen(argv[2], "a"); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (!main_outf) { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 perror(argv[2]); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 exit(1); |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 logfile_flag = 1; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } else { |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 main_outf = stdout; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 logfile_flag = 0; |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 main_loop(); /* does not return */ |
b112c2df6c43
sw: simtrace3-sniff-rx program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |