tunslip6: make printing of sensible strings from mote more reliable

This commit is contained in:
Michael Richardson 2014-05-10 17:16:07 -04:00
parent 6b473301c5
commit 6608b62b01

View file

@ -238,13 +238,21 @@ serial_to_tun(FILE *inslip, int outfd)
slip_send(slipfd, SLIP_END); slip_send(slipfd, SLIP_END);
} }
#define DEBUG_LINE_MARKER '\r' #define DEBUG_LINE_MARKER '\r'
} else if(uip.inbuf[0] == DEBUG_LINE_MARKER) { if(uip.inbuf[0] == DEBUG_LINE_MARKER ||
fwrite(uip.inbuf + 1, inbufptr - 1, 1, stdout); is_sensible_string(uip.inbuf, inbufptr)) {
} else if(is_sensible_string(uip.inbuf, inbufptr)) { unsigned char *out = uip.inbuf;
if(verbose==1) { /* strings already echoed below for verbose>1 */ unsigned int len = inbufptr;
if (timestamp) stamptime(); if(uip.inbuf[0] == DEBUG_LINE_MARKER) {
fwrite(uip.inbuf, inbufptr, 1, stdout); out++;
} len--;
}
fprintf(stderr, "\n***");
fwrite(out, len, 1, stderr);
fprintf(stderr, "***\n");
} else {
fprintf(stderr,
"serial_to_tun: drop packet len=%d\n", inbufptr);
}
} else { } else {
if(verbose>2) { if(verbose>2) {
if (timestamp) stamptime(); if (timestamp) stamptime();