2323#include <argp.h>
2424#include <ctype.h>
2525#include <hamlib/rig.h>
26+ #include <hamlib/rotator.h>
2627#include <pthread.h>
2728#include <stdio.h>
2829#include <stdlib.h>
5051#include "netkeyer.h"
5152#include "parse_logcfg.h"
5253#include "plugin.h"
54+ #include "qrb.h"
5355#include "qtcvars.h" // Includes globalvars.h
5456#include "readctydata.h"
5557#include "readcalls.h"
@@ -332,13 +334,13 @@ int nr_of_spots; /* Anzahl Lines in spot_ptr array */
332334int packetinterface = 0 ;
333335int fdSertnc = 0 ;
334336char tncportname [40 ];
335- char rigconf [80 ];
336337int tnc_serial_rate = 2400 ;
337338char clusterlogin [80 ] = "" ;
338339bool bmautoadd = false;
339340bool bmautograb = false;
340341
341342/*-------------------------------------rigctl-------------------------------*/
343+ char rigconf [80 ];
342344int myrig_model = 0 ; /* unset */
343345RIG * my_rig ; /* handle to rig (instance) */
344346pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER ;
@@ -354,6 +356,18 @@ int rignumber = 0;
354356int rig_comm_error = 0 ;
355357int rig_comm_success = 0 ;
356358
359+ /*-------------------------------------rotctl-------------------------------*/
360+ bool rot_control = false;
361+ int myrot_model = 0 ; /* unset */
362+ char rotconf [80 ];
363+ ROT * my_rot ; /* handle to rotator (instance) */
364+ pthread_mutex_t tlf_rot_mutex = PTHREAD_MUTEX_INITIALIZER ;
365+ int rot_serial_rate = 2400 ;
366+ char * rotportname ;
367+ int rotnumber = 0 ;
368+ int rot_comm_error = 0 ;
369+ int rot_comm_success = 0 ;
370+
357371/*----------------------------------fldigi---------------------------------*/
358372char fldigi_url [50 ] = "http://localhost:7362/RPC2" ;
359373
@@ -419,6 +433,7 @@ char itustr[3];
419433
420434bool nopacket = false; /* set if tlf is called with '-n' */
421435bool trx_control_disabled = false; /* set if tlf is called with '-r' */
436+ bool rot_control_disabled = false; /* set if tlf is called with '-R' */
422437bool convert_cabrillo = false; /* set if the arg input is a cabrillo */
423438
424439int bandweight_points [NBANDS ] = {1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 };
@@ -449,6 +464,7 @@ static const struct argp_option options[] = {
449464 {"import" , 'i' , 0 , 0 , "Import Cabrillo file to Tlf format" },
450465 {"no-cluster" , 'n' , 0 , 0 , "Start without cluster hookup" },
451466 {"no-rig" , 'r' , 0 , 0 , "Start without radio control" },
467+ {"no-rotator" , 'R' , 0 , 0 , "Start without radio control" },
452468 {"list" , 'l' , 0 , 0 , "List built-in contests" },
453469 {"sync" , 's' , "URL" , 0 , "Synchronize log with other node" },
454470 {"debug" , 'd' , 0 , 0 , "Debug mode" },
@@ -472,6 +488,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
472488 case 'r' :
473489 trx_control_disabled = true; // disable radio control
474490 break ;
491+ case 'R' :
492+ rot_control_disabled = true; // disable rotator control
493+ break ;
475494 case 'i' :
476495 convert_cabrillo = true;
477496 break ;
@@ -800,6 +819,36 @@ static void hamlib_init() {
800819 }
801820}
802821
822+ static void hamlib_rot_init () {
823+
824+ if (rot_control_disabled ) {
825+ rot_control = false;
826+ }
827+
828+ if (!rot_control ) {
829+ return ;
830+ }
831+
832+ shownr ("Rotator model number is" , myrot_model );
833+ shownr ("Rotator speed is" , rot_serial_rate );
834+
835+ showmsg ("Trying to start rotator control" );
836+
837+ int status = init_tlf_rot ();
838+
839+ if (status != 0 ) {
840+ showmsg ("Continue without rotator control Y/(N)?" );
841+ if (toupper (key_get ()) != 'Y' ) {
842+ endwin ();
843+ exit (1 );
844+ }
845+ trx_control = false;
846+ trx_control_disabled = true;
847+ showmsg ("Disabling rotator control!" );
848+ sleep (1 );
849+ }
850+ }
851+
803852static void fldigi_init () {
804853#ifdef HAVE_LIBXMLRPC
805854 int status ;
@@ -991,6 +1040,10 @@ static void tlf_cleanup() {
9911040 close_tlf_rig (my_rig );
9921041 }
9931042
1043+ if (my_rot ) {
1044+ close_tlf_rot (my_rot );
1045+ }
1046+
9941047#ifdef HAVE_LIBXMLRPC
9951048 if (digikeyer == FLDIGI ) {
9961049 fldigi_xmlrpc_cleanup ();
@@ -1098,6 +1151,7 @@ int main(int argc, char *argv[]) {
10981151// synclog(synclogfile);
10991152
11001153 hamlib_init ();
1154+ hamlib_rot_init ();
11011155 fldigi_init ();
11021156 lan_init ();
11031157 keyer_init ();
0 commit comments