annotate cmu200/dispatch.c @ 8:c873a36a16e6

fc-cmu200d: freq-meas implemented without response parsing
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 May 2017 18:20:55 +0000
parents 948031e6de50
children 2fb9768fc1e2
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 code that dispatches client commands.
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>
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
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 extern char *client_cmd_fields[];
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 extern int client_cmd_nfields;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
8
c873a36a16e6 fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
13 extern int cmd_freq_meas();
6
d8cbc7a383eb fc-cmu200d: signal-gen-off implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
14 extern int cmd_signal_gen_off();
5
493987a4527e fc-cmu200d: signal-gen-sine implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
15 extern int cmd_signal_gen_sine();
4
504d3cbb95b5 fc-cmu200d: signal-gen-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
16 extern int cmd_signal_gen_setup();
7
948031e6de50 fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 6
diff changeset
17 extern int cmd_vcxo_cal_setup();
4
504d3cbb95b5 fc-cmu200d: signal-gen-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
18
0
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 cmd_ping()
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 send_socket_response("+Pong\n");
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return(0);
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 static struct cmdtab {
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 char *cmd_kw;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 int (*handler)();
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 } cmdtab[] = {
8
c873a36a16e6 fc-cmu200d: freq-meas implemented without response parsing
Mychaela Falconia <falcon@freecalypso.org>
parents: 7
diff changeset
29 {"freq-meas", cmd_freq_meas},
0
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {"ping", cmd_ping},
6
d8cbc7a383eb fc-cmu200d: signal-gen-off implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 5
diff changeset
31 {"signal-gen-off", cmd_signal_gen_off},
5
493987a4527e fc-cmu200d: signal-gen-sine implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 4
diff changeset
32 {"signal-gen-sine", cmd_signal_gen_sine},
4
504d3cbb95b5 fc-cmu200d: signal-gen-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 0
diff changeset
33 {"signal-gen-setup", cmd_signal_gen_setup},
7
948031e6de50 fc-cmu200d: vcxo-cal-setup implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 6
diff changeset
34 {"vcxo-cal-setup", cmd_vcxo_cal_setup},
0
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {0, 0}
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 };
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 dispatch_client_command()
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 {
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 struct cmdtab *tp;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 for (tp = cmdtab; tp->cmd_kw; tp++)
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (!strcmp(client_cmd_fields[0], tp->cmd_kw))
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 break;
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (tp->handler)
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return tp->handler();
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 send_socket_response("-Unknown or unimplemented command\n");
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return(0);
bd62be88259d initial import of rfcal code and docs from freecalypso-tools repository
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }