kopia lustrzana https://github.com/Hamlib/Hamlib
This enables netrigctld to trigger two different CAT commands (Mic or DATA)
on the real rig. In rigctl_parse.c, we make sure that invalid attempts to so so are mapped on a safe variant. Second change to netrigctl: drain the input line before sending a new command, to reach sync again after a timeout.astyle-formatting
rodzic
21a6909a9a
commit
4838a349a6
|
@ -32,6 +32,8 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "network.h"
|
||||
#include "serial.h"
|
||||
#include "iofunc.h"
|
||||
#include "misc.h"
|
||||
#include "num_stdio.h"
|
||||
|
@ -50,6 +52,13 @@ static int netrigctl_transaction(RIG *rig, char *cmd, int len, char *buf)
|
|||
{
|
||||
int ret;
|
||||
|
||||
/* flush anything in the read buffer before command is sent */
|
||||
if (rig->state.rigport.type.rig == RIG_PORT_NETWORK || rig->state.rigport.type.rig == RIG_PORT_UDP_NETWORK) {
|
||||
network_flush(&rig->state.rigport);
|
||||
} else {
|
||||
serial_flush(&rig->state.rigport);
|
||||
}
|
||||
|
||||
ret = write_block(&rig->state.rigport, cmd, len);
|
||||
if (ret != RIG_OK)
|
||||
return ret;
|
||||
|
@ -1339,7 +1348,7 @@ const struct rig_caps netrigctl_caps = {
|
|||
.status = RIG_STATUS_BETA,
|
||||
.rig_type = RIG_TYPE_OTHER,
|
||||
.targetable_vfo = 0,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
.ptt_type = RIG_PTT_RIG_MICDATA,
|
||||
.dcd_type = RIG_DCD_RIG,
|
||||
.port_type = RIG_PORT_NETWORK,
|
||||
.timeout = 2000, /* enough for a network */
|
||||
|
|
|
@ -1253,7 +1253,7 @@ int print_conf_list(const struct confparams *cfp, rig_ptr_t data)
|
|||
cfp->u.n.min, cfp->u.n.max, cfp->u.n.step);
|
||||
break;
|
||||
case RIG_CONF_COMBO:
|
||||
if (!cfp->u.c.combostr)
|
||||
if (!cfp->u.c.combostr[0])
|
||||
break;
|
||||
printf("\tCombo: %s", cfp->u.c.combostr[0]);
|
||||
for (i=1 ; i<RIG_COMBO_MAX && cfp->u.c.combostr[i]; i++)
|
||||
|
@ -1487,11 +1487,36 @@ declare_proto_rig(get_vfo)
|
|||
/* 'T' */
|
||||
declare_proto_rig(set_ptt)
|
||||
{
|
||||
int ptt;
|
||||
int scr;
|
||||
ptt_t ptt;
|
||||
|
||||
/* TODO MICDATA */
|
||||
CHKSCN1ARG(sscanf(arg1, "%d", &ptt));
|
||||
return rig_set_ptt(rig, vfo, (ptt_t) ptt);
|
||||
CHKSCN1ARG(sscanf(arg1, "%d", &scr));
|
||||
ptt=scr;
|
||||
/*
|
||||
* We allow RIG_PTT_ON_MIC and RIG_PTT_ON_DATA arriving from netrigctl.
|
||||
* However, if the rig does not have two separate CAT commands, or if
|
||||
* the rig is actually switched by a hardware signal (DTR etc.), then
|
||||
* we map this to RIG_PTT_ON.
|
||||
* Currently, this is not really necessary here because it is taken
|
||||
* case of in rig_set_ptt, but you never know ....
|
||||
*/
|
||||
switch (ptt) {
|
||||
case RIG_PTT_ON_MIC:
|
||||
case RIG_PTT_ON_DATA:
|
||||
// map to a legal value
|
||||
if (rig->state.pttport.type.ptt != RIG_PTT_RIG_MICDATA) ptt=RIG_PTT_ON;
|
||||
break;
|
||||
case RIG_PTT_ON:
|
||||
case RIG_PTT_OFF:
|
||||
// nothing to do
|
||||
break;
|
||||
default:
|
||||
// this case is not handled in hamlib, but we guard against
|
||||
// illegal parameters here. The hamlib behaviour is to switch
|
||||
// on PTT whenever ptt != RIG_PTT_OFF.
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return rig_set_ptt(rig, vfo, ptt);
|
||||
}
|
||||
|
||||
/* 't' */
|
||||
|
@ -1939,6 +1964,7 @@ declare_proto_rig(set_level)
|
|||
switch (cfp->type) {
|
||||
case RIG_CONF_BUTTON:
|
||||
/* arg is ignored */
|
||||
val.i=0; // avoid passing uninitialized data
|
||||
break;
|
||||
case RIG_CONF_CHECKBUTTON:
|
||||
case RIG_CONF_COMBO:
|
||||
|
@ -2105,6 +2131,7 @@ declare_proto_rig(set_parm)
|
|||
switch (cfp->type) {
|
||||
case RIG_CONF_BUTTON:
|
||||
/* arg is ignored */
|
||||
val.i=0; // avoid passing uninitialized data
|
||||
break;
|
||||
case RIG_CONF_CHECKBUTTON:
|
||||
case RIG_CONF_COMBO:
|
||||
|
|
Ładowanie…
Reference in New Issue