kopia lustrzana https://github.com/Hamlib/Hamlib
Convert rigs/mds/, rigs/skanti/, rigs/tapr/ and rigs/tentec/
rodzic
eb94ce2b94
commit
a2abc25416
|
@ -50,15 +50,15 @@ int mds_transaction(RIG *rig, char *cmd, int expected, char **result)
|
||||||
{
|
{
|
||||||
char cmd_buf[MAXCMDLEN];
|
char cmd_buf[MAXCMDLEN];
|
||||||
int retval;
|
int retval;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
struct mds_priv_data *priv = rig->state.priv;
|
struct mds_priv_data *priv = rig->state.priv;
|
||||||
|
|
||||||
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
|
rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd=%s\n", __func__, cmd);
|
||||||
|
|
||||||
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s\n", cmd);
|
SNPRINTF(cmd_buf, sizeof(cmd_buf), "%s\n", cmd);
|
||||||
|
|
||||||
rig_flush(&rs->rigport);
|
rig_flush(rp);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd_buf, strlen(cmd_buf));
|
retval = write_block(rp, (unsigned char *) cmd_buf, strlen(cmd_buf));
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ int mds_transaction(RIG *rig, char *cmd, int expected, char **result)
|
||||||
char cmdtrm_str[2]; /* Default Command/Reply termination char */
|
char cmdtrm_str[2]; /* Default Command/Reply termination char */
|
||||||
cmdtrm_str[0] = 0x0d;
|
cmdtrm_str[0] = 0x0d;
|
||||||
cmdtrm_str[1] = 0x00;
|
cmdtrm_str[1] = 0x00;
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) priv->ret_data,
|
retval = read_string(rp, (unsigned char *) priv->ret_data,
|
||||||
sizeof(priv->ret_data), cmdtrm_str, strlen(cmdtrm_str), 0, expected);
|
sizeof(priv->ret_data), cmdtrm_str, strlen(cmdtrm_str), 0, expected);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
|
|
|
@ -59,13 +59,11 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
||||||
char *data, int *data_len)
|
char *data, 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);
|
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
|
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +78,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
||||||
* Transceiver sends back ">"
|
* Transceiver sends back ">"
|
||||||
*/
|
*/
|
||||||
char retbuf[BUFSZ + 1];
|
char retbuf[BUFSZ + 1];
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) retbuf, BUFSZ, PROMPT,
|
retval = read_string(rp, (unsigned char *) retbuf, BUFSZ, PROMPT,
|
||||||
strlen(PROMPT), 0, 1);
|
strlen(PROMPT), 0, 1);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
|
@ -100,7 +98,7 @@ static int skanti_transaction(RIG *rig, const char *cmd, int cmd_len,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, LF,
|
retval = read_string(rp, (unsigned char *) data, BUFSZ, LF,
|
||||||
strlen(LF), 0, 1);
|
strlen(LF), 0, 1);
|
||||||
|
|
||||||
if (retval == -RIG_ETIMEOUT)
|
if (retval == -RIG_ETIMEOUT)
|
||||||
|
|
|
@ -180,18 +180,19 @@ static int cu_transaction(RIG *rig, const char *cmd, int cmd_len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char retchar;
|
char retchar;
|
||||||
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
|
|
||||||
for (i = 0; i < cmd_len; i++)
|
for (i = 0; i < cmd_len; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
int ret = write_block(&rig->state.rigport, (unsigned char *) &cmd[i], 1);
|
int ret = write_block(rp, (unsigned char *) &cmd[i], 1);
|
||||||
|
|
||||||
if (ret != RIG_OK)
|
if (ret != RIG_OK)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = read_block(&rig->state.rigport, (unsigned char *) &retchar, 1);
|
ret = read_block(rp, (unsigned char *) &retchar, 1);
|
||||||
|
|
||||||
switch (retchar)
|
switch (retchar)
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,12 +45,10 @@ static int tapr_cmd(RIG *rig, unsigned char cmd, unsigned char c1,
|
||||||
unsigned char c2, unsigned char c3, unsigned char c4)
|
unsigned char c2, unsigned char c3, unsigned char c4)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
struct rig_state *rs;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
unsigned char cmdbuf[CMD_LEN];
|
unsigned char cmdbuf[CMD_LEN];
|
||||||
|
|
||||||
rs = &rig->state;
|
rig_flush(rp);
|
||||||
|
|
||||||
rig_flush(&rs->rigport);
|
|
||||||
|
|
||||||
cmdbuf[0] = ESC;
|
cmdbuf[0] = ESC;
|
||||||
cmdbuf[1] = cmd;
|
cmdbuf[1] = cmd;
|
||||||
|
@ -59,7 +57,7 @@ static int tapr_cmd(RIG *rig, unsigned char cmd, unsigned char c1,
|
||||||
cmdbuf[4] = c3;
|
cmdbuf[4] = c3;
|
||||||
cmdbuf[5] = c4;
|
cmdbuf[5] = c4;
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, cmdbuf, 6);
|
retval = write_block(rp, cmdbuf, 6);
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -257,19 +257,19 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
const int *data_len)
|
const int *data_len)
|
||||||
{
|
{
|
||||||
int i, retval = -RIG_EINTERNAL;
|
int i, retval = -RIG_EINTERNAL;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
|
|
||||||
// The original file had "A few XX's" due to sync problems
|
// The original file had "A few XX's" due to sync problems
|
||||||
// So I put this in a try loop which should, hopefully, never be seen
|
// So I put this in a try loop which should, hopefully, never be seen
|
||||||
for (i = 0; i < 3; ++i) // We'll try 3 times
|
for (i = 0; i < 3; ++i) // We'll try 3 times
|
||||||
{
|
{
|
||||||
char xxbuf[32];
|
char xxbuf[32];
|
||||||
rig_flush(&rs->rigport);
|
rig_flush(rp);
|
||||||
|
|
||||||
// We add 1 to data_len here for the null byte inserted by read_string eventually
|
// We add 1 to data_len here for the null byte inserted by read_string eventually
|
||||||
// That way all the callers can use the expected response length for the cmd_len parameter here
|
// That way all the callers can use the expected response length for the cmd_len parameter here
|
||||||
// Callers all need to ensure they have enough room in data for this
|
// Callers all need to ensure they have enough room in data for this
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -284,7 +284,7 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
|
|
||||||
if (data)
|
if (data)
|
||||||
{
|
{
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, (*data_len) + 1,
|
retval = read_string(rp, (unsigned char *) data, (*data_len) + 1,
|
||||||
term, strlen(term), 0,
|
term, strlen(term), 0,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
|
@ -307,9 +307,9 @@ static int tt588_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
rig_debug(RIG_DEBUG_ERR, "%s: write_block failed, try#%d\n", __func__, i + 1);
|
rig_debug(RIG_DEBUG_ERR, "%s: write_block failed, try#%d\n", __func__, i + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_block(&rs->rigport, (unsigned char *) "XX" EOM,
|
write_block(rp, (unsigned char *) "XX" EOM,
|
||||||
3); // we wont' worry about the response here
|
3); // we wont' worry about the response here
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) xxbuf, sizeof(xxbuf), "",
|
retval = read_string(rp, (unsigned char *) xxbuf, sizeof(xxbuf), "",
|
||||||
0, 0, 1); // this should timeout
|
0, 0, 1); // this should timeout
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
|
|
|
@ -109,7 +109,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
int *data_len)
|
int *data_len)
|
||||||
{
|
{
|
||||||
int data_len_init, itry;
|
int data_len_init, itry;
|
||||||
struct rig_state *rs;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
static int passcount = 0;
|
static int passcount = 0;
|
||||||
#ifdef TT565_TIME
|
#ifdef TT565_TIME
|
||||||
double ft1, ft2;
|
double ft1, ft2;
|
||||||
|
@ -122,9 +122,8 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
for (itry = 0; itry < rig->caps->retry; itry++)
|
for (itry = 0; itry < rig->caps->retry; itry++)
|
||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
rs = &rig->state;
|
rig_flush(rp); /* discard pending i/p */
|
||||||
rig_flush(&rs->rigport); /* discard pending i/p */
|
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
|
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +147,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
ft1 = tt565_timenow();
|
ft1 = tt565_timenow();
|
||||||
#endif
|
#endif
|
||||||
*data_len = data_len_init; /* restore orig. buffer length */
|
*data_len = data_len_init; /* restore orig. buffer length */
|
||||||
*data_len = read_string(&rs->rigport, (unsigned char *) data, *data_len,
|
*data_len = read_string(rp, (unsigned char *) data, *data_len,
|
||||||
EOM, strlen(EOM), 0, 1);
|
EOM, strlen(EOM), 0, 1);
|
||||||
|
|
||||||
if (!strncmp(data, "Z!", 2)) // command unrecognized??
|
if (!strncmp(data, "Z!", 2)) // command unrecognized??
|
||||||
|
@ -189,7 +188,7 @@ static int tt565_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
"** retry after delay (io=%d, retry=%d) **\n",
|
"** retry after delay (io=%d, retry=%d) **\n",
|
||||||
passcount, itry);
|
passcount, itry);
|
||||||
*data_len = data_len_init; /* restore orig. buffer length */
|
*data_len = data_len_init; /* restore orig. buffer length */
|
||||||
read_string(&rs->rigport, (unsigned char *) data, *data_len,
|
read_string(rp, (unsigned char *) data, *data_len,
|
||||||
EOM, strlen(EOM), 0, 1); // purge the input stream...
|
EOM, strlen(EOM), 0, 1); // purge the input stream...
|
||||||
continue; // now go retry the full command
|
continue; // now go retry the full command
|
||||||
}
|
}
|
||||||
|
@ -618,7 +617,6 @@ int tt565_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
||||||
*/
|
*/
|
||||||
int tt565_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
int tt565_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
char ttmode, ttreceiver;
|
char ttmode, ttreceiver;
|
||||||
int retval;
|
int retval;
|
||||||
char mdbuf[TT565_BUFSIZE];
|
char mdbuf[TT565_BUFSIZE];
|
||||||
|
@ -674,7 +672,7 @@ int tt565_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -943,9 +941,7 @@ int tt565_get_xit(RIG *rig, vfo_t vfo, shortfreq_t *xit)
|
||||||
*/
|
*/
|
||||||
int tt565_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
int tt565_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
return write_block(RIGPORT(rig),
|
||||||
|
|
||||||
return write_block(&rs->rigport,
|
|
||||||
(unsigned char *)(ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
|
(unsigned char *)(ptt == RIG_PTT_ON ? "*TK" EOM : "*TU" EOM), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ int tt585_set_vfo(RIG *rig, vfo_t vfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* toggle VFOs */
|
/* toggle VFOs */
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) "F", 1);
|
return write_block(RIGPORT(rig), (unsigned char *) "F", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tt585_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
int tt585_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
||||||
|
@ -297,7 +297,7 @@ int tt585_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t txvfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* toggle split mode */
|
/* toggle split mode */
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) "J", 1);
|
return write_block(RIGPORT(rig), (unsigned char *) "J", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tt585_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo)
|
int tt585_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *txvfo)
|
||||||
|
@ -370,7 +370,7 @@ int tt585_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
|
|
||||||
rig_force_cache_timeout(&priv->status_tv);
|
rig_force_cache_timeout(&priv->status_tv);
|
||||||
|
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) buf, strlen(buf));
|
return write_block(RIGPORT(rig), (unsigned char *) buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -455,6 +455,7 @@ int tt585_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
struct tt585_priv_data *priv = (struct tt585_priv_data *)rig->state.priv;
|
struct tt585_priv_data *priv = (struct tt585_priv_data *)rig->state.priv;
|
||||||
const char *mcmd, *wcmd;
|
const char *mcmd, *wcmd;
|
||||||
int ret;
|
int ret;
|
||||||
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
|
@ -476,7 +477,7 @@ int tt585_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
|
|
||||||
rig_force_cache_timeout(&priv->status_tv);
|
rig_force_cache_timeout(&priv->status_tv);
|
||||||
|
|
||||||
ret = write_block(&rig->state.rigport, (unsigned char *) mcmd, strlen(mcmd));
|
ret = write_block(rp, (unsigned char *) mcmd, strlen(mcmd));
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -511,7 +512,7 @@ int tt585_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
wcmd = "R";
|
wcmd = "R";
|
||||||
}
|
}
|
||||||
|
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) wcmd, strlen(mcmd));
|
return write_block(rp, (unsigned char *) wcmd, strlen(mcmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
int tt585_set_mem(RIG *rig, vfo_t vfo, int ch)
|
int tt585_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||||
|
@ -529,7 +530,7 @@ int tt585_set_mem(RIG *rig, vfo_t vfo, int ch)
|
||||||
/* does it work without a command after the channel number? */
|
/* does it work without a command after the channel number? */
|
||||||
SNPRINTF(buf, sizeof(buf), ":%02d", ch);
|
SNPRINTF(buf, sizeof(buf), ":%02d", ch);
|
||||||
|
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) buf, strlen(buf));
|
return write_block(RIGPORT(rig), (unsigned char *) buf, strlen(buf));
|
||||||
}
|
}
|
||||||
|
|
||||||
int tt585_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
int tt585_get_mem(RIG *rig, vfo_t vfo, int *ch)
|
||||||
|
@ -568,7 +569,7 @@ int tt585_get_status_data(RIG *rig)
|
||||||
hamlib_port_t *rigport;
|
hamlib_port_t *rigport;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
rigport = &rig->state.rigport;
|
rigport = RIGPORT(rig);
|
||||||
|
|
||||||
if (!rig_check_cache_timeout(&priv->status_tv, TT585_CACHE_TIMEOUT))
|
if (!rig_check_cache_timeout(&priv->status_tv, TT585_CACHE_TIMEOUT))
|
||||||
{
|
{
|
||||||
|
@ -608,7 +609,7 @@ int tt585_set_parm(RIG *rig, setting_t parm, value_t val)
|
||||||
{
|
{
|
||||||
case RIG_PARM_ANN:
|
case RIG_PARM_ANN:
|
||||||
/* FIXME: > is a toggle command only */
|
/* FIXME: > is a toggle command only */
|
||||||
ret = write_block(&rig->state.rigport, (unsigned char *) ">", 1);
|
ret = write_block(RIGPORT(rig), (unsigned char *) ">", 1);
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
@ -678,5 +679,5 @@ int tt585_vfo_op(RIG *rig, vfo_t vfo, vfo_op_t op)
|
||||||
|
|
||||||
rig_force_cache_timeout(&priv->status_tv);
|
rig_force_cache_timeout(&priv->status_tv);
|
||||||
|
|
||||||
return write_block(&rig->state.rigport, (unsigned char *) cmd, strlen(cmd));
|
return write_block(RIGPORT(rig), (unsigned char *) cmd, strlen(cmd));
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,15 +242,13 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
int retval;
|
int retval;
|
||||||
char str[BUFSZ];
|
char str[BUFSZ];
|
||||||
char fmt[16];
|
char fmt[16];
|
||||||
struct rig_state *rs;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
||||||
|
|
||||||
rs = &rig->state;
|
rig_flush(rp);
|
||||||
|
|
||||||
rig_flush(&rs->rigport);
|
|
||||||
|
|
||||||
num_snprintf(str, BUFSZ, "$%u%s", priv->receiver_id, cmd);
|
num_snprintf(str, BUFSZ, "$%u%s", priv->receiver_id, cmd);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) str, strlen(str));
|
retval = write_block(rp, (unsigned char *) str, strlen(str));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -263,7 +261,7 @@ static int rx331_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, 1, 0, 1);
|
retval = read_string(rp, (unsigned char *) data, BUFSZ, EOM, 1, 0, 1);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
@ -395,14 +393,13 @@ int rx331_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
||||||
|
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int freq_len, retval;
|
int freq_len, retval;
|
||||||
char freqbuf[16];
|
char freqbuf[16];
|
||||||
|
|
||||||
freq_len = num_snprintf(freqbuf, sizeof(freqbuf), "$%uF%.6f" EOM,
|
freq_len = num_snprintf(freqbuf, sizeof(freqbuf), "$%uF%.6f" EOM,
|
||||||
priv->receiver_id, freq / 1e6);
|
priv->receiver_id, freq / 1e6);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, freq_len);
|
retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf, freq_len);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -443,7 +440,6 @@ int rx331_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
char dmode;
|
char dmode;
|
||||||
int mdbuf_len, retval;
|
int mdbuf_len, retval;
|
||||||
char mdbuf[32];
|
char mdbuf[32];
|
||||||
|
@ -494,7 +490,7 @@ int rx331_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
dmode);
|
dmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, mdbuf_len);
|
retval = write_block(RIGPORT(rig), (unsigned char *) mdbuf, mdbuf_len);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -565,7 +561,6 @@ int rx331_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||||
int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
{
|
{
|
||||||
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
const struct rx331_priv_data *priv = (struct rx331_priv_data *)rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval = RIG_OK;
|
int retval = RIG_OK;
|
||||||
char cmdbuf[32];
|
char cmdbuf[32];
|
||||||
|
|
||||||
|
@ -637,7 +632,7 @@ int rx331_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -194,13 +194,11 @@ static int rx340_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);
|
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
|
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -213,7 +211,7 @@ static int rx340_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, BUFSZ, EOM, 1, 0, 1);
|
retval = read_string(rp, (unsigned char *) data, BUFSZ, EOM, 1, 0, 1);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
{
|
{
|
||||||
|
@ -273,19 +271,17 @@ int rx340_cleanup(RIG *rig)
|
||||||
|
|
||||||
int rx340_open(RIG *rig)
|
int rx340_open(RIG *rig)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
|
|
||||||
#define REMOTE_CMD "*R1"EOM
|
#define REMOTE_CMD "*R1"EOM
|
||||||
return write_block(&rs->rigport, (unsigned char *) REMOTE_CMD,
|
return write_block(RIGPORT(rig), (unsigned char *) REMOTE_CMD,
|
||||||
strlen(REMOTE_CMD));
|
strlen(REMOTE_CMD));
|
||||||
}
|
}
|
||||||
|
|
||||||
int rx340_close(RIG *rig)
|
int rx340_close(RIG *rig)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
|
|
||||||
#define LOCAL_CMD "*R0"EOM
|
#define LOCAL_CMD "*R0"EOM
|
||||||
return write_block(&rs->rigport, (unsigned char *) LOCAL_CMD,
|
return write_block(RIGPORT(rig), (unsigned char *) LOCAL_CMD,
|
||||||
strlen(LOCAL_CMD));
|
strlen(LOCAL_CMD));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,13 +290,12 @@ int rx340_close(RIG *rig)
|
||||||
*/
|
*/
|
||||||
int rx340_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
int rx340_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval;
|
int retval;
|
||||||
char freqbuf[16];
|
char freqbuf[16];
|
||||||
|
|
||||||
SNPRINTF(freqbuf, sizeof(freqbuf), "F%.6f" EOM, freq / 1e6);
|
SNPRINTF(freqbuf, sizeof(freqbuf), "F%.6f" EOM, freq / 1e6);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf, strlen(freqbuf));
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -341,7 +336,6 @@ int rx340_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
*/
|
*/
|
||||||
int rx340_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
int rx340_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
char dmode;
|
char dmode;
|
||||||
int retval;
|
int retval;
|
||||||
char mdbuf[32];
|
char mdbuf[32];
|
||||||
|
@ -390,7 +384,7 @@ int rx340_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
SNPRINTF(mdbuf, sizeof(mdbuf), "D%c" EOM, dmode);
|
SNPRINTF(mdbuf, sizeof(mdbuf), "D%c" EOM, dmode);
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -462,7 +456,6 @@ int rx340_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||||
*/
|
*/
|
||||||
int rx340_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
int rx340_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval = RIG_OK;
|
int retval = RIG_OK;
|
||||||
char cmdbuf[32];
|
char cmdbuf[32];
|
||||||
|
|
||||||
|
@ -510,7 +503,7 @@ int rx340_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
return -RIG_EINVAL;
|
return -RIG_EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,11 @@ int tentec_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);
|
retval = write_block(rp, (unsigned char *) cmd, cmd_len);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, cmd_len);
|
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -78,7 +76,7 @@ int tentec_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
|
retval = read_string(rp, (unsigned char *) data, *data_len, NULL, 0,
|
||||||
0, 1);
|
0, 1);
|
||||||
|
|
||||||
if (retval == -RIG_ETIMEOUT)
|
if (retval == -RIG_ETIMEOUT)
|
||||||
|
@ -229,7 +227,6 @@ static void tentec_tuning_factor_calc(RIG *rig)
|
||||||
int tentec_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
int tentec_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
struct tentec_priv_data *priv;
|
struct tentec_priv_data *priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval;
|
int retval;
|
||||||
char freqbuf[16];
|
char freqbuf[16];
|
||||||
freq_t old_freq;
|
freq_t old_freq;
|
||||||
|
@ -245,7 +242,7 @@ int tentec_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
priv->ftf >> 8, priv->ftf & 0xff,
|
priv->ftf >> 8, priv->ftf & 0xff,
|
||||||
priv->btf >> 8, priv->btf & 0xff);
|
priv->btf >> 8, priv->btf & 0xff);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf, strlen(freqbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -277,7 +274,7 @@ int tentec_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||||
int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv;
|
struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
char ttmode;
|
char ttmode;
|
||||||
rmode_t saved_mode;
|
rmode_t saved_mode;
|
||||||
pbwidth_t saved_width;
|
pbwidth_t saved_width;
|
||||||
|
@ -347,7 +344,7 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
priv->ftf >> 8, priv->ftf & 0xff,
|
priv->ftf >> 8, priv->ftf & 0xff,
|
||||||
priv->btf >> 8, priv->btf & 0xff,
|
priv->btf >> 8, priv->btf & 0xff,
|
||||||
ttmode);
|
ttmode);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -365,7 +362,7 @@ int tentec_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
priv->ftf >> 8, priv->ftf & 0xff,
|
priv->ftf >> 8, priv->ftf & 0xff,
|
||||||
priv->btf >> 8, priv->btf & 0xff,
|
priv->btf >> 8, priv->btf & 0xff,
|
||||||
ttmode);
|
ttmode);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -401,7 +398,7 @@ int tentec_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
||||||
int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
{
|
{
|
||||||
struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv;
|
struct tentec_priv_data *priv = (struct tentec_priv_data *)rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
int retval = RIG_OK;
|
int retval = RIG_OK;
|
||||||
char cmdbuf[32];
|
char cmdbuf[32];
|
||||||
|
|
||||||
|
@ -415,7 +412,7 @@ int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
|
||||||
val.i == RIG_AGC_SLOW ? '1' : (
|
val.i == RIG_AGC_SLOW ? '1' : (
|
||||||
val.i == RIG_AGC_FAST ? '3' : '2'));
|
val.i == RIG_AGC_FAST ? '3' : '2'));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -429,7 +426,7 @@ int tentec_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
* -> need to create RIG_LEVEL_LINEOUT ?
|
* -> need to create RIG_LEVEL_LINEOUT ?
|
||||||
*/
|
*/
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "C\x7f%c" EOM, (int)((1.0 - val.f) * 63.0));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "C\x7f%c" EOM, (int)((1.0 - val.f) * 63.0));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -66,9 +66,7 @@ tt550_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;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* set_transaction_active keeps the asynchronous decode routine from being called
|
* set_transaction_active keeps the asynchronous decode routine from being called
|
||||||
|
@ -76,9 +74,9 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
*/
|
*/
|
||||||
set_transaction_active(rig);
|
set_transaction_active(rig);
|
||||||
|
|
||||||
rig_flush(&rs->rigport);
|
rig_flush(rp);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmd, strlen(cmd));
|
retval = write_block(rp, (unsigned char *) cmd, strlen(cmd));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +93,7 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = read_string(&rs->rigport, (unsigned char *) data, *data_len, NULL, 0,
|
retval = read_string(rp, (unsigned char *) data, *data_len, NULL, 0,
|
||||||
0, 1);
|
0, 1);
|
||||||
|
|
||||||
if (retval == -RIG_ETIMEOUT)
|
if (retval == -RIG_ETIMEOUT)
|
||||||
|
@ -126,12 +124,11 @@ tt550_transaction(RIG *rig, const char *cmd, int cmd_len, char *data,
|
||||||
int
|
int
|
||||||
tt550_tx_control(RIG *rig, char oper)
|
tt550_tx_control(RIG *rig, char oper)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval;
|
int retval;
|
||||||
char cmdbuf[4];
|
char cmdbuf[4];
|
||||||
|
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "#%c" EOM, oper);
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "#%c" EOM, oper);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
/*
|
/*
|
||||||
* if (retval == RIG_OK) not currently saving the state of these operations I'm
|
* if (retval == RIG_OK) not currently saving the state of these operations I'm
|
||||||
* not sure we need to, but if so, this is where it would go.
|
* not sure we need to, but if so, this is where it would go.
|
||||||
|
@ -598,7 +595,6 @@ int
|
||||||
tt550_set_rx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
tt550_set_rx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
struct tt550_priv_data *priv;
|
struct tt550_priv_data *priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval;
|
int retval;
|
||||||
char freqbuf[16];
|
char freqbuf[16];
|
||||||
|
|
||||||
|
@ -612,7 +608,7 @@ tt550_set_rx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
||||||
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf, strlen(freqbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -632,7 +628,6 @@ int
|
||||||
tt550_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
tt550_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
{
|
{
|
||||||
struct tt550_priv_data *priv;
|
struct tt550_priv_data *priv;
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
int retval;
|
int retval;
|
||||||
char freqbuf[16];
|
char freqbuf[16];
|
||||||
|
|
||||||
|
@ -646,7 +641,7 @@ tt550_set_tx_freq(RIG *rig, vfo_t vfo, freq_t freq)
|
||||||
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
||||||
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
||||||
|
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) freqbuf, strlen(freqbuf));
|
retval = write_block(RIGPORT(rig), (unsigned char *) freqbuf, strlen(freqbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -681,7 +676,7 @@ int
|
||||||
tt550_set_rx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
tt550_set_rx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
char ttmode;
|
char ttmode;
|
||||||
rmode_t saved_mode;
|
rmode_t saved_mode;
|
||||||
pbwidth_t saved_width;
|
pbwidth_t saved_width;
|
||||||
|
@ -756,7 +751,7 @@ tt550_set_rx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
tt550_tuning_factor_calc(rig, RECEIVE);
|
tt550_tuning_factor_calc(rig, RECEIVE);
|
||||||
|
|
||||||
SNPRINTF(mdbuf, sizeof(mdbuf), "M%c%c" EOM, ttmode, ttmode);
|
SNPRINTF(mdbuf, sizeof(mdbuf), "M%c%c" EOM, ttmode, ttmode);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -772,7 +767,7 @@ tt550_set_rx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
ttfilter,
|
ttfilter,
|
||||||
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
||||||
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -796,7 +791,7 @@ int
|
||||||
tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
{
|
{
|
||||||
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
char ttmode;
|
char ttmode;
|
||||||
rmode_t saved_mode;
|
rmode_t saved_mode;
|
||||||
pbwidth_t saved_width;
|
pbwidth_t saved_width;
|
||||||
|
@ -889,7 +884,7 @@ tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
tt550_tuning_factor_calc(rig, TRANSMIT);
|
tt550_tuning_factor_calc(rig, TRANSMIT);
|
||||||
|
|
||||||
SNPRINTF(mdbuf, sizeof(mdbuf), "M%c%c" EOM, ttmode, ttmode);
|
SNPRINTF(mdbuf, sizeof(mdbuf), "M%c%c" EOM, ttmode, ttmode);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -905,7 +900,7 @@ tt550_set_tx_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
||||||
ttfilter,
|
ttfilter,
|
||||||
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
priv->ctf >> 8, priv->ctf & 0xff, priv->ftf >> 8,
|
||||||
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
priv->ftf & 0xff, priv->btf >> 8, priv->btf & 0xff);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) mdbuf, strlen(mdbuf));
|
retval = write_block(rp, (unsigned char *) mdbuf, strlen(mdbuf));
|
||||||
|
|
||||||
if (retval != RIG_OK)
|
if (retval != RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -994,7 +989,7 @@ int
|
||||||
tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
{
|
{
|
||||||
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
int retval, ditfactor, dahfactor, spcfactor;
|
int retval, ditfactor, dahfactor, spcfactor;
|
||||||
char cmdbuf[32];
|
char cmdbuf[32];
|
||||||
|
|
||||||
|
@ -1003,7 +998,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
case RIG_LEVEL_AGC:
|
case RIG_LEVEL_AGC:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "G%c" EOM,
|
||||||
val.i >= 3 ? '3' : (val.i < 2 ? '1' : '2'));
|
val.i >= 3 ? '3' : (val.i < 2 ? '1' : '2'));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1014,7 +1009,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_AF:
|
case RIG_LEVEL_AF:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "V%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "V%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1026,7 +1021,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_LINEOUT:
|
case RIG_LEVEL_LINEOUT:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "L%c" EOM, (int)(val.f * 63));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "L%c" EOM, (int)(val.f * 63));
|
||||||
retval = write_block(&rs->rigport, cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1038,7 +1033,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_RF:
|
case RIG_LEVEL_RF:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "A%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "A%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1049,7 +1044,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_SQL:
|
case RIG_LEVEL_SQL:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "S%c" EOM, (int)(val.f * 19));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "S%c" EOM, (int)(val.f * 19));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1060,7 +1055,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_NR:
|
case RIG_LEVEL_NR:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "D%c" EOM, (int)(val.f * 7));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "D%c" EOM, (int)(val.f * 7));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1074,7 +1069,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
* attenuator is either on or off
|
* attenuator is either on or off
|
||||||
*/
|
*/
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "B%c" EOM, val.i < 15 ? '0' : '1');
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "B%c" EOM, val.i < 15 ? '0' : '1');
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1093,7 +1088,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
ditfactor >> 8, ditfactor & 0xff, dahfactor >> 8,
|
ditfactor >> 8, ditfactor & 0xff, dahfactor >> 8,
|
||||||
dahfactor & 0xff, spcfactor >> 8,
|
dahfactor & 0xff, spcfactor >> 8,
|
||||||
spcfactor & 0xff);
|
spcfactor & 0xff);
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1104,7 +1099,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_RFPOWER:
|
case RIG_LEVEL_RFPOWER:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "P%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "P%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1115,7 +1110,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_VOXGAIN:
|
case RIG_LEVEL_VOXGAIN:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UG%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UG%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1126,7 +1121,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_VOXDELAY:
|
case RIG_LEVEL_VOXDELAY:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UH%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UH%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1137,7 +1132,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_ANTIVOX:
|
case RIG_LEVEL_ANTIVOX:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UA%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UA%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1148,7 +1143,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_COMP:
|
case RIG_LEVEL_COMP:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "Y%c" EOM, (int)(val.f * 127));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "Y%c" EOM, (int)(val.f * 127));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1159,7 +1154,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_MICGAIN:
|
case RIG_LEVEL_MICGAIN:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "O1%c%c" EOM, 0, (int)(val.f * 15));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "O1%c%c" EOM, 0, (int)(val.f * 15));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1170,7 +1165,7 @@ tt550_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
||||||
|
|
||||||
case RIG_LEVEL_BKINDL:
|
case RIG_LEVEL_BKINDL:
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UQ%c" EOM, (int)(val.f * 255));
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "UQ%c" EOM, (int)(val.f * 255));
|
||||||
retval = write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
retval = write_block(rp, (unsigned char *) cmdbuf, strlen(cmdbuf));
|
||||||
|
|
||||||
if (retval == RIG_OK)
|
if (retval == RIG_OK)
|
||||||
{
|
{
|
||||||
|
@ -1368,11 +1363,10 @@ tt550_get_info(RIG *rig)
|
||||||
int
|
int
|
||||||
tt550_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
tt550_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt)
|
||||||
{
|
{
|
||||||
struct rig_state *rs = &rig->state;
|
|
||||||
char cmdbuf[16];
|
char cmdbuf[16];
|
||||||
|
|
||||||
SNPRINTF(cmdbuf, sizeof(cmdbuf), "Q%c" EOM, ptt == 0 ? '0' : '1');
|
SNPRINTF(cmdbuf, sizeof(cmdbuf), "Q%c" EOM, ptt == 0 ? '0' : '1');
|
||||||
return (write_block(&rs->rigport, (unsigned char *) cmdbuf, strlen(cmdbuf)));
|
return (write_block(RIGPORT(rig), (unsigned char *) cmdbuf, strlen(cmdbuf)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,7 +1436,7 @@ tt550_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
||||||
{
|
{
|
||||||
unsigned char fctbuf[16];
|
unsigned char fctbuf[16];
|
||||||
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
struct tt550_priv_data *priv = (struct tt550_priv_data *) rig->state.priv;
|
||||||
struct rig_state *rs = &rig->state;
|
hamlib_port_t *rp = RIGPORT(rig);
|
||||||
|
|
||||||
/* Optimize:
|
/* Optimize:
|
||||||
* sort the switch cases with the most frequent first
|
* sort the switch cases with the most frequent first
|
||||||
|
@ -1452,20 +1446,20 @@ tt550_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
|
||||||
case RIG_FUNC_VOX:
|
case RIG_FUNC_VOX:
|
||||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "U%c" EOM, status == 0 ? '0' : '1');
|
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "U%c" EOM, status == 0 ? '0' : '1');
|
||||||
priv->vox = status;
|
priv->vox = status;
|
||||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
return write_block(rp, fctbuf, strlen((char *)fctbuf));
|
||||||
|
|
||||||
case RIG_FUNC_NR:
|
case RIG_FUNC_NR:
|
||||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, status == 0 ? '0' : '1',
|
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM, status == 0 ? '0' : '1',
|
||||||
priv->anf == 0 ? '0' : '1');
|
priv->anf == 0 ? '0' : '1');
|
||||||
priv->en_nr = status;
|
priv->en_nr = status;
|
||||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
return write_block(rp, fctbuf, strlen((char *)fctbuf));
|
||||||
|
|
||||||
case RIG_FUNC_ANF:
|
case RIG_FUNC_ANF:
|
||||||
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM,
|
SNPRINTF((char *) fctbuf, sizeof(fctbuf), "K%c%c" EOM,
|
||||||
priv->en_nr == 0 ? '0' : '1',
|
priv->en_nr == 0 ? '0' : '1',
|
||||||
status == 0 ? '0' : '1');
|
status == 0 ? '0' : '1');
|
||||||
priv->anf = status;
|
priv->anf = status;
|
||||||
return write_block(&rs->rigport, fctbuf, strlen((char *)fctbuf));
|
return write_block(rp, fctbuf, strlen((char *)fctbuf));
|
||||||
|
|
||||||
|
|
||||||
case RIG_FUNC_TUNER:
|
case RIG_FUNC_TUNER:
|
||||||
|
@ -1681,8 +1675,7 @@ tt550_decode_event(RIG *rig)
|
||||||
rs = &rig->state;
|
rs = &rig->state;
|
||||||
priv = (struct tt550_priv_data *) rs->priv;
|
priv = (struct tt550_priv_data *) rs->priv;
|
||||||
|
|
||||||
|
data_len = read_string(RIGPORT(rig), buf, MAXFRAMELEN, "\n\r", 2, 0,
|
||||||
data_len = read_string(&rs->rigport, buf, MAXFRAMELEN, "\n\r", 2, 0,
|
|
||||||
1);
|
1);
|
||||||
|
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue