1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
From 5d9373f24f1b519c030024b2f36277ba9713697c Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer@who-t.net>
Date: Wed, 21 Jul 2010 14:41:04 +1000
Subject: [PATCH 3/3] Allow for custom baud rates.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
---
inputattach.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
diff --git a/inputattach.c b/inputattach.c
index 0382954..6806fc8 100644
--- a/inputattach.c
+++ b/inputattach.c
@@ -506,7 +506,7 @@ static void show_help(void)
struct input_types *type;
puts("");
- puts("Usage: inputattach [--daemon] <mode> <device>");
+ puts("Usage: inputattach [--daemon] [--baud <baud>] <mode> <device>");
puts("");
puts("Modes:");
@@ -530,6 +530,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")) {
@@ -540,6 +541,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,
@@ -580,6 +590,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)
--
1.7.2.3
|