Skip to content

Commit e3b7cb8

Browse files
authored
Hamlib rotator support (#455)
This adds rotator support. Configuration is done exactly like rig support with ROTATOR_CONTROL, ROTMODEL, ROTSPEED and ROTPORT. Two new keybindings are introduced: ^ (think "arrow") rotates towards the country of the current call, and & (the key right of ^ on US keyboards) rotates to the long-path direction. If the current call is from the own country, no rotation is done.
1 parent 44a1f47 commit e3b7cb8

File tree

13 files changed

+378
-8
lines changed

13 files changed

+378
-8
lines changed

share/logcfg.dat

Lines changed: 13 additions & 0 deletions
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/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>
@@ -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[];
@@ -187,6 +191,7 @@ extern bool keyer_backspace;
187191
extern int netkeyer_port;
188192
extern int cqdelay;
189193
extern int serial_rate;
194+
extern int rot_serial_rate;
190195
extern int tnc_serial_rate;
191196
extern int countrylist_points;
192197
extern int my_country_points;
@@ -221,6 +226,7 @@ extern char modem_mode[];
221226
extern char sc_volume[];
222227
extern char clusterlogin[];
223228
extern char rigconf[];
229+
extern char rotconf[];
224230
extern char keyer_device[10];
225231
extern char netkeyer_hostaddress[];
226232
extern char pr_hostaddress[];
@@ -236,6 +242,7 @@ extern char fldigi_url[50];
236242
extern char *cabrillo;
237243
extern char *editor_cmd;
238244
extern char *rigportname;
245+
extern char *rotportname;
239246
extern char *config_file;
240247
#ifdef HAVE_PYTHON
241248
extern char *plugin_config;
@@ -257,6 +264,7 @@ extern bool ignoredupe;
257264
extern bool continentlist_only;
258265
extern int debuglevel;
259266
extern bool trx_control;
267+
extern bool rot_control;
260268
extern bool nopacket;
261269
extern bool verbose;
262270

src/keyer.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "netkeyer.h"
3737
#include "nicebox.h" // Includes curses.h
3838
#include "sendbuf.h"
39+
#include "sendqrg.h"
3940
#include "speedupndown.h"
4041
#include "stoptx.h"
4142
#include "time_update.h"
@@ -144,6 +145,20 @@ int handle_common_key(int key) {
144145
break;
145146
}
146147

148+
// Rotate antenna to short path
149+
case '^': {
150+
rotate_to_qrb(false);
151+
152+
break;
153+
}
154+
155+
// Rotate antenna to long path
156+
case '&': {
157+
rotate_to_qrb(true);
158+
159+
break;
160+
}
161+
147162
// <Page-Up>, change RST if call field not empty, else increase CW speed.
148163
case KEY_PPAGE: {
149164
if (change_rst && (strlen(current_qso.call) != 0)) { // change RST

src/main.c

Lines changed: 56 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>
@@ -334,13 +335,13 @@ int nr_of_spots; /* Anzahl Lines in spot_ptr array */
334335
int packetinterface = 0;
335336
int fdSertnc = 0;
336337
char tncportname[40];
337-
char rigconf[80];
338338
int tnc_serial_rate = 2400;
339339
char clusterlogin[80] = "";
340340
bool bmautoadd = false;
341341
bool bmautograb = false;
342342

343343
/*-------------------------------------rigctl-------------------------------*/
344+
char rigconf[80];
344345
int myrig_model = 0; /* unset */
345346
RIG *my_rig; /* handle to rig (instance) */
346347
pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -356,6 +357,15 @@ int rignumber = 0;
356357
int rig_comm_error = 0;
357358
int rig_comm_success = 0;
358359

360+
/*-------------------------------------rotctl-------------------------------*/
361+
bool rot_control;
362+
int myrot_model; /* unset */
363+
char rotconf[80];
364+
ROT *my_rot; /* handle to rotator (instance) */
365+
pthread_mutex_t tlf_rot_mutex = PTHREAD_MUTEX_INITIALIZER;
366+
int rot_serial_rate;
367+
char *rotportname;
368+
359369
/*----------------------------------fldigi---------------------------------*/
360370
char fldigi_url[50] = "http://localhost:7362/RPC2";
361371

@@ -421,6 +431,7 @@ char itustr[3];
421431

422432
bool nopacket = false; /* set if tlf is called with '-n' */
423433
bool trx_control_disabled = false; /* set if tlf is called with '-r' */
434+
bool rot_control_disabled = false; /* set if tlf is called with '-R' */
424435
bool convert_cabrillo = false; /* set if the arg input is a cabrillo */
425436

426437
int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
@@ -451,6 +462,7 @@ static const struct argp_option options[] = {
451462
{"import", 'i', 0, 0, "Import Cabrillo file to Tlf format"},
452463
{"no-cluster", 'n', 0, 0, "Start without cluster hookup" },
453464
{"no-rig", 'r', 0, 0, "Start without radio control" },
465+
{"no-rotator", 'R', 0, 0, "Start without rotator control" },
454466
{"list", 'l', 0, 0, "List built-in contests" },
455467
{"sync", 's', "URL", 0, "Synchronize log with other node" },
456468
{
@@ -477,6 +489,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
477489
case 'r':
478490
trx_control_disabled = true; // disable radio control
479491
break;
492+
case 'R':
493+
rot_control_disabled = true; // disable rotator control
494+
break;
480495
case 'i':
481496
convert_cabrillo = true;
482497
break;
@@ -665,6 +680,11 @@ static void init_variables() {
665680
rig_mode_sync = true;
666681
use_bandoutput = false;
667682

683+
/* rotctl */
684+
rot_control = false;
685+
myrot_model = 0; /* unset */
686+
rot_serial_rate = 2400;
687+
668688
lan_active = false;
669689
thisnode = 'A';
670690
lan_port = 6788;
@@ -812,6 +832,36 @@ static void hamlib_init() {
812832
}
813833
}
814834

835+
static void hamlib_rot_init() {
836+
837+
if (rot_control_disabled) {
838+
rot_control = false;
839+
}
840+
841+
if (!rot_control) {
842+
return;
843+
}
844+
845+
shownr("Rotator model number is", myrot_model);
846+
shownr("Rotator speed is", rot_serial_rate);
847+
848+
showmsg("Trying to start rotator control");
849+
850+
int status = init_tlf_rot();
851+
852+
if (status != 0) {
853+
showmsg("Continue without rotator control Y/(N)?");
854+
if (toupper(key_get()) != 'Y') {
855+
endwin();
856+
exit(1);
857+
}
858+
rot_control = false;
859+
rot_control_disabled = true;
860+
showmsg("Disabling rotator control!");
861+
sleep(1);
862+
}
863+
}
864+
815865
static void fldigi_init() {
816866
#ifdef HAVE_LIBXMLRPC
817867
int status;
@@ -1003,6 +1053,10 @@ static void tlf_cleanup() {
10031053
close_tlf_rig(my_rig);
10041054
}
10051055

1056+
if (my_rot) {
1057+
close_tlf_rot(my_rot);
1058+
}
1059+
10061060
#ifdef HAVE_LIBXMLRPC
10071061
if (digikeyer == FLDIGI) {
10081062
fldigi_xmlrpc_cleanup();
@@ -1114,6 +1168,7 @@ int main(int argc, char *argv[]) {
11141168
// synclog(synclogfile);
11151169

11161170
hamlib_init();
1171+
hamlib_rot_init();
11171172
fldigi_init();
11181173
lan_init();
11191174
keyer_init();

src/parse_logcfg.c

Lines changed: 5 additions & 0 deletions
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)},
@@ -1384,13 +1385,15 @@ static config_t logcfg_configs[] = {
13841385
{"NETKEYERPORT", CFG_INT(netkeyer_port, 1, INT32_MAX)},
13851386
{"TNCSPEED", CFG_INT(tnc_serial_rate, 0, INT32_MAX)},
13861387
{"RIGSPEED", CFG_INT(serial_rate, 0, INT32_MAX)},
1388+
{"ROTSPEED", CFG_INT(rot_serial_rate, 0, INT32_MAX)},
13871389
{"CQDELAY", CFG_INT(cqdelay, 3, 60)},
13881390
{"SSBPOINTS", CFG_INT(ssbpoints, 0, INT32_MAX)},
13891391
{"CWPOINTS", CFG_INT(cwpoints, 0, INT32_MAX)},
13901392
{"WEIGHT", CFG_INT(weight, -50, 50)},
13911393
{"TXDELAY", CFG_INT(txdelay, 0, 50)},
13921394
{"TUNE_SECONDS", CFG_INT(tune_seconds, 1, 100)},
13931395
{"RIGMODEL", CFG_INT(myrig_model, 0, 99999)},
1396+
{"ROTMODEL", CFG_INT(myrot_model, 0, 99999)},
13941397
{"COUNTRY_LIST_POINTS", CFG_INT(countrylist_points, 0, INT32_MAX)},
13951398
{"MY_COUNTRY_POINTS", CFG_INT(my_country_points, 0, INT32_MAX)},
13961399
{"MY_CONTINENT_POINTS", CFG_INT(my_cont_points, 0, INT32_MAX)},
@@ -1407,6 +1410,7 @@ static config_t logcfg_configs[] = {
14071410
{"RIGPTT", CFG_INT_CONST(rigptt, CAT_PTT_WANTED)},
14081411

14091412
{"RIGCONF", CFG_STRING_STATIC(rigconf, 80)},
1413+
{"ROTCONF", CFG_STRING_STATIC(rotconf, 80)},
14101414
{"LOGFILE", CFG_STRING_STATIC(logfile, 120)},
14111415
{"KEYER_DEVICE", CFG_STRING_STATIC(keyer_device, 10)},
14121416
{"NETKEYERHOST", CFG_STRING_STATIC(netkeyer_hostaddress, 16)},
@@ -1430,6 +1434,7 @@ static config_t logcfg_configs[] = {
14301434
#endif
14311435

14321436
{"RIGPORT", CFG_STRING_NOCHOMP(rigportname)},
1437+
{"ROTPORT", CFG_STRING(rotportname)},
14331438
{"CLUSTERLOGIN", CFG_STRING_STATIC_NOCHOMP(clusterlogin, 80)},
14341439

14351440
{"CALL", NEED_PARAM, cfg_call},

src/qrb.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
*/
2121

22-
#include <hamlib/rotator.h>
23-
2422
#include "globalvars.h"
2523
#include "qrb.h"
2624

0 commit comments

Comments
 (0)