Convert rigs/flexradio, rigs/gomspace, rigs/jrc, rigs/kachina

pull/1508/head
George Baltz N3GB 2024-01-30 13:42:28 -05:00
rodzic 1e552b557f
commit c7ab5c44af
8 zmienionych plików z 57 dodań i 62 usunięć

Wyświetl plik

@ -328,7 +328,7 @@ static int send_command(RIG *rig, const char *cmdstr, size_t buflen)
{ {
int ret; int ret;
ret = write_block(&rig->state.rigport, (unsigned char *) cmdstr, buflen); ret = write_block(RIGPORT(rig), (unsigned char *) cmdstr, buflen);
return ret; return ret;
} }
@ -481,6 +481,7 @@ int dttsp_get_conf(RIG *rig, hamlib_token_t token, char *val)
int dttsp_init(RIG *rig) int dttsp_init(RIG *rig)
{ {
struct dttsp_priv_data *priv; struct dttsp_priv_data *priv;
hamlib_port_t *rp = RIGPORT(rig);
const char *cmdpath; const char *cmdpath;
char *p; char *p;
@ -515,10 +516,10 @@ int dttsp_init(RIG *rig)
cmdpath = getenv("SDR_PARMPATH"); cmdpath = getenv("SDR_PARMPATH");
if (!cmdpath) if (!cmdpath)
cmdpath = rig->state.rigport.type.rig == RIG_PORT_UDP_NETWORK ? cmdpath = rp->type.rig == RIG_PORT_UDP_NETWORK ?
DEFAULT_DTTSP_CMD_NET_ADDR : DEFAULT_DTTSP_CMD_PATH; DEFAULT_DTTSP_CMD_NET_ADDR : DEFAULT_DTTSP_CMD_PATH;
strncpy(rig->state.rigport.pathname, cmdpath, HAMLIB_FILPATHLEN - 1); strncpy(rp->pathname, cmdpath, HAMLIB_FILPATHLEN - 1);
return RIG_OK; return RIG_OK;
} }
@ -530,6 +531,7 @@ int dttsp_open(RIG *rig)
int ret; int ret;
char *p; char *p;
char *meterpath; char *meterpath;
hamlib_port_t *rp = RIGPORT(rig);
rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__);
@ -561,18 +563,18 @@ int dttsp_open(RIG *rig)
} }
/* open DttSP meter pipe */ /* open DttSP meter pipe */
priv->meter_port.post_write_delay = rig->state.rigport.post_write_delay; priv->meter_port.post_write_delay = rp->post_write_delay;
priv->meter_port.timeout = rig->state.rigport.timeout; priv->meter_port.timeout = rp->timeout;
priv->meter_port.retry = rig->state.rigport.retry; priv->meter_port.retry = rp->retry;
p = getenv("SDR_METERPATH"); p = getenv("SDR_METERPATH");
if (!p) if (!p)
{ {
meterpath = priv->meter_port.pathname; meterpath = priv->meter_port.pathname;
SNPRINTF(meterpath, HAMLIB_FILPATHLEN, "%s", rig->state.rigport.pathname); SNPRINTF(meterpath, HAMLIB_FILPATHLEN, "%s", rp->pathname);
if (rig->state.rigport.type.rig == RIG_PORT_UDP_NETWORK) if (rp->type.rig == RIG_PORT_UDP_NETWORK)
{ {
p = strrchr(meterpath, ':'); p = strrchr(meterpath, ':');
@ -605,7 +607,7 @@ int dttsp_open(RIG *rig)
} }
else else
{ {
priv->meter_port.type.rig = rig->state.rigport.type.rig; priv->meter_port.type.rig = rp->type.rig;
ret = port_open(&priv->meter_port); ret = port_open(&priv->meter_port);
if (ret < 0) if (ret < 0)

Wyświetl plik

@ -216,7 +216,7 @@ int sdr1k_init(RIG *rig)
static void pdelay(RIG *rig) static void pdelay(RIG *rig)
{ {
unsigned char r; unsigned char r;
par_read_data(&rig->state.rigport, &r); /* ~1us */ par_read_data(RIGPORT(rig), &r); /* ~1us */
} }
int sdr1k_open(RIG *rig) int sdr1k_open(RIG *rig)
@ -453,7 +453,7 @@ int
write_latch(RIG *rig, latch_t which, unsigned value, unsigned mask) write_latch(RIG *rig, latch_t which, unsigned value, unsigned mask)
{ {
struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv; struct sdr1k_priv_data *priv = (struct sdr1k_priv_data *)rig->state.priv;
hamlib_port_t *pport = &rig->state.rigport; hamlib_port_t *pport = RIGPORT(rig);
if (!(L_EXT <= which && which <= L_DDS1)) if (!(L_EXT <= which && which <= L_DDS1))
{ {

Wyświetl plik

@ -110,7 +110,7 @@ static int gs100_init(RIG *rig)
rig->state.priv = (void *)priv; rig->state.priv = (void *)priv;
#ifdef _LOCAL_SIMULATION_ #ifdef _LOCAL_SIMULATION_
rig->state.rigport.type.rig = RIG_PORT_NONE; // just simulation RIGPORT(rig)->type.rig = RIG_PORT_NONE; // just simulation
priv->freq_rx = rig->caps->rx_range_list1->startf; priv->freq_rx = rig->caps->rx_range_list1->startf;
priv->freq_tx = rig->caps->tx_range_list1->startf; priv->freq_tx = rig->caps->tx_range_list1->startf;
#endif #endif
@ -520,7 +520,7 @@ static int gomx_get(RIG *rig, int table, char *varname, const char *varvalue,
/* Sends a message to the GS100 and parses response lines */ /* Sends a message to the GS100 and parses response lines */
static int gomx_transaction(RIG *rig, char *message, char *response) static int gomx_transaction(RIG *rig, char *message, char *response)
{ {
struct rig_state *rs; hamlib_port_t *rp;
int retval, n = 0; int retval, n = 0;
char buf[BUFSZ]; char buf[BUFSZ];
@ -531,18 +531,18 @@ static int gomx_transaction(RIG *rig, char *message, char *response)
rig_debug(RIG_DEBUG_TRACE, "%s: msg='%s'\n", __func__, rig_debug(RIG_DEBUG_TRACE, "%s: msg='%s'\n", __func__,
message == NULL ? "NULL" : message); message == NULL ? "NULL" : message);
rs = &rig->state; rp = RIGPORT(rig);
// send message to the transceiver // send message to the transceiver
rig_flush(&rs->rigport); rig_flush(rp);
retval = write_block(&rs->rigport, (uint8_t *)message, strlen(message)); retval = write_block(rp, (uint8_t *)message, strlen(message));
if (retval != RIG_OK) { return (retval); } if (retval != RIG_OK) { return (retval); }
while (1) while (1)
{ {
// read the response line // read the response line
retval = read_string(&rs->rigport, (unsigned char *)buf, BUFSZ, retval = read_string(rp, (unsigned char *)buf, BUFSZ,
(const char *)GOM_STOPSET, 0, strlen(GOM_STOPSET), 0); (const char *)GOM_STOPSET, 0, strlen(GOM_STOPSET), 0);
if (retval < 0) { return (retval); } if (retval < 0) { return (retval); }

Wyświetl plik

@ -241,6 +241,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
struct icmarine_priv_data *priv; struct icmarine_priv_data *priv;
int i, retval; int i, retval;
struct rig_state *rs; struct rig_state *rs;
hamlib_port_t *rp = RIGPORT(rig);
char cmdbuf[BUFSZ + 1]; char cmdbuf[BUFSZ + 1];
char respbuf[BUFSZ + 1]; char respbuf[BUFSZ + 1];
char *p; char *p;
@ -254,7 +255,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
rs = &rig->state; rs = &rig->state;
priv = (struct icmarine_priv_data *)rs->priv; priv = (struct icmarine_priv_data *)rs->priv;
rig_flush(&rs->rigport); rig_flush(rp);
/* command formatting */ /* command formatting */
SNPRINTF(cmdbuf, BUFSZ, "$PICOA,%02d,%02u,%s", SNPRINTF(cmdbuf, BUFSZ, "$PICOA,%02d,%02u,%s",
@ -277,7 +278,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
cmd_len += snprintf(cmdbuf + cmd_len, BUFSZ - cmd_len, "*%02X" EOM, csum); cmd_len += snprintf(cmdbuf + cmd_len, BUFSZ - cmd_len, "*%02X" EOM, csum);
/* I/O */ /* I/O */
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, cmd_len); retval = write_block(rp, (unsigned char *) cmdbuf, cmd_len);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
@ -287,7 +288,7 @@ int icmarine_transaction(RIG *rig, const char *cmd, const char *param,
/* /*
* Transceiver sends an echo of cmd followed by a CR/LF * Transceiver sends an echo of cmd followed by a CR/LF
*/ */
retval = read_string(&rs->rigport, (unsigned char *) respbuf, BUFSZ, LF, retval = read_string(rp, (unsigned char *) respbuf, BUFSZ, LF,
strlen(LF), 0, 1); strlen(LF), 0, 1);
if (retval < 0) if (retval < 0)

Wyświetl plik

@ -67,15 +67,13 @@ int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
int *data_len) int *data_len)
{ {
int retval; int retval;
struct rig_state *rs; hamlib_port_t *rp = RIGPORT(rig);
rs = &rig->state; rig_flush(rp);
rig_flush(&rs->rigport);
set_transaction_active(rig); set_transaction_active(rig);
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len); retval = write_block(rp, (unsigned char *) cmd, cmd_len);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
@ -89,7 +87,7 @@ int jrc_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
return 0; return 0;
} }
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, retval = read_string(rp, (unsigned char *) data, BUFSZ, EOM,
strlen(EOM), 0, 1); strlen(EOM), 0, 1);
set_transaction_inactive(rig); set_transaction_inactive(rig);
@ -1612,7 +1610,6 @@ int jrc_scan(RIG *rig, vfo_t vfo, scan_t scan, int ch)
int jrc_decode_event(RIG *rig) int jrc_decode_event(RIG *rig)
{ {
const struct jrc_priv_caps *priv = (struct jrc_priv_caps *)rig->caps->priv; const struct jrc_priv_caps *priv = (struct jrc_priv_caps *)rig->caps->priv;
struct rig_state *rs;
freq_t freq; freq_t freq;
rmode_t mode; rmode_t mode;
pbwidth_t width; pbwidth_t width;
@ -1621,13 +1618,11 @@ int jrc_decode_event(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s: jrc_decode called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s: jrc_decode called\n", __func__);
rs = &rig->state;
/* "Iabdfg"CR */ /* "Iabdfg"CR */
//#define SETUP_STATUS_LEN 17 //#define SETUP_STATUS_LEN 17
//count = read_string(&rs->rigport, buf, SETUP_STATUS_LEN, "", 0); //count = read_string(RIGPORT(rig), buf, SETUP_STATUS_LEN, "", 0);
count = read_string(&rs->rigport, (unsigned char *) buf, priv->info_len, "", 0, count = read_string(RIGPORT(rig), (unsigned char *) buf, priv->info_len, "", 0,
0, 1); 0, 1);
if (count < 0) if (count < 0)

Wyświetl plik

@ -298,7 +298,7 @@ static int jst145_open(RIG *rig)
pbwidth_t width; pbwidth_t width;
struct jst145_priv_data *priv = rig->state.priv; struct jst145_priv_data *priv = rig->state.priv;
retval = write_block(&rig->state.rigport, (unsigned char *) "H1\r", 3); retval = write_block(RIGPORT(rig), (unsigned char *) "H1\r", 3);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
@ -317,7 +317,7 @@ static int jst145_open(RIG *rig)
static int jst145_close(RIG *rig) static int jst145_close(RIG *rig)
{ {
return write_block(&rig->state.rigport, (unsigned char *) "H0\r", 3); return write_block(RIGPORT(rig), (unsigned char *) "H0\r", 3);
} }
static int jst145_set_vfo(RIG *rig, vfo_t vfo) static int jst145_set_vfo(RIG *rig, vfo_t vfo)
@ -325,7 +325,7 @@ static int jst145_set_vfo(RIG *rig, vfo_t vfo)
char cmd[MAX_LEN]; char cmd[MAX_LEN];
SNPRINTF(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B'); SNPRINTF(cmd, sizeof(cmd), "F%c\r", vfo == RIG_VFO_A ? 'A' : 'B');
return write_block(&rig->state.rigport, (unsigned char *) cmd, strlen(cmd)); return write_block(RIGPORT(rig), (unsigned char *) cmd, strlen(cmd));
} }
static int jst145_get_vfo(RIG *rig, vfo_t *vfo) static int jst145_get_vfo(RIG *rig, vfo_t *vfo)
@ -388,7 +388,7 @@ static int jst145_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
priv->freqA = freq; priv->freqA = freq;
} }
retval = write_block(&rig->state.rigport, (unsigned char *) freqbuf, retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf,
strlen(freqbuf)); strlen(freqbuf));
if (retval != RIG_OK) if (retval != RIG_OK)
@ -475,7 +475,7 @@ static int jst145_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL; return -RIG_EINVAL;
} }
retval = write_block(&rig->state.rigport, (unsigned char *) modestr, retval = write_block(RIGPORT(rig), (unsigned char *) modestr,
strlen(modestr)); strlen(modestr));
if (retval != RIG_OK) if (retval != RIG_OK)
@ -542,7 +542,7 @@ static int jst145_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
{ {
char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" : char *cmd = val.i == RIG_AGC_SLOW ? "G0\r" : (val.i == RIG_AGC_FAST ? "G1\r" :
"G2\r"); "G2\r");
return write_block(&rig->state.rigport, (unsigned char *) cmd, 3); return write_block(RIGPORT(rig), (unsigned char *) cmd, 3);
} }
default: default:
@ -558,7 +558,7 @@ static int jst145_set_mem(RIG *rig, vfo_t vfo, int ch)
SNPRINTF(membuf, sizeof(membuf), "C%03d\r", ch); SNPRINTF(membuf, sizeof(membuf), "C%03d\r", ch);
return write_block(&rig->state.rigport, (unsigned char *) membuf, return write_block(RIGPORT(rig), (unsigned char *) membuf,
strlen(membuf)); strlen(membuf));
} }
@ -567,7 +567,7 @@ static int jst145_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
switch (op) switch (op)
{ {
case RIG_OP_FROM_VFO: case RIG_OP_FROM_VFO:
return write_block(&rig->state.rigport, (unsigned char *) "E1\r", 3); return write_block(RIGPORT(rig), (unsigned char *) "E1\r", 3);
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
@ -583,7 +583,7 @@ static int jst145_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__); rig_debug(RIG_DEBUG_TRACE, "%s: entered\n", __func__);
SNPRINTF(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0'); SNPRINTF(cmd, sizeof(cmd), "X%c\r", ptt ? '1' : '0');
priv->ptt = ptt; priv->ptt = ptt;
return write_block(&rig->state.rigport, (unsigned char *) cmd, strlen(cmd)); return write_block(RIGPORT(rig), (unsigned char *) cmd, strlen(cmd));
} }
static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) static int jst145_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)

Wyświetl plik

@ -151,12 +151,12 @@ struct rig_caps nrd525_caps =
static int nrd525_open(RIG *rig) static int nrd525_open(RIG *rig)
{ {
return write_block(&rig->state.rigport, (unsigned char *) "H1", 2); return write_block(RIGPORT(rig), (unsigned char *) "H1", 2);
} }
static int nrd525_close(RIG *rig) static int nrd525_close(RIG *rig)
{ {
return write_block(&rig->state.rigport, (unsigned char *) "H0", 2); return write_block(RIGPORT(rig), (unsigned char *) "H0", 2);
} }
static int nrd525_set_freq(RIG *rig, vfo_t vfo, freq_t freq) static int nrd525_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
@ -165,7 +165,7 @@ static int nrd525_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
SNPRINTF(freqbuf, sizeof(freqbuf), "F%08u", (unsigned)(freq / 10)); SNPRINTF(freqbuf, sizeof(freqbuf), "F%08u", (unsigned)(freq / 10));
return write_block(&rig->state.rigport, (unsigned char *) freqbuf, return write_block(RIGPORT(rig), (unsigned char *) freqbuf,
strlen(freqbuf)); strlen(freqbuf));
} }
@ -194,7 +194,7 @@ static int nrd525_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
return -RIG_EINVAL; return -RIG_EINVAL;
} }
retval = write_block(&rig->state.rigport, (unsigned char *) modestr, retval = write_block(RIGPORT(rig), (unsigned char *) modestr,
strlen(modestr)); strlen(modestr));
if (retval != RIG_OK) if (retval != RIG_OK)
@ -219,11 +219,11 @@ static int nrd525_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
switch (level) switch (level)
{ {
case RIG_LEVEL_ATT: case RIG_LEVEL_ATT:
return write_block(&rig->state.rigport, return write_block(RIGPORT(rig),
(unsigned char *)(val.i != 0 ? "A1" : "A0"), 2); (unsigned char *)(val.i != 0 ? "A1" : "A0"), 2);
case RIG_LEVEL_AGC: case RIG_LEVEL_AGC:
return write_block(&rig->state.rigport, return write_block(RIGPORT(rig),
(unsigned char *)(val.i == RIG_AGC_SLOW ? "G0" : (unsigned char *)(val.i == RIG_AGC_SLOW ? "G0" :
(val.i == RIG_AGC_FAST ? "G1" : "G2")), 2); (val.i == RIG_AGC_FAST ? "G1" : "G2")), 2);
@ -238,7 +238,7 @@ static int nrd525_set_mem(RIG *rig, vfo_t vfo, int ch)
SNPRINTF(membuf, sizeof(membuf), "C%03d", ch); SNPRINTF(membuf, sizeof(membuf), "C%03d", ch);
return write_block(&rig->state.rigport, (unsigned char *) membuf, return write_block(RIGPORT(rig), (unsigned char *) membuf,
strlen(membuf)); strlen(membuf));
} }
@ -247,7 +247,7 @@ static int nrd525_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
switch (op) switch (op)
{ {
case RIG_OP_FROM_VFO: case RIG_OP_FROM_VFO:
return write_block(&rig->state.rigport, (unsigned char *) "E1", 2); return write_block(RIGPORT(rig), (unsigned char *) "E1", 2);
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;

Wyświetl plik

@ -65,26 +65,24 @@
static int kachina_transaction(RIG *rig, unsigned char cmd1, unsigned char cmd2) static int kachina_transaction(RIG *rig, unsigned char cmd1, unsigned char cmd2)
{ {
int count, retval; int count, retval;
struct rig_state *rs; hamlib_port_t *rp = RIGPORT(rig);
unsigned char buf4[4]; unsigned char buf4[4];
rs = &rig->state;
buf4[0] = STX; buf4[0] = STX;
buf4[1] = cmd1; buf4[1] = cmd1;
buf4[2] = cmd2; buf4[2] = cmd2;
buf4[3] = ETX; buf4[3] = ETX;
rig_flush(&rs->rigport); rig_flush(rp);
retval = write_block(&rs->rigport, buf4, 4); retval = write_block(rp, buf4, 4);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
count = read_string(&rs->rigport, buf4, 1, "", 0, 0, 1); count = read_string(rp, buf4, 1, "", 0, 0, 1);
if (count != 1) if (count != 1)
{ {
@ -98,11 +96,9 @@ static int kachina_trans_n(RIG *rig, unsigned char cmd1, const char *data,
int data_len) int data_len)
{ {
int cmd_len, count, retval; int cmd_len, count, retval;
struct rig_state *rs; hamlib_port_t *rp = RIGPORT(rig);
unsigned char buf[16]; unsigned char buf[16];
rs = &rig->state;
buf[0] = STX; buf[0] = STX;
buf[1] = cmd1; buf[1] = cmd1;
memcpy(buf + 2, data, data_len); memcpy(buf + 2, data, data_len);
@ -110,16 +106,16 @@ static int kachina_trans_n(RIG *rig, unsigned char cmd1, const char *data,
cmd_len = data_len + 3; cmd_len = data_len + 3;
rig_flush(&rs->rigport); rig_flush(rp);
retval = write_block(&rs->rigport, buf, cmd_len); retval = write_block(rp, buf, cmd_len);
if (retval != RIG_OK) if (retval != RIG_OK)
{ {
return retval; return retval;
} }
count = read_string(&rs->rigport, buf, 1, "", 0, 0, 1); count = read_string(rp, buf, 1, "", 0, 0, 1);
if (count != 1) if (count != 1)
{ {
@ -229,6 +225,7 @@ int kachina_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
{ {
int i, count; int i, count;
unsigned char buf[32]; unsigned char buf[32];
hamlib_port_t *rp = RIGPORT(rig);
static const char rcv_signal_range[128] = static const char rcv_signal_range[128] =
{ {
@ -261,9 +258,9 @@ int kachina_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
/* telemetry sent to the PC automatically at a 50msec rate */ /* telemetry sent to the PC automatically at a 50msec rate */
rig_flush(&rig->state.rigport); rig_flush(rp);
count = read_string(&rig->state.rigport, buf, 31, rcv_signal_range, count = read_string(rp, buf, 31, rcv_signal_range,
128, 0, 1); 128, 0, 1);
if (count < 1) if (count < 1)