Browse Source

Only print printable characters.

master
Solomon Peachy 8 years ago
parent
commit
0d8967f317
  1. 5
      passthru.c

5
passthru.c

@ -37,6 +37,7 @@
#include <string.h>
#include <syslog.h>
#include <ctype.h>
struct sob_config {
uint32_t baud;
@ -341,7 +342,7 @@ int main (int argc, char **argv)
while ((i = read(ser_fd1, &c, sizeof(c))) > 0) {
char buf[20];
write(ser_fd2, &c, sizeof(c));
sprintf(buf, "1> 0x%02x \n", c);
sprintf(buf, "1> 0x%02x '%c'\n", c, isprint(c)? c : '.' );
write(fileno(stdout), buf, strlen(buf));
}
}
@ -351,7 +352,7 @@ int main (int argc, char **argv)
while ((i = read(ser_fd2, &c, sizeof(c))) > 0) {
char buf[20];
write(ser_fd1, &c, sizeof(c));
sprintf(buf, "2> 0x%02x \n", c);
sprintf(buf, "2> 0x%02x '%c'\n", c, isprint(c)? c : '.' );
write(fileno(stdout), buf, strlen(buf));
}
}

Loading…
Cancel
Save