annotate rvinterf/lowlevel/format_fc.c @ 1030:194967e11b2b

fc-shell: tch record and tch play reworked for libgsm-compatible file format
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 31 May 2016 18:39:06 +0000
parents 658fe6f1880f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
1009
009d5bf2ff4c rvinterf/lowlevel: formatting of FC-specific packet types split off
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 975
diff changeset
2 * This module has been split off from format.c; it implements the decoding
009d5bf2ff4c rvinterf/lowlevel: formatting of FC-specific packet types split off
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 975
diff changeset
3 * of those Rx packet types which have been invented in FreeCalypso.
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
4 */
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
5
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <sys/types.h>
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdio.h>
133
56b53c289785 rvtdump: some restructuring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 127
diff changeset
8 #include <string.h>
56b53c289785 rvtdump: some restructuring
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 127
diff changeset
9 #include <strings.h>
256
2f285f20d617 rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 175
diff changeset
10 #include "../include/pktmux.h"
2f285f20d617 rvinterf: *.h moved into include subdir
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 175
diff changeset
11 #include "../include/limits.h"
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
12
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
13 extern u_char rxpkt[];
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
14 extern size_t rxpkt_len;
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
15
333
2ac2f6d88bb2 rvinterf & rvtdump: use the new libg23 for G23 packet decoding
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 327
diff changeset
16 static char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */
327
05874f1ddacb rvinterf & rvtdump: new decoding of G23/GPF packets
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents: 256
diff changeset
17
126
811b138f1bed rvtdump utility written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff changeset
18 void
880
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
19 print_ati_output()
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
20 {
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
21 int i, c;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
22 char *dp;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
23
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
24 dp = fmtbuf;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
25 strcpy(dp, "ATI: ");
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
26 dp += 5;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
27 for (i = 1; i < rxpkt_len; i++) {
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
28 c = rxpkt[i];
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
29 if (c & 0x80) {
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
30 *dp++ = 'M';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
31 *dp++ = '-';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
32 c &= 0x7F;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
33 }
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
34 if (c < 0x20) {
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
35 *dp++ = '^';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
36 *dp++ = c + '@';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
37 } else if (c == 0x7F) {
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
38 *dp++ = '^';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
39 *dp++ = '?';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
40 } else
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
41 *dp++ = c;
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
42 }
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
43 *dp = '\0';
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
44 output_line(fmtbuf);
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
45 }
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
46
136fa1ccd591 rvtdump & rvinterf: print and log ATI responses in ASCII
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 856
diff changeset
47 void
856
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
48 print_fc_lld_msg()
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
49 {
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
50 int i, c;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
51 char *dp;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
52
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
53 dp = fmtbuf;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
54 strcpy(dp, "LLD: ");
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
55 dp += 5;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
56 for (i = 1; i < rxpkt_len; i++) {
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
57 c = rxpkt[i];
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
58 if (c & 0x80) {
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
59 *dp++ = 'M';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
60 *dp++ = '-';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
61 c &= 0x7F;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
62 }
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
63 if (c < 0x20) {
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
64 *dp++ = '^';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
65 *dp++ = c + '@';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
66 } else if (c == 0x7F) {
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
67 *dp++ = '^';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
68 *dp++ = '?';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
69 } else
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
70 *dp++ = c;
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
71 }
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
72 *dp = '\0';
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
73 output_line(fmtbuf);
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
74 }
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
75
d527ac304ad5 rvinterf & rvtdump: handle low level debug messages from FC firmwares
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 333
diff changeset
76 void
1010
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
77 print_tch_output_raw()
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
78 {
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
79 int i;
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
80 char *dp;
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
81
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
82 dp = fmtbuf;
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
83 strcpy(dp, "TCH:");
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
84 dp += 4;
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
85 for (i = 1; i < rxpkt_len; i++) {
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
86 sprintf(dp, " %02X", rxpkt[i]);
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
87 dp += 3;
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
88 }
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
89 *dp = '\0';
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
90 output_line(fmtbuf);
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
91 }
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
92
658fe6f1880f rvinterf/lowlevel: handle TCH packet type in rvinterf and rvtdump
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 1009
diff changeset
93 void
902
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
94 report_extui_packet()
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
95 {
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
96 sprintf(fmtbuf, "LCD OUT: row %u col %u-%u", rxpkt[1], rxpkt[2],
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
97 rxpkt[2] + (rxpkt_len - 3) / 2 - 1);
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
98 output_line(fmtbuf);
4423039aeb4b rvtdump: report ext LCD output packets sanely
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 880
diff changeset
99 }