kopia lustrzana https://github.com/Hamlib/Hamlib
Fix CODAN 2110 -- correct model# and all the minor changes to the CICS protocol
rodzic
e93d368fcb
commit
84c656edd1
2
NEWS
2
NEWS
|
@ -14,7 +14,7 @@ Version 5.x -- future
|
|||
|
||||
Version 4.6.3
|
||||
* Fix rigctl showing hamlib_verson when connecting to rigctld
|
||||
* Add rig CODAN 2021
|
||||
* Add rig CODAN 2110
|
||||
|
||||
Version 4.6.2
|
||||
* Add missing levels for IC746/PRO RIG_LEVEL_RFPOWER_METER,RIG_LEVEL_RFPOWER_METER_WATTS,RIG_LEVEL_SWR,RIG_LEVEL_ALC
|
||||
|
|
|
@ -657,7 +657,7 @@
|
|||
#define RIG_BACKEND_CODAN "codan"
|
||||
#define RIG_MODEL_CODAN_ENVOY RIG_MAKE_MODEL(RIG_CODAN, 1)
|
||||
#define RIG_MODEL_CODAN_NGT RIG_MAKE_MODEL(RIG_CODAN, 2)
|
||||
#define RIG_MODEL_CODAN_2021 RIG_MAKE_MODEL(RIG_CODAN, 3)
|
||||
#define RIG_MODEL_CODAN_2110 RIG_MAKE_MODEL(RIG_CODAN, 3)
|
||||
|
||||
/*
|
||||
* Gomspace
|
||||
|
|
|
@ -48,21 +48,21 @@ int codan_transaction(RIG *rig, char *cmd, int expected, char **result)
|
|||
int retval;
|
||||
hamlib_port_t *rp = RIGPORT(rig);
|
||||
struct codan_priv_data *priv = STATE(rig)->priv;
|
||||
//int retry = 3;
|
||||
int retry = 3;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
|
||||
|
||||
// Seems the 2021 wants LF instead of CR
|
||||
if (rig->caps->rig_model == RIG_MODEL_CODAN_2021)
|
||||
// Seems the 2110 wants CR instead of LF
|
||||
if (rig->caps->rig_model == RIG_MODEL_CODAN_2110)
|
||||
{
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%d", cmd, 0x0a);
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%c", cmd, 0x0d);
|
||||
}
|
||||
else
|
||||
{
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%d", cmd, 0x0d);
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s%c", cmd, 0x0a);
|
||||
}
|
||||
|
||||
rig_flush(rp);
|
||||
repeat:
|
||||
retval = write_block(rp, (unsigned char *) cmd_buf, strlen(cmd_buf));
|
||||
hl_usleep(rig->caps->post_write_delay);
|
||||
|
||||
|
@ -83,6 +83,10 @@ again1:
|
|||
|
||||
if (strncmp(cmd, priv->ret_data, strlen(cmd)) == 0) { goto again1; }
|
||||
|
||||
if (strstr(priv->ret_data, "ERROR") && --retry > 0) { goto repeat; }
|
||||
|
||||
if (strstr(priv->ret_data, "CHAN") && --retry > 0) { goto again1; }
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
return retval;
|
||||
|
@ -97,6 +101,10 @@ again2:
|
|||
|
||||
if (strncmp(cmd, priv->ret_data, strlen(cmd)) == 0) { goto again2; }
|
||||
|
||||
if (strstr(priv->ret_data, "ERROR") && --retry > 0) { goto repeat; }
|
||||
|
||||
if (strstr(priv->ret_data, "CHAN")) { goto again2; }
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
return retval;
|
||||
|
@ -162,6 +170,28 @@ int codan_init(RIG *rig)
|
|||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
||||
int codan_set_freq_2110(RIG *rig, vfo_t vfo, freq_t freq)
|
||||
{
|
||||
char cmd_buf[MAXCMDLEN];
|
||||
int retval;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s freq=%.0f\n", __func__,
|
||||
rig_strvfo(vfo), freq);
|
||||
|
||||
// Purportedly can't do split so we just set VFOB=VFOA
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "\rfreq %.0f", freq / 1000);
|
||||
|
||||
char *response = NULL;
|
||||
retval = codan_transaction(rig, cmd_buf, 0, &response);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
return retval;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int codan_open(RIG *rig)
|
||||
{
|
||||
char *results = NULL;
|
||||
|
@ -176,7 +206,15 @@ int codan_open(RIG *rig)
|
|||
}
|
||||
|
||||
codan_transaction(rig, "login", 1, &results);
|
||||
codan_set_freq(rig, RIG_VFO_A, 14074000.0);
|
||||
|
||||
if (rig->caps->rig_model == RIG_MODEL_CODAN_2110)
|
||||
{
|
||||
codan_set_freq_2110(rig, RIG_VFO_A, 14074000.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
codan_set_freq(rig, RIG_VFO_A, 14074000.0);
|
||||
}
|
||||
|
||||
RETURNFUNC2(RIG_OK);
|
||||
}
|
||||
|
@ -393,6 +431,38 @@ int codan_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
int codan_get_ptt_2110(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||
{
|
||||
int retval;
|
||||
char *response = NULL;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo));
|
||||
|
||||
retval = codan_transaction(rig, "ptt", 0, &response);
|
||||
|
||||
if (retval != RIG_OK)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: error response?='%s'\n", __func__, response);
|
||||
return retval;
|
||||
}
|
||||
|
||||
const char *p = strstr(response, "PTT");
|
||||
|
||||
if (p)
|
||||
{
|
||||
if (strstr(p, "OFF")) { *ptt = 0; }
|
||||
else { *ptt = 1; }
|
||||
}
|
||||
else
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: unable to find Ptt in %s\n", __func__, response);
|
||||
return -RIG_EPROTO;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* codan_set_ptt
|
||||
* Assumes rig!=NULL
|
||||
|
@ -421,6 +491,32 @@ int codan_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
int codan_set_ptt_2110(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||
{
|
||||
int retval;
|
||||
char cmd_buf[MAXCMDLEN];
|
||||
char *response;
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: ptt=%d\n", __func__, ptt);
|
||||
|
||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "ptt %s",
|
||||
ptt == 0 ? "off" : "on");
|
||||
response = NULL;
|
||||
retval = codan_transaction(rig, cmd_buf, 0, &response);
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
rig_debug(RIG_DEBUG_ERR, "%s: invalid response=%s\n", __func__, response);
|
||||
return retval;
|
||||
}
|
||||
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd result=%s\n", __func__, response);
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -552,14 +648,14 @@ struct rig_caps codan_ngs_caps =
|
|||
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
|
||||
};
|
||||
|
||||
struct rig_caps codan_2021_caps =
|
||||
struct rig_caps codan_2110_caps =
|
||||
{
|
||||
RIG_MODEL(RIG_MODEL_CODAN_2021),
|
||||
.model_name = "2021",
|
||||
RIG_MODEL(RIG_MODEL_CODAN_2110),
|
||||
.model_name = "2110",
|
||||
.mfg_name = "CODAN",
|
||||
.version = BACKEND_VER ".0",
|
||||
.copyright = "LGPL",
|
||||
.status = RIG_STATUS_ALPHA,
|
||||
.status = RIG_STATUS_STABLE,
|
||||
.rig_type = RIG_TYPE_TRANSCEIVER,
|
||||
.targetable_vfo = RIG_TARGETABLE_FREQ,
|
||||
.ptt_type = RIG_PTT_RIG,
|
||||
|
@ -603,15 +699,16 @@ struct rig_caps codan_2021_caps =
|
|||
.priv = NULL,
|
||||
|
||||
.rig_init = codan_init,
|
||||
.rig_open = codan_open,
|
||||
.rig_cleanup = codan_cleanup,
|
||||
|
||||
.set_freq = codan_set_freq,
|
||||
.set_freq = codan_set_freq_2110,
|
||||
.get_freq = codan_get_freq,
|
||||
.set_mode = codan_set_mode,
|
||||
.get_mode = codan_get_mode,
|
||||
|
||||
.set_ptt = codan_set_ptt,
|
||||
.get_ptt = codan_get_ptt,
|
||||
.set_ptt = codan_set_ptt_2110,
|
||||
.get_ptt = codan_get_ptt_2110,
|
||||
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
|
||||
};
|
||||
|
||||
|
@ -621,7 +718,7 @@ DECLARE_INITRIG_BACKEND(codan)
|
|||
|
||||
rig_register(&codan_envoy_caps);
|
||||
rig_register(&codan_ngs_caps);
|
||||
rig_register(&codan_2021_caps);
|
||||
rig_register(&codan_2110_caps);
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: _init back from rig_register\n", __func__);
|
||||
|
||||
return RIG_OK;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "hamlib/rig.h"
|
||||
|
||||
#define BACKEND_VER "20240318"
|
||||
#define BACKEND_VER "20250216"
|
||||
|
||||
#define EOM "\x0d"
|
||||
#define TRUE 1
|
||||
|
|
Ładowanie…
Reference in New Issue