Skip to content

Commit ec0c62e

Browse files
committed
Hamlib rotator support
1 parent f41982a commit ec0c62e

14 files changed

+313
-14
lines changed

share/logcfg.dat

+13
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,19 @@ CWTONE=800
143143
#
144144
#################################
145145
# #
146+
# ROTATOR CONTROL #
147+
# (comment out if not present) #
148+
# Rigmodel = Hamlib index, here #
149+
# for Yaesu GS-232B #
150+
#################################
151+
#
152+
#ROTATOR_CONTROL
153+
#ROTMODEL=603
154+
#ROTSPEED=9600
155+
#ROTPORT=/dev/ttyUSB3
156+
#
157+
#################################
158+
# #
146159
# INFORMATION WINDOWS #
147160
# #
148161
#################################

src/callinput.c

+8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "nicebox.h" // Includes curses.h
6161
#include "note.h"
6262
#include "printcall.h"
63+
#include "qrb.h"
6364
#include "qtcvars.h" // Includes globalvars.h
6465
#include "qtcwin.h"
6566
#include "rtty.h"
@@ -713,6 +714,13 @@ int callinput(void) {
713714
break;
714715
}
715716

717+
// Ctrl-D (^D), rotate antenna "d"irection.
718+
case CTRL_D: {
719+
rotate_to_qrb();
720+
721+
break;
722+
}
723+
716724
// Ctrl-F (^F), change frequency dialog.
717725
case CTRL_F: {
718726
change_freq();

src/globalvars.h

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
#include <glib.h>
33
#include <hamlib/rig.h>
4+
#include <hamlib/rotator.h>
45
#include <stdbool.h>
56

67
#include <config.h>
@@ -109,10 +110,13 @@ extern int highqsonr;
109110

110111

111112
extern RIG *my_rig;
113+
extern ROT *my_rot;
112114
extern pthread_mutex_t tlf_rig_mutex;
115+
extern pthread_mutex_t tlf_rot_mutex;
113116
extern cqmode_t cqmode;
114117
extern int trxmode;
115118
extern int myrig_model;
119+
extern int myrot_model;
116120
extern rmode_t rigmode;
117121
extern freq_t freq;
118122
extern char lastqsonr[];
@@ -186,6 +190,7 @@ extern bool keyer_backspace;
186190
extern int netkeyer_port;
187191
extern int cqdelay;
188192
extern int serial_rate;
193+
extern int rot_serial_rate;
189194
extern int tnc_serial_rate;
190195
extern int countrylist_points;
191196
extern int my_country_points;
@@ -220,6 +225,7 @@ extern char modem_mode[];
220225
extern char sc_volume[];
221226
extern char clusterlogin[];
222227
extern char rigconf[];
228+
extern char rotconf[];
223229
extern char keyer_device[10];
224230
extern char netkeyer_hostaddress[];
225231
extern char pr_hostaddress[];
@@ -235,6 +241,7 @@ extern char fldigi_url[50];
235241
extern char *cabrillo;
236242
extern char *editor_cmd;
237243
extern char *rigportname;
244+
extern char *rotportname;
238245
extern char *config_file;
239246
#ifdef HAVE_PYTHON
240247
extern char *plugin_config;
@@ -256,6 +263,7 @@ extern bool ignoredupe;
256263
extern bool continentlist_only;
257264
extern bool debugflag;
258265
extern bool trx_control;
266+
extern bool rot_control;
259267
extern bool nopacket;
260268
extern bool verbose;
261269

src/keystroke_names.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#define CTRL_A 1
2828
#define CTRL_B 2
29+
#define CTRL_D 4
2930
#define CTRL_E 5
3031
#define CTRL_F 6
3132
#define CTRL_G 7 /* Bell */

src/main.c

+55-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
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>
@@ -50,6 +51,7 @@
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 */
332334
int packetinterface = 0;
333335
int fdSertnc = 0;
334336
char tncportname[40];
335-
char rigconf[80];
336337
int tnc_serial_rate = 2400;
337338
char clusterlogin[80] = "";
338339
bool bmautoadd = false;
339340
bool bmautograb = false;
340341

341342
/*-------------------------------------rigctl-------------------------------*/
343+
char rigconf[80];
342344
int myrig_model = 0; /* unset */
343345
RIG *my_rig; /* handle to rig (instance) */
344346
pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -354,6 +356,18 @@ int rignumber = 0;
354356
int rig_comm_error = 0;
355357
int 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---------------------------------*/
358372
char fldigi_url[50] = "http://localhost:7362/RPC2";
359373

@@ -419,6 +433,7 @@ char itustr[3];
419433

420434
bool nopacket = false; /* set if tlf is called with '-n' */
421435
bool trx_control_disabled = false; /* set if tlf is called with '-r' */
436+
bool rot_control_disabled = false; /* set if tlf is called with '-R' */
422437
bool convert_cabrillo = false; /* set if the arg input is a cabrillo */
423438

424439
int 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+
803852
static 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();

src/parse_logcfg.c

+5
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,7 @@ static config_t logcfg_configs[] = {
12991299
{"IGNOREDUPE", CFG_BOOL(ignoredupe)},
13001300
{"USE_CONTINENTLIST_ONLY", CFG_BOOL(continentlist_only)},
13011301
{"RADIO_CONTROL", CFG_BOOL(trx_control)},
1302+
{"ROTATOR_CONTROL", CFG_BOOL(rot_control)},
13021303
{"PORTABLE_MULT_2", CFG_BOOL(portable_x2)},
13031304

13041305
{"USEPARTIALS", CFG_BOOL(use_part)},
@@ -1383,13 +1384,15 @@ static config_t logcfg_configs[] = {
13831384
{"NETKEYERPORT", CFG_INT(netkeyer_port, 1, INT32_MAX)},
13841385
{"TNCSPEED", CFG_INT(tnc_serial_rate, 0, INT32_MAX)},
13851386
{"RIGSPEED", CFG_INT(serial_rate, 0, INT32_MAX)},
1387+
{"ROTSPEED", CFG_INT(rot_serial_rate, 0, INT32_MAX)},
13861388
{"CQDELAY", CFG_INT(cqdelay, 3, 60)},
13871389
{"SSBPOINTS", CFG_INT(ssbpoints, 0, INT32_MAX)},
13881390
{"CWPOINTS", CFG_INT(cwpoints, 0, INT32_MAX)},
13891391
{"WEIGHT", CFG_INT(weight, -50, 50)},
13901392
{"TXDELAY", CFG_INT(txdelay, 0, 50)},
13911393
{"TUNE_SECONDS", CFG_INT(tune_seconds, 1, 100)},
13921394
{"RIGMODEL", CFG_INT(myrig_model, 0, 99999)},
1395+
{"ROTMODEL", CFG_INT(myrot_model, 0, 99999)},
13931396
{"COUNTRY_LIST_POINTS", CFG_INT(countrylist_points, 0, INT32_MAX)},
13941397
{"MY_COUNTRY_POINTS", CFG_INT(my_country_points, 0, INT32_MAX)},
13951398
{"MY_CONTINENT_POINTS", CFG_INT(my_cont_points, 0, INT32_MAX)},
@@ -1406,6 +1409,7 @@ static config_t logcfg_configs[] = {
14061409
{"RIGPTT", CFG_INT_CONST(rigptt, CAT_PTT_WANTED)},
14071410

14081411
{"RIGCONF", CFG_STRING_STATIC(rigconf, 80)},
1412+
{"ROTCONF", CFG_STRING_STATIC(rotconf, 80)},
14091413
{"LOGFILE", CFG_STRING_STATIC(logfile, 120)},
14101414
{"KEYER_DEVICE", CFG_STRING_STATIC(keyer_device, 10)},
14111415
{"NETKEYERHOST", CFG_STRING_STATIC(netkeyer_hostaddress, 16)},
@@ -1429,6 +1433,7 @@ static config_t logcfg_configs[] = {
14291433
#endif
14301434

14311435
{"RIGPORT", CFG_STRING_NOCHOMP(rigportname)},
1436+
{"ROTPORT", CFG_STRING_NOCHOMP(rotportname)},
14321437
{"CLUSTERLOGIN", CFG_STRING_STATIC_NOCHOMP(clusterlogin, 80)},
14331438

14341439
{"CALL", NEED_PARAM, cfg_call},

0 commit comments

Comments
 (0)