Add hw/sw flow control options to passthru.
This commit is contained in:
parent
7f1f017295
commit
4ed6c4a3a8
50
passthru.c
50
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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue