FreeCalypso > hg > freecalypso-sw
comparison rvinterf/lowlevel/format.c @ 327:05874f1ddacb
rvinterf & rvtdump: new decoding of G23/GPF packets
| author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
|---|---|
| date | Sun, 20 Apr 2014 20:39:53 +0000 |
| parents | 2f285f20d617 |
| children | 2ac2f6d88bb2 |
comparison
equal
deleted
inserted
replaced
| 326:7e878e6b9cf7 | 327:05874f1ddacb |
|---|---|
| 11 #include "../include/limits.h" | 11 #include "../include/limits.h" |
| 12 | 12 |
| 13 extern u_char rxpkt[]; | 13 extern u_char rxpkt[]; |
| 14 extern size_t rxpkt_len; | 14 extern size_t rxpkt_len; |
| 15 | 15 |
| 16 char fmtbuf[MAX_PKT_FROM_TARGET*8]; /* size it generously */ | |
| 17 | |
| 16 void | 18 void |
| 17 print_rv_trace() | 19 print_rv_trace() |
| 18 { | 20 { |
| 19 char buf[MAX_PKT_FROM_TARGET*4]; | |
| 20 int i, c; | 21 int i, c; |
| 21 char *dp; | 22 char *dp; |
| 22 | 23 |
| 23 dp = buf; | 24 dp = fmtbuf; |
| 24 strcpy(dp, "RV "); | 25 strcpy(dp, "RV "); |
| 25 dp += 3; | 26 dp += 3; |
| 26 /* the SWE static ID is sent MSB first */ | 27 /* the SWE static ID is sent MSB first */ |
| 27 for (i = 1; i <= 4; i++) { | 28 for (i = 1; i <= 4; i++) { |
| 28 sprintf(dp, "%02X", rxpkt[i]); | 29 sprintf(dp, "%02X", rxpkt[i]); |
| 46 *dp++ = '?'; | 47 *dp++ = '?'; |
| 47 } else | 48 } else |
| 48 *dp++ = c; | 49 *dp++ = c; |
| 49 } | 50 } |
| 50 *dp = '\0'; | 51 *dp = '\0'; |
| 51 output_line(buf); | 52 output_line(fmtbuf); |
| 52 } | 53 } |
| 53 | 54 |
| 54 void | 55 void |
| 55 print_l1_trace() | 56 print_l1_trace() |
| 56 { | 57 { |
| 57 char buf[MAX_PKT_FROM_TARGET*4+1]; | |
| 58 int i, c; | 58 int i, c; |
| 59 char *dp; | 59 char *dp; |
| 60 | 60 |
| 61 dp = buf; | 61 dp = fmtbuf; |
| 62 strcpy(dp, "L1: "); | 62 strcpy(dp, "L1: "); |
| 63 dp += 4; | 63 dp += 4; |
| 64 for (i = 1; i < rxpkt_len; i++) { | 64 for (i = 1; i < rxpkt_len; i++) { |
| 65 if ((i+1 < rxpkt_len) && | 65 if ((i+1 < rxpkt_len) && |
| 66 (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' || | 66 (rxpkt[i] == '\r' && rxpkt[i+1] == '\n' || |
| 67 rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) { | 67 rxpkt[i] == '\n' && rxpkt[i+1] == '\r')) { |
| 68 *dp = '\0'; | 68 *dp = '\0'; |
| 69 output_line(buf); | 69 output_line(fmtbuf); |
| 70 if (i+2 == rxpkt_len) | 70 if (i+2 == rxpkt_len) |
| 71 return; | 71 return; |
| 72 dp = buf; | 72 dp = fmtbuf; |
| 73 *dp++ = '+'; | 73 *dp++ = '+'; |
| 74 *dp++ = ' '; | 74 *dp++ = ' '; |
| 75 i++; | 75 i++; |
| 76 continue; | 76 continue; |
| 77 } | 77 } |
| 90 } else | 90 } else |
| 91 *dp++ = c; | 91 *dp++ = c; |
| 92 } | 92 } |
| 93 /* will get here only if no newline sequence at the end */ | 93 /* will get here only if no newline sequence at the end */ |
| 94 *dp = '\0'; | 94 *dp = '\0'; |
| 95 output_line(buf); | 95 output_line(fmtbuf); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void | 98 void |
| 99 print_etm_output_raw() | 99 print_etm_output_raw() |
| 100 { | 100 { |
| 101 char buf[MAX_PKT_FROM_TARGET*3+2]; | |
| 102 int i; | 101 int i; |
| 103 char *dp; | 102 char *dp; |
| 104 | 103 |
| 105 dp = buf; | 104 dp = fmtbuf; |
| 106 strcpy(dp, "ETM:"); | 105 strcpy(dp, "ETM:"); |
| 107 dp += 4; | 106 dp += 4; |
| 108 for (i = 1; i < rxpkt_len; i++) { | 107 for (i = 1; i < rxpkt_len; i++) { |
| 109 sprintf(dp, " %02X", rxpkt[i]); | 108 sprintf(dp, " %02X", rxpkt[i]); |
| 110 dp += 3; | 109 dp += 3; |
| 111 } | 110 } |
| 112 *dp = '\0'; | 111 *dp = '\0'; |
| 113 output_line(buf); | 112 output_line(fmtbuf); |
| 114 } | 113 } |
| 115 | 114 |
| 116 void | 115 void |
| 117 print_unknown_packet() | 116 print_unknown_packet() |
| 118 { | 117 { |
| 119 char buf[MAX_PKT_FROM_TARGET*3+5]; | |
| 120 int i; | 118 int i; |
| 121 char *dp; | 119 char *dp; |
| 122 | 120 |
| 123 dp = buf; | 121 dp = fmtbuf; |
| 124 strcpy(dp, "UNK:"); | 122 strcpy(dp, "UNK:"); |
| 125 dp += 4; | 123 dp += 4; |
| 126 for (i = 0; i < rxpkt_len; i++) { | 124 for (i = 0; i < rxpkt_len; i++) { |
| 127 sprintf(dp, " %02X", rxpkt[i]); | 125 sprintf(dp, " %02X", rxpkt[i]); |
| 128 dp += 3; | 126 dp += 3; |
| 129 } | 127 } |
| 130 *dp = '\0'; | 128 *dp = '\0'; |
| 131 output_line(buf); | 129 output_line(fmtbuf); |
| 132 } | 130 } |
