Skip to content
Merged
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
164 changes: 147 additions & 17 deletions src/gtk-rig-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ static void start_timer(GtkRigCtrl * data);

static GtkBoxClass *parent_class = NULL;


static void gtk_rig_ctrl_destroy(GtkWidget * widget)
{
GtkRigCtrl *ctrl = GTK_RIG_CTRL(widget);
Expand Down Expand Up @@ -717,7 +716,7 @@ static void trsp_tune_cb(GtkButton * button, gpointer data)
if ((ctrl->trsp->downlow > 0) && (ctrl->trsp->downhigh > 0))
{
freq = ctrl->trsp->downlow +
abs(ctrl->trsp->downhigh - ctrl->trsp->downlow) / 2;
labs((long)ctrl->trsp->downhigh - (long)ctrl->trsp->downlow) / 2;
gtk_freq_knob_set_value(GTK_FREQ_KNOB(ctrl->SatFreqDown), freq);

/* invalidate RIG<->GPREDICT sync */
Expand All @@ -728,7 +727,7 @@ static void trsp_tune_cb(GtkButton * button, gpointer data)
if ((ctrl->trsp->uplow > 0) && (ctrl->trsp->uphigh > 0))
{
freq = ctrl->trsp->uplow +
abs(ctrl->trsp->uphigh - ctrl->trsp->uplow) / 2;
labs((long)ctrl->trsp->uphigh - (long)ctrl->trsp->uplow) / 2;
gtk_freq_knob_set_value(GTK_FREQ_KNOB(ctrl->SatFreqUp), freq);

/* invalidate RIG<->GPREDICT sync */
Expand Down Expand Up @@ -1004,6 +1003,7 @@ static void rig_engaged_cb(GtkToggleButton * button, gpointer data)
ctrl->rigctl_thread = g_thread_new("rigctl_run", rigctl_run, ctrl);
setconfig(ctrl);
}
ctrl->conf2 = NULL;
}

static GtkWidget *create_target_widgets(GtkRigCtrl * ctrl)
Expand Down Expand Up @@ -1489,29 +1489,79 @@ static inline gboolean check_get_response(gchar * buffback, gboolean retcode,
return retcode;
}

static int get_vfos(GtkRigCtrl * ctrl, char *rx, char *tx)
{
// fill rx/tx with vfo name plus space if not empty
rx = tx = "";
switch (ctrl->conf->vfoUp)
{
case VFO_A:
if (ctrl->conf->vfo_opt)
{rx = "VFOB ";tx = "VFOA ";}
break;

case VFO_B:
if (ctrl->conf->vfo_opt)
{rx = "VFOA ";tx = "VFOB ";}
break;

case VFO_MAIN:
if (ctrl->conf->vfo_opt)
{rx = "Sub";tx = "Main";}
break;

case VFO_SUB:
if (ctrl->conf->vfo_opt)
{rx = "Main";tx = "Sub";}
break;

default:
sat_log_log(SAT_LOG_LEVEL_ERROR,
_("%s called but TX VFO is %d and we don't know how to handle it."), __func__,
ctrl->conf->vfoUp);
return 1;
}
sat_log_log(SAT_LOG_LEVEL_DEBUG, "rx=%x, tx=%s\n", rx, tx);
return 0;
}

/* Setup VFOs for split operation (simplex or duplex) */
static gboolean setup_split(GtkRigCtrl * ctrl)
{
gchar *buff;
gchar buffback[256];
gboolean retcode;
gchar *rx="", *tx="";

get_vfos(ctrl, rx, tx);
switch (ctrl->conf->vfoUp)
{
case VFO_A:
buff = g_strdup("S 1 VFOA\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup("S VFOB 1 VFOA\x0a");
else
buff = g_strdup("S 1 VFOA\x0a");
break;

case VFO_B:
buff = g_strdup("S 1 VFOB\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup("S VFOA 1 VFOB\x0a");
else
buff = g_strdup("S 1 VFOB\x0a");
break;

case VFO_MAIN:
buff = g_strdup("S 1 Main\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup("S Sub 1 Main\x0a");
else
buff = g_strdup("S 1 Main\x0a");
break;

case VFO_SUB:
buff = g_strdup("S 1 Sub\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup("S Main 1 Sub\x0a");
else
buff = g_strdup("S 1 Sub\x0a");
break;

default:
Expand Down Expand Up @@ -2253,12 +2303,18 @@ static gboolean get_ptt(GtkRigCtrl * ctrl, gint sock)
if (ctrl->conf->ptt == PTT_TYPE_CAT)
{
/* send command get_ptt (t) */
buff = g_strdup_printf("t\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("t currVFO\x0a");
else
buff = g_strdup_printf("t\x0a");
}
else
{
/* send command \get_dcd */
buff = g_strdup_printf("%c\x0a", 0x8b);
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("%c currVFO\x0a", 0x8b);
else
buff = g_strdup_printf("%c\x0a", 0x8b);
}

retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
Expand All @@ -2282,10 +2338,20 @@ static gboolean set_ptt(GtkRigCtrl * ctrl, gint sock, gboolean ptt)
gboolean retcode;

/* send command */
if (ptt == TRUE)
buff = g_strdup_printf("T 1\x0aq\x0a");
if (ptt == TRUE)
{
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("T currVFO 1\x0aq\x0a");
else
buff = g_strdup_printf("T 1\x0aq\x0a");
}
else
buff = g_strdup_printf("T 0\x0aq\x0a");
{
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("T currVFO 0\x0aq\x0a");
else
buff = g_strdup_printf("T 0\x0aq\x0a");
}

retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
g_free(buff);
Expand Down Expand Up @@ -2363,7 +2429,10 @@ static gboolean set_freq_simplex(GtkRigCtrl * ctrl, gint sock, gdouble freq)
gchar buffback[128];
gboolean retcode;

buff = g_strdup_printf("F %10.0f\x0a", freq);
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("F currVFO %10.0f\x0a", freq);
else
buff = g_strdup_printf("F %10.0f\x0a", freq);
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
g_free(buff);

Expand All @@ -2383,7 +2452,12 @@ static gboolean set_freq_toggle(GtkRigCtrl * ctrl, gint sock, gdouble freq)
gboolean retcode;

/* send command */
buff = g_strdup_printf("I %10.0f\x0a", freq);
printf("set_freq_toggle %d\n", ctrl->conf->vfo_opt);
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("I VFOA %10.0f\x0a", freq);
else
buff = g_strdup_printf("I %10.0f\x0a", freq);

retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
g_free(buff);

Expand All @@ -2402,6 +2476,9 @@ static gboolean set_toggle(GtkRigCtrl * ctrl, gint sock)
gchar buffback[128];
gboolean retcode;

if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("S %s 1 %d\x0a", ctrl->conf->vfoDown==VFO_A?"VFOA":"VFOB", ctrl->conf->vfoDown);
else
buff = g_strdup_printf("S 1 %d\x0a", ctrl->conf->vfoDown);
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
g_free(buff);
Expand All @@ -2421,7 +2498,10 @@ static gboolean unset_toggle(GtkRigCtrl * ctrl, gint sock)
gboolean retcode;

/* send command */
buff = g_strdup_printf("S 0 %d\x0a", ctrl->conf->vfoDown);
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("S VFOA 0 %d\x0a", ctrl->conf->vfoDown);
else
buff = g_strdup_printf("S 0 %d\x0a", ctrl->conf->vfoDown);
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
g_free(buff);

Expand All @@ -2440,7 +2520,10 @@ static gboolean get_freq_simplex(GtkRigCtrl * ctrl, gint sock, gdouble * freq)
gboolean retcode;
gboolean retval = TRUE;

buff = g_strdup_printf("f\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("f currVFO\x0a");
else
buff = g_strdup_printf("f\x0a");
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
retcode = check_get_response(buffback, retcode, __func__);
if (retcode)
Expand All @@ -2461,6 +2544,39 @@ static gboolean get_freq_simplex(GtkRigCtrl * ctrl, gint sock, gdouble * freq)
return retval;
}

/*
* Get vfo option
*
* Returns TRUE if the vfo option enabled was successful, FALSE otherwise
*/
static gboolean get_vfo_opt(GtkRigCtrl * ctrl, gint sock)
{
gchar *buff;
gchar buffback[128];
gboolean retcode;
gboolean retval = TRUE;

buff = g_strdup_printf("\\set_vfo_opt 1\x0a");
send_rigctld_command(ctrl, sock, buff, buffback, 128);
// we don't really care about the return from set_vto_opt
// we'll check to see if it worked next
buff = g_strdup_printf("\\chk_vfo\x0a");
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
retcode = check_get_response(buffback, retcode, __func__);
if (retcode)
{
if (buffback[0]=='1') return TRUE;
else return FALSE;
}
else
{
retval = FALSE;
}

g_free(buff);
return retval;
}

/*
* Get frequency when the radio is working toggle
*
Expand All @@ -2481,7 +2597,10 @@ static gboolean get_freq_toggle(GtkRigCtrl * ctrl, gint sock, gdouble * freq)
}

/* send command */
buff = g_strdup_printf("i\x0a");
if (ctrl->conf->vfo_opt)
buff = g_strdup_printf("i currVFO\x0a");
else
buff = g_strdup_printf("i\x0a");
retcode = send_rigctld_command(ctrl, sock, buff, buffback, 128);
retcode = check_get_response(buffback, retcode, __func__);
if (retcode)
Expand Down Expand Up @@ -2730,11 +2849,22 @@ static void rigctrl_open(GtkRigCtrl * data)

open_rigctld_socket(ctrl->conf, &(ctrl->sock));

// check to see if vfo option is enabled
ctrl->conf->vfo_opt = get_vfo_opt(ctrl, ctrl->sock);
sat_log_log(SAT_LOG_LEVEL_DEBUG,
_("%s:%s: VFO opt=%d"), __FILE__,
__func__, ctrl->conf->vfo_opt);

/* set initial frequency */
if (ctrl->conf2 != NULL)
{
open_rigctld_socket(ctrl->conf2, &(ctrl->sock2));
/* set initial dual mode */
ctrl->conf2->vfo_opt = get_vfo_opt(ctrl, ctrl->sock);
sat_log_log(SAT_LOG_LEVEL_DEBUG,
_("%s:%s: VFO opt2=%d"), __FILE__,
__func__, ctrl->conf2->vfo_opt);

exec_dual_rig_cycle(ctrl);
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/radio-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ typedef struct {

gboolean signal_aos; /*!< Send AOS notification to RIG */
gboolean signal_los; /*!< Send LOS notification to RIG */

gint vfo_opt; /*!< Keep track of vfo_opt being enabled in rigctld */
} radio_conf_t;


Expand Down
8 changes: 4 additions & 4 deletions src/tle-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ static gint read_fresh_tle(const gchar * dir, const gchar * fnam,
case 1:
strncpy(tle_working[0], tle_working[1], 80);
strncpy(tle_working[1], tle_working[2], 80);
strncpy(tle_working[2], linetmp, 80);
memcpy(tle_working[2], linetmp, 80);
tle_working[2][79] = 0; // make coverity happy
break;
default:
Expand Down Expand Up @@ -965,10 +965,10 @@ static gint read_fresh_tle(const gchar * dir, const gchar * fnam,
/* put in a dummy name of form yyyy-nnaa base on international id */
/* this special form will be overwritten if a three line tle ever has another name */

strncpy(idstr, &tle_working[0][11], 6);
memcpy(idstr, &tle_working[0][11], 6);
g_strstrip(idstr);
strncpy(idyearstr, &tle_working[0][9], 2);
idstr[6] = '\0';
memcpy(idyearstr, &tle_working[0][9], 2);
idstr[6] = 0;
idyearstr[2] = '\0';
idyear = g_ascii_strtod(idyearstr, NULL);

Expand Down