sconsole

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 6657135a1dbb4c7471456ebef3ac1217ce7db6d3
parent ef13e4cd1beac8e49052a7a711235733b5f35226
Author: Brian Swetland <swetland@frotz.net>
Date:   Fri, 13 Dec 2013 01:01:19 -0800

add -c for nl-to-cr remap mode

Sometimes the remote will only accept a CR.

Diffstat:
Msconsole.c | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sconsole.c b/sconsole.c @@ -219,6 +219,7 @@ int main(int argc, char *argv[]) const char *device = "/dev/ttyUSB0"; const char *logfile = "console.log"; int fd, n; + int map_nl_to_cr = 0; int escape = 0; int logfd = -1; unsigned char ESC = 27; @@ -245,6 +246,10 @@ int main(int argc, char *argv[]) logfile = &argv[1][2]; logfd = open(logfile, O_CREAT | O_WRONLY, 0644); break; + case 'c': + /* carriage return mode -- map \n to \r */ + map_nl_to_cr = 1; + break; default: fprintf(stderr, "unknown option %s\n", argv[1]); return 1; @@ -301,7 +306,12 @@ int main(int argc, char *argv[]) if (x == 27) { escape = 1; } else { - write(fd, &x, 1); + if ((x == '\n') && map_nl_to_cr) { + x = '\r'; + write(fd, &x, 1); + } else { + write(fd, &x, 1); + } } break; case 1: