Skip to content

Commit 46afb1a

Browse files
committed
Hamlib rotator support
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 bf70155 commit 46afb1a

File tree

13 files changed

+362
-4
lines changed

13 files changed

+362
-4
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 "tlf.h"
@@ -143,6 +144,20 @@ int handle_common_key(int key) {
143144
break;
144145
}
145146

147+
// Rotate antenna to short path
148+
case '^': {
149+
rotate_to_qrb(false);
150+
151+
break;
152+
}
153+
154+
// Rotate antenna to long path
155+
case '&': {
156+
rotate_to_qrb(true);
157+
158+
break;
159+
}
160+
146161
// <Page-Up>, change RST if call field not empty, else increase CW speed.
147162
case KEY_PPAGE: {
148163
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>
@@ -333,13 +334,13 @@ int nr_of_spots; /* Anzahl Lines in spot_ptr array */
333334
int packetinterface = 0;
334335
int fdSertnc = 0;
335336
char tncportname[40];
336-
char rigconf[80];
337337
int tnc_serial_rate = 2400;
338338
char clusterlogin[80] = "";
339339
bool bmautoadd = false;
340340
bool bmautograb = false;
341341

342342
/*-------------------------------------rigctl-------------------------------*/
343+
char rigconf[80];
343344
int myrig_model = 0; /* unset */
344345
RIG *my_rig; /* handle to rig (instance) */
345346
pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -355,6 +356,15 @@ int rignumber = 0;
355356
int rig_comm_error = 0;
356357
int rig_comm_success = 0;
357358

359+
/*-------------------------------------rotctl-------------------------------*/
360+
bool rot_control;
361+
int myrot_model; /* 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;
366+
char *rotportname;
367+
358368
/*----------------------------------fldigi---------------------------------*/
359369
char fldigi_url[50] = "http://localhost:7362/RPC2";
360370

@@ -420,6 +430,7 @@ char itustr[3];
420430

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

425436
int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
@@ -450,6 +461,7 @@ static const struct argp_option options[] = {
450461
{"import", 'i', 0, 0, "Import Cabrillo file to Tlf format"},
451462
{"no-cluster", 'n', 0, 0, "Start without cluster hookup" },
452463
{"no-rig", 'r', 0, 0, "Start without radio control" },
464+
{"no-rotator", 'R', 0, 0, "Start without radio control" },
453465
{"list", 'l', 0, 0, "List built-in contests" },
454466
{"sync", 's', "URL", 0, "Synchronize log with other node" },
455467
{
@@ -476,6 +488,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
476488
case 'r':
477489
trx_control_disabled = true; // disable radio control
478490
break;
491+
case 'R':
492+
rot_control_disabled = true; // disable rotator control
493+
break;
479494
case 'i':
480495
convert_cabrillo = true;
481496
break;
@@ -664,6 +679,11 @@ static void init_variables() {
664679
rig_mode_sync = true;
665680
use_bandoutput = false;
666681

682+
/* rotctl */
683+
rot_control = false;
684+
myrot_model = 0; /* unset */
685+
rot_serial_rate = 2400;
686+
667687
lan_active = false;
668688
thisnode = 'A';
669689
lan_port = 6788;
@@ -808,6 +828,36 @@ static void hamlib_init() {
808828
}
809829
}
810830

831+
static void hamlib_rot_init() {
832+
833+
if (rot_control_disabled) {
834+
rot_control = false;
835+
}
836+
837+
if (!rot_control) {
838+
return;
839+
}
840+
841+
shownr("Rotator model number is", myrot_model);
842+
shownr("Rotator speed is", rot_serial_rate);
843+
844+
showmsg("Trying to start rotator control");
845+
846+
int status = init_tlf_rot();
847+
848+
if (status != 0) {
849+
showmsg("Continue without rotator control Y/(N)?");
850+
if (toupper(key_get()) != 'Y') {
851+
endwin();
852+
exit(1);
853+
}
854+
rot_control = false;
855+
rot_control_disabled = true;
856+
showmsg("Disabling rotator control!");
857+
sleep(1);
858+
}
859+
}
860+
811861
static void fldigi_init() {
812862
#ifdef HAVE_LIBXMLRPC
813863
int status;
@@ -999,6 +1049,10 @@ static void tlf_cleanup() {
9991049
close_tlf_rig(my_rig);
10001050
}
10011051

1052+
if (my_rot) {
1053+
close_tlf_rot(my_rot);
1054+
}
1055+
10021056
#ifdef HAVE_LIBXMLRPC
10031057
if (digikeyer == FLDIGI) {
10041058
fldigi_xmlrpc_cleanup();
@@ -1110,6 +1164,7 @@ int main(int argc, char *argv[]) {
11101164
// synclog(synclogfile);
11111165

11121166
hamlib_init();
1167+
hamlib_rot_init();
11131168
fldigi_init();
11141169
lan_init();
11151170
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)},
@@ -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},

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)