Skip to content

Hamlib rotator support #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions share/logcfg.dat
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ CWTONE=800
#
#################################
# #
# ROTATOR CONTROL #
# (comment out if not present) #
# Rigmodel = Hamlib index, here #
# for Yaesu GS-232B #
#################################
#
#ROTATOR_CONTROL
#ROTMODEL=603
#ROTSPEED=9600
#ROTPORT=/dev/ttyUSB3
#
#################################
# #
# INFORMATION WINDOWS #
# #
#################################
Expand Down
8 changes: 8 additions & 0 deletions src/globalvars.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <glib.h>
#include <hamlib/rig.h>
#include <hamlib/rotator.h>
#include <stdbool.h>

#include <config.h>
Expand Down Expand Up @@ -109,10 +110,13 @@ extern int highqsonr;


extern RIG *my_rig;
extern ROT *my_rot;
extern pthread_mutex_t tlf_rig_mutex;
extern pthread_mutex_t tlf_rot_mutex;
extern cqmode_t cqmode;
extern int trxmode;
extern int myrig_model;
extern int myrot_model;
extern rmode_t rigmode;
extern freq_t freq;
extern char lastqsonr[];
Expand Down Expand Up @@ -186,6 +190,7 @@ extern bool keyer_backspace;
extern int netkeyer_port;
extern int cqdelay;
extern int serial_rate;
extern int rot_serial_rate;
extern int tnc_serial_rate;
extern int countrylist_points;
extern int my_country_points;
Expand Down Expand Up @@ -220,6 +225,7 @@ extern char modem_mode[];
extern char sc_volume[];
extern char clusterlogin[];
extern char rigconf[];
extern char rotconf[];
extern char keyer_device[10];
extern char netkeyer_hostaddress[];
extern char pr_hostaddress[];
Expand All @@ -235,6 +241,7 @@ extern char fldigi_url[50];
extern char *cabrillo;
extern char *editor_cmd;
extern char *rigportname;
extern char *rotportname;
extern char *config_file;
#ifdef HAVE_PYTHON
extern char *plugin_config;
Expand All @@ -256,6 +263,7 @@ extern bool ignoredupe;
extern bool continentlist_only;
extern bool debugflag;
extern bool trx_control;
extern bool rot_control;
extern bool nopacket;
extern bool verbose;

Expand Down
8 changes: 8 additions & 0 deletions src/keyer.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "keystroke_names.h"
#include "netkeyer.h"
#include "nicebox.h" // Includes curses.h
#include "qrb.h"
#include "sendbuf.h"
#include "speedupndown.h"
#include "stoptx.h"
Expand Down Expand Up @@ -163,6 +164,13 @@ int handle_common_key(int key) {
break;
}

// Ctrl-D (^D), rotate antenna "d"irection.
case CTRL_D: {
rotate_to_qrb();

break;
}

// Alt-0 to Alt-9 (M-0...M-9), send CW/Digimode messages 15-24.
case 128+'0' ... 128+'9': {
int index = key - (128 + '0') + CQ_TU_MSG + 1;
Expand Down
1 change: 1 addition & 0 deletions src/keystroke_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#define CTRL_A 1
#define CTRL_B 2
#define CTRL_D 4
#define CTRL_E 5
#define CTRL_F 6
#define CTRL_G 7 /* Bell */
Expand Down
58 changes: 57 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <argp.h>
#include <ctype.h>
#include <hamlib/rig.h>
#include <hamlib/rotator.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -50,6 +51,7 @@
#include "netkeyer.h"
#include "parse_logcfg.h"
#include "plugin.h"
#include "qrb.h"
#include "qtcvars.h" // Includes globalvars.h
#include "readctydata.h"
#include "readcalls.h"
Expand Down Expand Up @@ -332,13 +334,13 @@ int nr_of_spots; /* Anzahl Lines in spot_ptr array */
int packetinterface = 0;
int fdSertnc = 0;
char tncportname[40];
char rigconf[80];
int tnc_serial_rate = 2400;
char clusterlogin[80] = "";
bool bmautoadd = false;
bool bmautograb = false;

/*-------------------------------------rigctl-------------------------------*/
char rigconf[80];
int myrig_model = 0; /* unset */
RIG *my_rig; /* handle to rig (instance) */
pthread_mutex_t tlf_rig_mutex = PTHREAD_MUTEX_INITIALIZER;
Expand All @@ -354,6 +356,15 @@ int rignumber = 0;
int rig_comm_error = 0;
int rig_comm_success = 0;

/*-------------------------------------rotctl-------------------------------*/
bool rot_control;
int myrot_model; /* unset */
char rotconf[80];
ROT *my_rot; /* handle to rotator (instance) */
pthread_mutex_t tlf_rot_mutex = PTHREAD_MUTEX_INITIALIZER;
int rot_serial_rate;
char *rotportname;

/*----------------------------------fldigi---------------------------------*/
char fldigi_url[50] = "http://localhost:7362/RPC2";

Expand Down Expand Up @@ -419,6 +430,7 @@ char itustr[3];

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

int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
Expand Down Expand Up @@ -449,6 +461,7 @@ static const struct argp_option options[] = {
{"import", 'i', 0, 0, "Import Cabrillo file to Tlf format"},
{"no-cluster", 'n', 0, 0, "Start without cluster hookup" },
{"no-rig", 'r', 0, 0, "Start without radio control" },
{"no-rotator", 'R', 0, 0, "Start without radio control" },
{"list", 'l', 0, 0, "List built-in contests" },
{"sync", 's', "URL", 0, "Synchronize log with other node" },
{"debug", 'd', 0, 0, "Debug mode" },
Expand All @@ -472,6 +485,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'r':
trx_control_disabled = true; // disable radio control
break;
case 'R':
rot_control_disabled = true; // disable rotator control
break;
case 'i':
convert_cabrillo = true;
break;
Expand Down Expand Up @@ -658,6 +674,11 @@ static void init_variables() {
rig_mode_sync = true;
use_bandoutput = false;

/* rotctl */
rot_control = false;
myrot_model = 0; /* unset */
rot_serial_rate = 2400;

lan_active = false;
thisnode = 'A';
lan_port = 6788;
Expand Down Expand Up @@ -800,6 +821,36 @@ static void hamlib_init() {
}
}

static void hamlib_rot_init() {

if (rot_control_disabled) {
rot_control = false;
}

if (!rot_control) {
return;
}

shownr("Rotator model number is", myrot_model);
shownr("Rotator speed is", rot_serial_rate);

showmsg("Trying to start rotator control");

int status = init_tlf_rot();

if (status != 0) {
showmsg("Continue without rotator control Y/(N)?");
if (toupper(key_get()) != 'Y') {
endwin();
exit(1);
}
rot_control = false;
rot_control_disabled = true;
showmsg("Disabling rotator control!");
sleep(1);
}
}

static void fldigi_init() {
#ifdef HAVE_LIBXMLRPC
int status;
Expand Down Expand Up @@ -991,6 +1042,10 @@ static void tlf_cleanup() {
close_tlf_rig(my_rig);
}

if (my_rot) {
close_tlf_rot(my_rot);
}

#ifdef HAVE_LIBXMLRPC
if (digikeyer == FLDIGI) {
fldigi_xmlrpc_cleanup();
Expand Down Expand Up @@ -1098,6 +1153,7 @@ int main(int argc, char *argv[]) {
// synclog(synclogfile);

hamlib_init();
hamlib_rot_init();
fldigi_init();
lan_init();
keyer_init();
Expand Down
5 changes: 5 additions & 0 deletions src/parse_logcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1299,6 +1299,7 @@ static config_t logcfg_configs[] = {
{"IGNOREDUPE", CFG_BOOL(ignoredupe)},
{"USE_CONTINENTLIST_ONLY", CFG_BOOL(continentlist_only)},
{"RADIO_CONTROL", CFG_BOOL(trx_control)},
{"ROTATOR_CONTROL", CFG_BOOL(rot_control)},
{"PORTABLE_MULT_2", CFG_BOOL(portable_x2)},

{"USEPARTIALS", CFG_BOOL(use_part)},
Expand Down Expand Up @@ -1383,13 +1384,15 @@ static config_t logcfg_configs[] = {
{"NETKEYERPORT", CFG_INT(netkeyer_port, 1, INT32_MAX)},
{"TNCSPEED", CFG_INT(tnc_serial_rate, 0, INT32_MAX)},
{"RIGSPEED", CFG_INT(serial_rate, 0, INT32_MAX)},
{"ROTSPEED", CFG_INT(rot_serial_rate, 0, INT32_MAX)},
{"CQDELAY", CFG_INT(cqdelay, 3, 60)},
{"SSBPOINTS", CFG_INT(ssbpoints, 0, INT32_MAX)},
{"CWPOINTS", CFG_INT(cwpoints, 0, INT32_MAX)},
{"WEIGHT", CFG_INT(weight, -50, 50)},
{"TXDELAY", CFG_INT(txdelay, 0, 50)},
{"TUNE_SECONDS", CFG_INT(tune_seconds, 1, 100)},
{"RIGMODEL", CFG_INT(myrig_model, 0, 99999)},
{"ROTMODEL", CFG_INT(myrot_model, 0, 99999)},
{"COUNTRY_LIST_POINTS", CFG_INT(countrylist_points, 0, INT32_MAX)},
{"MY_COUNTRY_POINTS", CFG_INT(my_country_points, 0, INT32_MAX)},
{"MY_CONTINENT_POINTS", CFG_INT(my_cont_points, 0, INT32_MAX)},
Expand All @@ -1406,6 +1409,7 @@ static config_t logcfg_configs[] = {
{"RIGPTT", CFG_INT_CONST(rigptt, CAT_PTT_WANTED)},

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

{"RIGPORT", CFG_STRING_NOCHOMP(rigportname)},
{"ROTPORT", CFG_STRING_NOCHOMP(rotportname)},
{"CLUSTERLOGIN", CFG_STRING_STATIC_NOCHOMP(clusterlogin, 80)},

{"CALL", NEED_PARAM, cfg_call},
Expand Down
Loading
Loading