diff --git a/inputattach.c b/inputattach.c index a7de302..8967950 100644 --- a/inputattach.c +++ b/inputattach.c @@ -503,7 +503,7 @@ static void show_help(void) struct input_types *type; puts(""); - puts("Usage: inputattach [--daemon] "); + puts("Usage: inputattach [--daemon] [--baud ] "); puts(""); puts("Modes:"); @@ -527,6 +527,7 @@ int main(int argc, char **argv) int i; char c; int retval; + int baud = -1; for (i = 1; i < argc; i++) { if (!strcasecmp(argv[i], "--help")) { @@ -537,6 +538,15 @@ int main(int argc, char **argv) } else if (need_device) { device = argv[i]; need_device = 0; + } else if (!strcasecmp(argv[i], "--baud")) { + if (argc <= i + 1) { + show_help(); + fprintf(stderr, + "inputattach: require baud rate\n"); + return EXIT_FAILURE; + } + + baud = atoi(argv[++i]); } else { if (type && type->name) { fprintf(stderr, @@ -577,6 +587,19 @@ int main(int argc, char **argv) return 1; } + switch(baud) { + case -1: break; + case 2400: type->speed = B2400; break; + case 4800: type->speed = B4800; break; + case 9600: type->speed = B9600; break; + case 19200: type->speed = B19200; break; + case 38400: type->speed = B38400; break; + default: + fprintf(stderr, "inputattach: invalid baud rate '%d'\n", + baud); + return EXIT_FAILURE; + } + setline(fd, type->flags, type->speed); if (type->flush)