FreeCalypso > hg > freecalypso-sw
comparison rvinterf/lowlevel/format_fc.c @ 1009:009d5bf2ff4c
rvinterf/lowlevel: formatting of FC-specific packet types split off
into format_fc.c
| author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Sun, 20 Mar 2016 20:23:54 +0000 |
| parents | rvinterf/lowlevel/format.c@0d7cc054ef72 |
| children | 658fe6f1880f |
comparison
equal
deleted
inserted
replaced
| 1008:5f919af515f1 | 1009:009d5bf2ff4c |
|---|---|
| 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 report_extui_packet() | |
| 78 { | |
| 79 sprintf(fmtbuf, "LCD OUT: row %u col %u-%u", rxpkt[1], rxpkt[2], | |
| 80 rxpkt[2] + (rxpkt_len - 3) / 2 - 1); | |
| 81 output_line(fmtbuf); | |
| 82 } |
