FreeCalypso > hg > freecalypso-tools
comparison rvinterf/lowlevel/format_fc.c @ 0:e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Jun 2016 00:13:35 +0000 |
parents | |
children | 4e243402f453 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e7502631a0f9 |
---|---|
1 /* | |
2 * This module has been split off from format.c; it implements the decoding | |
3 * of those Rx packet types which have been invented in FreeCalypso. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "../include/pktmux.h" | |
11 #include "../include/limits.h" | |
12 | |
13 extern u_char rxpkt[]; | |
14 extern size_t rxpkt_len; | |
15 | |
16 static char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */ | |
17 | |
18 void | |
19 print_ati_output() | |
20 { | |
21 int i, c; | |
22 char *dp; | |
23 | |
24 dp = fmtbuf; | |
25 strcpy(dp, "ATI: "); | |
26 dp += 5; | |
27 for (i = 1; i < rxpkt_len; i++) { | |
28 c = rxpkt[i]; | |
29 if (c & 0x80) { | |
30 *dp++ = 'M'; | |
31 *dp++ = '-'; | |
32 c &= 0x7F; | |
33 } | |
34 if (c < 0x20) { | |
35 *dp++ = '^'; | |
36 *dp++ = c + '@'; | |
37 } else if (c == 0x7F) { | |
38 *dp++ = '^'; | |
39 *dp++ = '?'; | |
40 } else | |
41 *dp++ = c; | |
42 } | |
43 *dp = '\0'; | |
44 output_line(fmtbuf); | |
45 } | |
46 | |
47 void | |
48 print_fc_lld_msg() | |
49 { | |
50 int i, c; | |
51 char *dp; | |
52 | |
53 dp = fmtbuf; | |
54 strcpy(dp, "LLD: "); | |
55 dp += 5; | |
56 for (i = 1; i < rxpkt_len; i++) { | |
57 c = rxpkt[i]; | |
58 if (c & 0x80) { | |
59 *dp++ = 'M'; | |
60 *dp++ = '-'; | |
61 c &= 0x7F; | |
62 } | |
63 if (c < 0x20) { | |
64 *dp++ = '^'; | |
65 *dp++ = c + '@'; | |
66 } else if (c == 0x7F) { | |
67 *dp++ = '^'; | |
68 *dp++ = '?'; | |
69 } else | |
70 *dp++ = c; | |
71 } | |
72 *dp = '\0'; | |
73 output_line(fmtbuf); | |
74 } | |
75 | |
76 void | |
77 print_tch_output_raw() | |
78 { | |
79 int i; | |
80 char *dp; | |
81 | |
82 dp = fmtbuf; | |
83 strcpy(dp, "TCH:"); | |
84 dp += 4; | |
85 for (i = 1; i < rxpkt_len; i++) { | |
86 sprintf(dp, " %02X", rxpkt[i]); | |
87 dp += 3; | |
88 } | |
89 *dp = '\0'; | |
90 output_line(fmtbuf); | |
91 } | |
92 | |
93 void | |
94 report_extui_packet() | |
95 { | |
96 sprintf(fmtbuf, "LCD OUT: row %u col %u-%u", rxpkt[1], rxpkt[2], | |
97 rxpkt[2] + (rxpkt_len - 3) / 2 - 1); | |
98 output_line(fmtbuf); | |
99 } |