summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2013-08-25 10:10:55 -0400
committerSolomon Peachy <pizza@shaftnet.org>2013-08-25 10:10:55 -0400
commit4ed6c4a3a8407469a9a379c68c194bec62346704 (patch)
treee80d1044bc89f4306fc1325d457f9f82073359dc
parent7f1f0172955a41e7e616035f17bb09a765e3cdfb (diff)
downloadsobredirect-4ed6c4a3a8407469a9a379c68c194bec62346704.tar.gz
sobredirect-4ed6c4a3a8407469a9a379c68c194bec62346704.tar.bz2
sobredirect-4ed6c4a3a8407469a9a379c68c194bec62346704.zip
Add hw/sw flow control options to passthru.
-rw-r--r--passthru.c50
-rw-r--r--redirector.c2
2 files changed, 46 insertions, 6 deletions
diff --git a/passthru.c b/passthru.c
index b134f1f..25493ed 100644
--- a/passthru.c
+++ b/passthru.c
@@ -59,9 +59,8 @@ static void dump_config(char *prefix, struct sob_config *cfg)
void printhelp() {
fprintf(stderr, " Serial to Serial forwarder and sniffer\n\n");
- fprintf(stderr, "\t-d <serialdev> -s <commsparams>\n");
- fprintf(stderr, "\t-D <serialdev> -S <commsparams>\n");
-
+ fprintf(stderr, "\t-d <serialdev> -s <commsparams> [ -x | -r ]\n");
+ fprintf(stderr, "\t-D <serialdev> -S <commsparams> [ -X | -R ]\n");
fprintf(stderr, "commsparams: <baud>-<databits><parity><stopbits>\n");
fprintf(stderr, "\n");
}
@@ -79,6 +78,8 @@ int main (int argc, char **argv)
int hw_flow = 0;
int sw_flow = 0;
+ int hw_flow2 = 0;
+ int sw_flow2 = 0;
char *ser_dev1 = NULL;
char *ser_dev2 = NULL;
@@ -99,7 +100,7 @@ int main (int argc, char **argv)
/* Parse command line */
while(1) {
int c;
- c = getopt(argc, argv, "hd:s:D:S:");
+ c = getopt(argc, argv, "hd:s:D:S:xrXR");
if (c == -1) break;
switch (c) {
case 'h':
@@ -117,6 +118,19 @@ int main (int argc, char **argv)
case 'S':
comm_params2 = optarg;
break;
+ case 'x':
+ sw_flow = 1;
+ break;
+ case 'r':
+ hw_flow = 1;
+ break;
+ case 'X':
+ sw_flow2 = 1;
+ break;
+ case 'R':
+ hw_flow2 = 1;
+ break;
+
default:
fprintf(stderr, "getopt returned bogus option '%c'\n", c);
return 1;
@@ -129,6 +143,32 @@ int main (int argc, char **argv)
return 2;
}
+ if (hw_flow && sw_flow) {
+ fprintf(stderr, "ERROR: can't use both hardware and software flow control.\n\n");
+ printhelp();
+ return 10;
+ }
+
+ if (hw_flow2 && sw_flow2) {
+ fprintf(stderr, "ERROR: can't use both hardware and software flow control.\n\n");
+ printhelp();
+ return 10;
+ }
+
+ if (hw_flow)
+ sob_cfg1.flow = 'H';
+ else if (sw_flow)
+ sob_cfg1.flow = 'S';
+ else
+ sob_cfg1.flow = 'N';
+
+ if (hw_flow2)
+ sob_cfg2.flow = 'H';
+ else if (sw_flow2)
+ sob_cfg2.flow = 'S';
+ else
+ sob_cfg2.flow = 'N';
+
/* Parse serial parameters #1 */
i = sscanf(comm_params1, "%d-%d%c%d", &sob_cfg1.baud, &sob_cfg1.databits,
&sob_cfg1.parity, &sob_cfg1.stopbits);
@@ -197,7 +237,7 @@ int main (int argc, char **argv)
/* Set serial Parameters #2*/
i = setserial(&ser_cfg2, ser_fd2, sob_cfg2.baud, sob_cfg2.databits,
sob_cfg2.parity, sob_cfg2.stopbits,
- hw_flow, sw_flow, modem_lines);
+ hw_flow2, sw_flow2, modem_lines);
if (i > 0) {
printhelp();
return 7;
diff --git a/redirector.c b/redirector.c
index d67f5c8..f425aff 100644
--- a/redirector.c
+++ b/redirector.c
@@ -276,7 +276,7 @@ int main (int argc, char **argv)
}
if (hw_flow)
- sob_cfg.flow = 'H';
+ sob_cfg.flow = 'H';
else if (sw_flow)
sob_cfg.flow = 'S';
else