annotate rfcal/cmu200/main.c @ 216:7e3e3a958e3f

doc/Host-tools-overview: updated and simplified
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 May 2017 12:48:38 +0000
parents db9ee7745cdd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
194
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-cmu200d.
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 int target_fd;
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 static char default_socket_pathname[] = "/tmp/fc_rftest_socket";
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char *bind_socket_pathname;
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 if (argc < 3 || argc > 4) {
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 fprintf(stderr,
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 "usage: %s serial-port baud [socket-pathname]\n",
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 argv[0]);
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 exit(1);
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 }
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 open_target_serial(argv[1], argv[2]);
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 set_serial_nonblock(0);
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 init_cmu200();
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (argc > 3)
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 bind_socket_pathname = argv[3];
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 else
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 bind_socket_pathname = default_socket_pathname;
195
db9ee7745cdd fc-cmu200d: socket handling skeleton added
Mychaela Falconia <falcon@freecalypso.org>
parents: 194
diff changeset
30 create_listener_socket();
db9ee7745cdd fc-cmu200d: socket handling skeleton added
Mychaela Falconia <falcon@freecalypso.org>
parents: 194
diff changeset
31 for (;;) {
db9ee7745cdd fc-cmu200d: socket handling skeleton added
Mychaela Falconia <falcon@freecalypso.org>
parents: 194
diff changeset
32 get_socket_connection();
db9ee7745cdd fc-cmu200d: socket handling skeleton added
Mychaela Falconia <falcon@freecalypso.org>
parents: 194
diff changeset
33 handle_session();
db9ee7745cdd fc-cmu200d: socket handling skeleton added
Mychaela Falconia <falcon@freecalypso.org>
parents: 194
diff changeset
34 }
194
31d43f0e469a fc-cmu200d skeleton started, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }