annotate cmu200/main.c @ 104:7ad0495991ed

autocal: use the new ERROR_RFFAIL exit code
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Dec 2017 07:01:13 +0000
parents 348c29b7d02a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
86
348c29b7d02a fc-cmu200d: ignore SIGPIPE so we don't exit if a client terminates
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
8 #include <signal.h>
0
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 int target_fd;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
37
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
12 char *bind_socket_pathname = "/tmp/fc_rftest_socket";
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
13 char *cmu200_tx_name = "TX";
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
14 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
15
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 main(argc, argv)
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char **argv;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
37
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
19 extern char *optarg;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
20 extern int optind;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
21 int c;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
22
68
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents: 37
diff changeset
23 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
24 switch (c) {
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
25 case '1':
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
26 cmu200_rf_port = 1;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
27 continue;
68
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents: 37
diff changeset
28 case '2':
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents: 37
diff changeset
29 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
30 continue;
37
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
31 case 'a':
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
32 cmu200_tx_name = "AUXT";
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
33 continue;
68
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents: 37
diff changeset
34 case 'c':
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents: 37
diff changeset
35 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
36 continue;
37
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
37 case 't':
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
38 bind_socket_pathname = optarg;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
39 continue;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
40 default:
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
41 usage: fprintf(stderr,
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
42 "usage: %s [options] serial-port baud\n",
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
43 argv[0]);
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
44 exit(1);
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
45 }
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
46 if (argc - optind != 2)
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
47 goto usage;
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
48
498b90f6e224 fc-cmu200d: added command line options
Mychaela Falconia <falcon@freecalypso.org>
parents: 9
diff changeset
49 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
50 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
51 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
52 init_cmu200();
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 create_listener_socket();
86
348c29b7d02a fc-cmu200d: ignore SIGPIPE so we don't exit if a client terminates
Mychaela Falconia <falcon@freecalypso.org>
parents: 68
diff changeset
54 signal(SIGPIPE, SIG_IGN);
0
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 for (;;) {
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 get_socket_connection();
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 handle_session();
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }