Only print printable characters.
This commit is contained in:
parent
d8d860c458
commit
0d8967f317
|
@ -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…
Reference in a new issue