commit 62f33d87852de094a7ddc6da2656f80be6a87143
parent ceb8470d0ef87be8950b8be6dd222a485e6ce7cf
Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 27 Oct 2012 01:27:02 +0200
Outputting raw txt in protocol mode. Text mode still replaces unreadable
characters.
Diffstat:
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/acarsdec.h b/acarsdec.h
@@ -7,6 +7,7 @@ typedef struct {
unsigned char no[5];
unsigned char fid[7];
char txt[256];
+ int txtlen;
} msg_t;
extern int initsample(char *sourcename, int src);
diff --git a/getmesg.c b/getmesg.c
@@ -31,7 +31,7 @@ struct mstat_s {
CRC2, END } state;
int ind;
unsigned short crc;
- char txt[243];
+ char txt[243+1];
} mstat[2];
@@ -61,16 +61,6 @@ static void update_crc(unsigned short *crc, unsigned char ch)
static int build_mesg(char *txt, int len, msg_t *msg)
{
int i, k;
- char r;
-
- /* remove special chars */
- for (i = 0; i < len; i++) {
- r = txt[i];
- if (r < ' ' && r != 0x0d && r != 0x0a)
- r = ' ';
- txt[i] = r;
- }
- txt[i] = '\0';
/* fill msg struct */
k = 0;
@@ -107,7 +97,10 @@ static int build_mesg(char *txt, int len, msg_t *msg)
}
msg->fid[6] = '\0';
- strcpy(msg->txt, &(txt[k]));
+ len -= k;
+ memmove(msg->txt, &(txt[k]), len);
+ msg->txt[len] = '\0';
+ msg->txtlen = len;
return 1;
}
@@ -227,3 +220,4 @@ int getmesg(unsigned char r, msg_t *msg, int ch)
}
} while (1);
}
+
diff --git a/main.c b/main.c
@@ -75,6 +75,14 @@ void print_mesg(msg_t *msg, int colored, int messgnumb)
time_t t;
struct tm *tmp;
char pos[128];
+ int i;
+
+ for (i = 0; i < msg->txtlen; i++) {
+ if (msg->txt[i] < ' ' && msg->txt[i] != '\r'
+ && msg->txt[i] != '\n') {
+ msg->txt[i] = ' ';
+ }
+ }
if (colored) {
printf("ACARS mode: %s%c%s", RED, msg->mode, NONE);
@@ -102,8 +110,6 @@ void print_mesg(msg_t *msg, int colored, int messgnumb)
}
}
-
-
t = time(NULL);
tmp = gmtime(&t);
printf("\n[%5d]-------------------------------------"
@@ -128,7 +134,10 @@ void print_proto(msg_t *msg)
printf("BLKID: %d\n", (int) msg->bid);
printf("MSGNO: %s\n", msg->no);
printf("FLIGHTID: %s\n", msg->fid);
- printf("CONTENT: %s\n.\n", msg->txt);
+ printf("CONTENTLENGTH: %d\n", msg->txtlen);
+ printf("CONTENT:\n");
+ fwrite(msg->txt, msg->txtlen, 1, stdout);
+ printf("\n.\n");
if (posconv(msg->txt, msg->label, pos)==0) {
printf("APRS-ADDR: %s\n", msg->addr);