FreeCalypso > hg > fc-rfcal-tools
annotate cmu200/main.c @ 46:751f8d9efed0
Rx cal: started the single measurement code
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sat, 27 May 2017 06:25:59 +0000 |
| parents | 498b90f6e224 |
| children | 3ec82dc1dbda |
| rev | line source |
|---|---|
|
0
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the main() function for fc-cmu200d. |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
|
37
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
7 #include <unistd.h> |
|
0
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 int target_fd; |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
|
37
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
11 char *bind_socket_pathname = "/tmp/fc_rftest_socket"; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
12 char *cmu200_tx_name = "TX"; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
13 int cmu200_rf_port = 2; |
|
0
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 main(argc, argv) |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char **argv; |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
|
37
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
18 extern char *optarg; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
19 extern int optind; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
20 int c; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
21 |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
22 while ((c = getopt(argc, argv, "1at:")) != EOF) |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
23 switch (c) { |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
24 case '1': |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
25 cmu200_rf_port = 1; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
26 continue; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
27 case 'a': |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
28 cmu200_tx_name = "AUXT"; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
29 continue; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
30 case 't': |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
31 bind_socket_pathname = optarg; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
32 continue; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
33 default: |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
34 usage: fprintf(stderr, |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
35 "usage: %s [options] serial-port baud\n", |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
36 argv[0]); |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
37 exit(1); |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
38 } |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
39 if (argc - optind != 2) |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
40 goto usage; |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
41 |
|
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
42 open_target_serial(argv[optind], argv[optind+1]); |
|
0
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 set_serial_nonblock(0); |
|
9
6d7079a81e8b
fc-cmu200d: do setlinebuf(stdout) for easier logging with tee
Mychaela Falconia <falcon@freecalypso.org>
parents:
0
diff
changeset
|
44 setlinebuf(stdout); /* to allow logging with tee */ |
|
0
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 init_cmu200(); |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 create_listener_socket(); |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 for (;;) { |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 get_socket_connection(); |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 handle_session(); |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
|
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
