FreeCalypso > hg > fc-rfcal-tools
annotate cmu200/main.c @ 68:3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 Jul 2017 04:34:15 +0000 |
parents | 498b90f6e224 |
children | 348c29b7d02a |
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 |
68
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
22 while ((c = getopt(argc, argv, "12ac:t:")) != EOF) |
37
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; |
68
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
27 case '2': |
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
28 cmu200_rf_port = 2; |
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
29 continue; |
37
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
30 case 'a': |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
31 cmu200_tx_name = "AUXT"; |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
32 continue; |
68
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
33 case 'c': |
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
34 read_cable_conf_file(optarg); |
3ec82dc1dbda
fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
37
diff
changeset
|
35 continue; |
37
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
36 case 't': |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
37 bind_socket_pathname = optarg; |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
38 continue; |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
39 default: |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
40 usage: fprintf(stderr, |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
41 "usage: %s [options] serial-port baud\n", |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
42 argv[0]); |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
43 exit(1); |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
44 } |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
45 if (argc - optind != 2) |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
46 goto usage; |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
47 |
498b90f6e224
fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents:
9
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 init_cmu200(); |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 create_listener_socket(); |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (;;) { |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 get_socket_connection(); |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 handle_session(); |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
bd62be88259d
initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |