Skip to content

Commit abfd19b

Browse files
committed
Hamlib rotator support
1 parent 6022a84 commit abfd19b

File tree

14 files changed

+313
-14
lines changed

14 files changed

+313
-14
lines changed

share/logcfg.dat

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

src/callinput.c

Lines changed: 8 additions & 0 deletions
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

Lines changed: 8 additions & 0 deletions
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>
@@ -108,10 +109,13 @@ extern int highqsonr;
108109

109110

110111
extern RIG *my_rig;
112+
extern ROT *my_rot;
111113
extern pthread_mutex_t tlf_rig_mutex;
114+
extern pthread_mutex_t tlf_rot_mutex;
112115
extern cqmode_t cqmode;
113116
extern int trxmode;
114117
extern int myrig_model;
118+
extern int myrot_model;
115119
extern rmode_t rigmode;
116120
extern freq_t freq;
117121
extern char lastqsonr[];
@@ -184,6 +188,7 @@ extern bool keyer_backspace;
184188
extern int netkeyer_port;
185189
extern int cqdelay;
186190
extern int serial_rate;
191+
extern int rot_serial_rate;
187192
extern int tnc_serial_rate;
188193
extern int countrylist_points;
189194
extern int my_country_points;
@@ -218,6 +223,7 @@ extern char modem_mode[];
218223
extern char sc_volume[];
219224
extern char clusterlogin[];
220225
extern char rigconf[];
226+
extern char rotconf[];
221227
extern char keyer_device[10];
222228
extern char netkeyer_hostaddress[];
223229
extern char pr_hostaddress[];
@@ -233,6 +239,7 @@ extern char fldigi_url[50];
233239
extern char *cabrillo;
234240
extern char *editor_cmd;
235241
extern char *rigportname;
242+
extern char *rotportname;
236243
extern char *config_file;
237244
#ifdef HAVE_PYTHON
238245
extern char *plugin_config;
@@ -254,6 +261,7 @@ extern bool ignoredupe;
254261
extern bool continentlist_only;
255262
extern bool debugflag;
256263
extern bool trx_control;
264+
extern bool rot_control;
257265
extern bool nopacket;
258266
extern bool verbose;
259267

src/keystroke_names.h

Lines changed: 1 addition & 0 deletions
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

Lines changed: 55 additions & 1 deletion
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"
@@ -331,13 +333,13 @@ int nr_of_spots; /* Anzahl Lines in spot_ptr array */
331333
int packetinterface = 0;
332334
int fdSertnc = 0;
333335
char tncportname[40];
334-
char rigconf[80];
335336
int tnc_serial_rate = 2400;
336337
char clusterlogin[80] = "";
337338
bool bmautoadd = false;
338339
bool bmautograb = false;
339340

340341
/*-------------------------------------rigctl-------------------------------*/
342+
char rigconf[80];
341343
int myrig_model = 0; /* unset */
342344
RIG *my_rig; /* handle to rig (instance) */
343345
pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -353,6 +355,18 @@ int rignumber = 0;
353355
int rig_comm_error = 0;
354356
int rig_comm_success = 0;
355357

358+
/*-------------------------------------rotctl-------------------------------*/
359+
bool rot_control = false;
360+
int myrot_model = 0; /* unset */
361+
char rotconf[80];
362+
ROT *my_rot; /* handle to rotator (instance) */
363+
pthread_mutex_t tlf_rot_mutex = PTHREAD_MUTEX_INITIALIZER;
364+
int rot_serial_rate = 2400;
365+
char *rotportname;
366+
int rotnumber = 0;
367+
int rot_comm_error = 0;
368+
int rot_comm_success = 0;
369+
356370
/*----------------------------------fldigi---------------------------------*/
357371
char fldigi_url[50] = "http://localhost:7362/RPC2";
358372

@@ -418,6 +432,7 @@ char itustr[3];
418432

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

423438
int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
@@ -448,6 +463,7 @@ static const struct argp_option options[] = {
448463
{"import", 'i', 0, 0, "Import Cabrillo file to Tlf format"},
449464
{"no-cluster", 'n', 0, 0, "Start without cluster hookup" },
450465
{"no-rig", 'r', 0, 0, "Start without radio control" },
466+
{"no-rotator", 'R', 0, 0, "Start without radio control" },
451467
{"list", 'l', 0, 0, "List built-in contests" },
452468
{"sync", 's', "URL", 0, "Synchronize log with other node" },
453469
{"debug", 'd', 0, 0, "Debug mode" },
@@ -471,6 +487,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
471487
case 'r':
472488
trx_control_disabled = true; // disable radio control
473489
break;
490+
case 'R':
491+
rot_control_disabled = true; // disable rotator control
492+
break;
474493
case 'i':
475494
convert_cabrillo = true;
476495
break;
@@ -788,6 +807,36 @@ static void hamlib_init() {
788807
}
789808
}
790809

