cake
/
p7utils
Archived
1
0
Fork 0

Added --reset for the settings.

This commit is contained in:
Thomas Touhey 2017-04-06 17:49:34 +02:00
parent 6ef5df8d7c
commit bd9ebf1ce5
3 changed files with 17 additions and 8 deletions

View File

@ -70,6 +70,7 @@ static const char help_main[] =
" and two stop bits. (E for even parity, O for odd parity)\n"
" --set <settings> Set the following serial settings (when used with `--com`).\n"
" The string has the same format than for `--use`.\n"
" --reset Reset the default communication settings (9600N2).\n"
"\n"
"Type \"" QUOTE(BIN) " <subcommand> --help\" for some help about the subcommand.\n"
"Report bugs to " QUOTE(MAINTAINER) ".";
@ -264,6 +265,7 @@ int parse_args(int ac, char **av, args_t *args)
{"no-exit", no_argument, NULL, 'e'},
{"no-term", no_argument, NULL, 'e'},
{"set", required_argument, NULL, 'S'},
{"reset", no_argument, NULL, 'R'},
{"use", required_argument, NULL, 'U'},
/* sentinel */
@ -272,7 +274,7 @@ int parse_args(int ac, char **av, args_t *args)
/* get all options */
int c; opterr = 0;
int help = 0;
int help = 0, rst = 0;
const char *s_out = NULL, *s_dir = NULL, *s_todir = NULL;
const char *s_use = NULL, *s_set = NULL;
while ((c = getopt_long(ac, av, short_options, long_options, NULL)) != -1) {
@ -305,6 +307,7 @@ int parse_args(int ac, char **av, args_t *args)
/* use and set settings */
case 'U': s_use = optarg; break;
case 'S': s_set = optarg; break;
case 'R': rst = 1; break;
/* in case of error */
case '?':
@ -409,18 +412,23 @@ int parse_args(int ac, char **av, args_t *args)
noerror = 1;
if (!noerror) return (0);
/* serial settings */
if (s_set) {
if (args->com) args->set = &args->_set;
if (make_settings("--set", s_set, &args->_set))
return (0);
}
/* use serial settings */
if (s_use) {
if (args->com) args->use = &args->_use;
if (make_settings("--use", s_use, &args->_use))
return (0);
}
/* set serial settings */
if (rst)
args->do_the_set = 1;
else if (s_set) {
args->do_the_set = 1;
if (args->com) args->set = &args->_set;
if (make_settings("--set", s_set, &args->_set))
return (0);
}
/* check local path */
if (args->localpath) {
if (fpmode[0] == 'w' && !strcmp(args->localpath, "-"))

View File

@ -216,7 +216,7 @@ int main(int ac, char **av)
}
/* Change speed, and things */
if (args.set) {
if (args.do_the_set) {
err = p7_setlink(handle, args.set);
if (err) goto fail;
}

View File

@ -39,6 +39,7 @@ typedef struct {
unsigned int initflags;
p7_streamsettings_t *use, _use;
p7_streamsettings_t *set, _set;
int do_the_set;
/* for file transferring menus */
const char *dirname, *filename;