annotate rvinterf/asyncshell/rxctl.c @ 902:4423039aeb4b

rvtdump: report ext LCD output packets sanely
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 06 Sep 2015 07:27:57 +0000
parents c9f353b5d70c
children 820d34f3f3d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
874
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * This module contains the code for enabling and disabling the receiving
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 * of various packet types via rvinterf.
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 */
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <ctype.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include <string.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 #include <strings.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 #include <stdlib.h>
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 #include "pktmux.h"
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 #include "localsock.h"
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 send_rxctl_cmd(channel, enable)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 u_char cmdbuf[2];
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 cmdbuf[0] = enable ? CLI2RVI_WANT_MUXPROTO : CLI2RVI_DROP_MUXPROTO;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 cmdbuf[1] = channel;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 send_init_command(cmdbuf, 2);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 ati_rx_control(newstate)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 static int state = 0;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 if (state == newstate)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 return;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 send_rxctl_cmd(RVT_AT_HEADER, newstate);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 state = newstate;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 gpf_rx_control(newstate)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 static int state = 0;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 if (state == newstate)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 return;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 send_rxctl_cmd(RVT_L23_HEADER, newstate);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 state = newstate;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 rxctl_user_cmd(args, enable)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 char *args;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 char *cp, *np;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 int gotsome = 0;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 for (cp = args; ; ) {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 while (isspace(*cp))
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 cp++;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 if (!*cp) {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 if (!gotsome)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 printf("error: argument required\n");
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 return;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 for (np = cp; *cp && !isspace(*cp); cp++)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 ;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 if (*cp)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 *cp++ = '\0';
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 if (!strcmp(np, "ati"))
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 ati_rx_control(enable);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 else if (!strcmp(np, "gpf"))
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 gpf_rx_control(enable);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 else {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 printf("error: unknown channel \"%s\"\n", np);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 return;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 }
876
c9f353b5d70c rvinterf/asyncshell/rxctl.c: buglet in the implementation of dis/enable commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 874
diff changeset
74 gotsome++;
874
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
78 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
79 cmd_enable(args)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 char *args;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 rxctl_user_cmd(args, 1);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
84
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
85 void
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
86 cmd_disable(args)
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
87 char *args;
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
88 {
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
89 rxctl_user_cmd(args, 0);
72d64c172d85 fc-shell: Rx control implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
90 }