annotate rvinterf/lowlevel/logsent.c @ 991:5cff3579814c

target-utils: libbase factored out of libcommon The library dependency order is now strictly unidirectional
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Wed, 30 Dec 2015 20:48:12 +0000
parents da9a36515da6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
2 * This module implements the logging of sent packets
134
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
3 */
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <string.h>
e0d56e9be8a2 rvtdump: time-stamped logging implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
8 #include <strings.h>
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
9 #include "../include/pktmux.h"
256
2f285f20d617 rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 174
diff changeset
10 #include "../include/limits.h"
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
11
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
12 static void
881
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
13 log_sent_ati(pkt, pktlen)
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
14 u_char *pkt;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
15 {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
16 char buf[MAX_PKT_TO_TARGET*4+10];
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
17 int i, c;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
18 char *dp;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
19
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
20 strcpy(buf, "Sent to ATI: ");
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
21 dp = buf + 13;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
22 for (i = 1; i < pktlen; i++) {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
23 c = pkt[i];
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
24 if (c & 0x80) {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
25 *dp++ = 'M';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
26 *dp++ = '-';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
27 c &= 0x7F;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
28 }
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
29 if (c < 0x20) {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
30 *dp++ = '^';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
31 *dp++ = c + '@';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
32 } else if (c == 0x7F) {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
33 *dp++ = '^';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
34 *dp++ = '?';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
35 } else
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
36 *dp++ = c;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
37 }
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
38 *dp = '\0';
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
39 output_line(buf);
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
40 }
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
41
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
42 static void
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
43 log_sent_gpf(pkt, pktlen)
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
44 u_char *pkt;
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
45 {
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
46 char buf[MAX_PKT_TO_TARGET*4+30];
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
47
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
48 strcpy(buf, "Sent ");
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
49 format_g23_packet(pkt, pktlen, buf + 5);
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
50 output_line(buf);
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
51 }
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
52
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
53 static void
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
54 log_sent_other(pkt, pktlen)
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
55 u_char *pkt;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
56 {
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
57 char buf[MAX_PKT_TO_TARGET*3+5];
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
58 int i;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
59 char *dp;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
60
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
61 dp = buf;
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
62 strcpy(dp, "Sent");
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
63 dp += 4;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
64 for (i = 0; i < pktlen; i++) {
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
65 sprintf(dp, " %02X", pkt[i]);
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
66 dp += 3;
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
67 }
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
68 *dp = '\0';
174
3256dc6e84ae rvinterf: refactored rvtdump compiles and works
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 173
diff changeset
69 output_line(buf);
171
4d8e4c58df71 rvtdump: implemented Tx extension hack, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 134
diff changeset
70 }
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
71
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
72 log_sent_packet(pkt, pktlen)
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
73 u_char *pkt;
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
74 {
881
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
75 switch (pkt[0]) {
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
76 case RVT_L23_HEADER:
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
77 log_sent_gpf(pkt, pktlen);
881
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
78 return;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
79 case RVT_AT_HEADER:
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
80 log_sent_ati(pkt, pktlen);
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
81 return;
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
82 default:
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
83 log_sent_other(pkt, pktlen);
881
da9a36515da6 rvinterf: log sent AT commands in ASCII form
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 628
diff changeset
84 }
628
c2f2f7d78451 rvinterf: log sent GPF packets with the same decoding as received ones
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
85 }