Add -R --rot_file2 option to rotctl and rotctld for 2nd rotator controller for RT21

https://github.com/Hamlib/Hamlib/issues/747
pull/759/head
Mike Black W9MDB 2021-07-23 23:28:02 -05:00
rodzic 68336fedfa
commit fa10d10e38
2 zmienionych plików z 38 dodań i 2 usunięć

Wyświetl plik

@ -83,11 +83,12 @@ void usage();
* NB: do NOT use -W since it's reserved by POSIX. * NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file * TODO: add an option to read from a file
*/ */
#define SHORT_OPTIONS "+m:r:s:C:o:O:t:LvhVluZ" #define SHORT_OPTIONS "+m:r:R:s:C:o:O:t:LvhVluZ"
static struct option long_options[] = static struct option long_options[] =
{ {
{"model", 1, 0, 'm'}, {"model", 1, 0, 'm'},
{"rot-file", 1, 0, 'r'}, {"rot-file", 1, 0, 'r'},
{"rot-file2", 1, 0, 'R'},
{"serial-speed", 1, 0, 's'}, {"serial-speed", 1, 0, 's'},
{"send-cmd-term", 1, 0, 't'}, {"send-cmd-term", 1, 0, 't'},
{"list", 0, 0, 'l'}, {"list", 0, 0, 'l'},
@ -135,6 +136,7 @@ int main(int argc, char *argv[])
#endif /* HAVE_READLINE_HISTORY */ #endif /* HAVE_READLINE_HISTORY */
const char *rot_file = NULL; const char *rot_file = NULL;
const char *rot_file2 = NULL; // for 2nd controller for RT21
int serial_rate = 0; int serial_rate = 0;
char conf_parms[MAXCONFLEN] = ""; char conf_parms[MAXCONFLEN] = "";
int interactive = 1; /* if no cmd on command line, switch to interactive */ int interactive = 1; /* if no cmd on command line, switch to interactive */
@ -190,6 +192,16 @@ int main(int argc, char *argv[])
rot_file = optarg; rot_file = optarg;
break; break;
case 'R':
if (!optarg)
{
usage(); /* wrong arg count */
exit(1);
}
rot_file2 = optarg;
break;
case 's': case 's':
if (!optarg) if (!optarg)
{ {
@ -343,6 +355,11 @@ int main(int argc, char *argv[])
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1); strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
} }
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */ /* FIXME: bound checking and port type == serial */
if (serial_rate != 0) if (serial_rate != 0)
{ {
@ -493,6 +510,7 @@ void usage()
printf( printf(
" -m, --model=ID select rotator model number. See model list\n" " -m, --model=ID select rotator model number. See model list\n"
" -r, --rot-file=DEVICE set device of the rotator to operate on\n" " -r, --rot-file=DEVICE set device of the rotator to operate on\n"
" -R, --rot-file2=DEVICE set device of the 2nd rotator controller to operate on\n"
" -s, --serial-speed=BAUD set serial speed of the serial port\n" " -s, --serial-speed=BAUD set serial speed of the serial port\n"
" -t, --send-cmd-term=CHAR set send_cmd command termination char\n" " -t, --send-cmd-term=CHAR set send_cmd command termination char\n"
" -C, --set-conf=PARM=VAL set config parameters\n" " -C, --set-conf=PARM=VAL set config parameters\n"

Wyświetl plik

@ -84,11 +84,12 @@ void usage();
* NB: do NOT use -W since it's reserved by POSIX. * NB: do NOT use -W since it's reserved by POSIX.
* TODO: add an option to read from a file * TODO: add an option to read from a file
*/ */
#define SHORT_OPTIONS "m:r:s:C:o:O:t:T:LuvhVlZ" #define SHORT_OPTIONS "m:r:R:s:C:o:O:t:T:LuvhVlZ"
static struct option long_options[] = static struct option long_options[] =
{ {
{"model", 1, 0, 'm'}, {"model", 1, 0, 'm'},
{"rot-file", 1, 0, 'r'}, {"rot-file", 1, 0, 'r'},
{"rot-file2", 1, 0, 'R'},
{"serial-speed", 1, 0, 's'}, {"serial-speed", 1, 0, 's'},
{"port", 1, 0, 't'}, {"port", 1, 0, 't'},
{"listen-addr", 1, 0, 'T'}, {"listen-addr", 1, 0, 'T'},
@ -160,6 +161,7 @@ int main(int argc, char *argv[])
int show_conf = 0; int show_conf = 0;
int dump_caps_opt = 0; int dump_caps_opt = 0;
const char *rot_file = NULL; const char *rot_file = NULL;
const char *rot_file2 = NULL;
int serial_rate = 0; int serial_rate = 0;
char conf_parms[MAXCONFLEN] = ""; char conf_parms[MAXCONFLEN] = "";
@ -218,6 +220,16 @@ int main(int argc, char *argv[])
rot_file = optarg; rot_file = optarg;
break; break;
case 'R':
if (!optarg)
{
usage(); /* wrong arg count */
exit(1);
}
rot_file2 = optarg;
break;
case 's': case 's':
if (!optarg) if (!optarg)
{ {
@ -351,6 +363,11 @@ int main(int argc, char *argv[])
strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1); strncpy(my_rot->state.rotport.pathname, rot_file, HAMLIB_FILPATHLEN - 1);
} }
if (rot_file2)
{
strncpy(my_rot->state.rotport2.pathname, rot_file2, HAMLIB_FILPATHLEN - 1);
}
/* FIXME: bound checking and port type == serial */ /* FIXME: bound checking and port type == serial */
if (serial_rate != 0) if (serial_rate != 0)
{ {
@ -730,6 +747,7 @@ void usage()
printf( printf(
" -m, --model=ID select rotator model number. See model list\n" " -m, --model=ID select rotator model number. See model list\n"
" -r, --rot-file=DEVICE set device of the rotator to operate on\n" " -r, --rot-file=DEVICE set device of the rotator to operate on\n"
" -R, --rot-file2=DEVICE set device of the 2nd rotator controller to operate on\n"
" -s, --serial-speed=BAUD set serial speed of the serial port\n" " -s, --serial-speed=BAUD set serial speed of the serial port\n"
" -t, --port=NUM set TCP listening port, default %s\n" " -t, --port=NUM set TCP listening port, default %s\n"
" -T, --listen-addr=IPADDR set listening IP address, default ANY\n" " -T, --listen-addr=IPADDR set listening IP address, default ANY\n"