810+
static void hamlib_rot_init() {
811+
812+
if (rot_control_disabled) {
813+
rot_control = false;
814+
}
815+
816+
if (!rot_control) {
817+
return;
818+
}
819+
820+
shownr("Rotator model number is", myrot_model);
821+
shownr("Rotator speed is", rot_serial_rate);
822+
823+
showmsg("Trying to start rotator control");
824+
825+
int status = init_tlf_rot();
826+
827+
if (status != 0) {
828+
showmsg("Continue without rotator control Y/(N)?");
829+
if (toupper(key_get()) != 'Y') {
830+
endwin();
831+
exit(1);
832+
}
833+
trx_control = false;
834+
trx_control_disabled = true;
835+
showmsg("Disabling rotator control!");
836+
sleep(1);
837+
}
838+
}
839+
791840
static void fldigi_init() {
792841
#ifdef HAVE_LIBXMLRPC
793842
int status;
@@ -979,6 +1028,10 @@ static void tlf_cleanup() {
9791028
close_tlf_rig(my_rig);
9801029
}
9811030

1031+
if (my_rot) {
1032+
close_tlf_rot(my_rot);
1033+
}
1034+
9821035
#ifdef HAVE_LIBXMLRPC
9831036
if (digikeyer == FLDIGI) {
9841037
fldigi_xmlrpc_cleanup();
@@ -1086,6 +1139,7 @@ int main(int argc, char *argv[]) {
10861139
// synclog(synclogfile);
10871140

10881141
hamlib_init();
1142+
hamlib_rot_init();
10891143
fldigi_init();
10901144
lan_init();
10911145
keyer_init();

src/parse_logcfg.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,7 @@ static config_t logcfg_configs[] = {
12431243
{"IGNOREDUPE", CFG_BOOL(ignoredupe)},
12441244
{"USE_CONTINENTLIST_ONLY", CFG_BOOL(continentlist_only)},
12451245
{"RADIO_CONTROL", CFG_BOOL(trx_control)},
1246+
{"ROTATOR_CONTROL", CFG_BOOL(rot_control)},
12461247
{"PORTABLE_MULT_2", CFG_BOOL(portable_x2)},
12471248

12481249
{"USEPARTIALS", CFG_BOOL(use_part)},
@@ -1326,13 +1327,15 @@ static config_t logcfg_configs[] = {
13261327
{"NETKEYERPORT", CFG_INT(netkeyer_port, 1, INT32_MAX)},
13271328
{"TNCSPEED", CFG_INT(tnc_serial_rate, 0, INT32_MAX)},
13281329
{"RIGSPEED", CFG_INT(serial_rate, 0, INT32_MAX)},
1330+
{"ROTSPEED", CFG_INT(rot_serial_rate, 0, INT32_MAX)},
13291331
{"CQDELAY", CFG_INT(cqdelay, 3, 60)},
13301332
{"SSBPOINTS", CFG_INT(ssbpoints, 0, INT32_MAX)},
13311333
{"CWPOINTS", CFG_INT(cwpoints, 0, INT32_MAX)},
13321334
{"WEIGHT", CFG_INT(weight, -50, 50)},
13331335
{"TXDELAY", CFG_INT(txdelay, 0, 50)},
13341336
{"TUNE_SECONDS", CFG_INT(tune_seconds, 1, 100)},
13351337
{"RIGMODEL", CFG_INT(myrig_model, 0, 99999)},
1338+
{"ROTMODEL", CFG_INT(myrot_model, 0, 99999)},
13361339
{"COUNTRY_LIST_POINTS", CFG_INT(countrylist_points, 0, INT32_MAX)},
13371340
{"MY_COUNTRY_POINTS", CFG_INT(my_country_points, 0, INT32_MAX)},
13381341
{"MY_CONTINENT_POINTS", CFG_INT(my_cont_points, 0, INT32_MAX)},
@@ -1349,6 +1352,7 @@ static config_t logcfg_configs[] = {
13491352
{"RIGPTT", CFG_INT_CONST(rigptt, CAT_PTT_WANTED)},
13501353

13511354
{"RIGCONF", CFG_STRING_STATIC(rigconf, 80)},
1355+
{"ROTCONF", CFG_STRING_STATIC(rotconf, 80)},
13521356
{"LOGFILE", CFG_STRING_STATIC(logfile, 120)},
13531357
{"KEYER_DEVICE", CFG_STRING_STATIC(keyer_device, 10)},
13541358
{"NETKEYERHOST", CFG_STRING_STATIC(netkeyer_hostaddress, 16)},
@@ -1372,6 +1376,7 @@ static config_t logcfg_configs[] = {
13721376
#endif
13731377

13741378
{"RIGPORT", CFG_STRING_NOCHOMP(rigportname)},
1379+
{"ROTPORT", CFG_STRING_NOCHOMP(rotportname)},
13751380
{"CLUSTERLOGIN", CFG_STRING_STATIC_NOCHOMP(clusterlogin, 80)},
13761381

13771382
{"CALL", NEED_PARAM, cfg_call},

0 commit comments

Comments
 (0)