Added newcat_get_ts, newcat_set_ts

Added newcat_get_faststep, newcat_set_faststep


git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2532 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.9
Terry Embry, KJ4EED 2008-12-28 00:25:31 +00:00
rodzic 0a21830680
commit 7b751bff86
3 zmienionych plików z 385 dodań i 218 usunięć

Wyświetl plik

@ -9,7 +9,7 @@
* via serial interface to an FT-950 using the "CAT" interface
*
*
* $Id: ft950.c,v 1.12 2008-12-27 08:08:47 mrtembry Exp $
* $Id: ft950.c,v 1.13 2008-12-28 00:25:31 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -224,6 +224,9 @@ const struct rig_caps ft950_caps = {
.get_ctcss_sql = newcat_get_ctcss_sql,
.set_powerstat = newcat_set_powerstat,
.get_powerstat = newcat_get_powerstat,
.get_ts = newcat_get_ts,
.set_ts = newcat_set_ts,
};

Wyświetl plik

@ -14,7 +14,7 @@
* FT-950, FT-450. Much testing remains. -N0NB
*
*
* $Id: newcat.c,v 1.33 2008-12-27 08:08:47 mrtembry Exp $
* $Id: newcat.c,v 1.34 2008-12-28 00:25:31 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -206,6 +206,8 @@ static int newcat_get_rxbandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *
static int newcat_set_rxbandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width);
static int newcat_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow);
static int newcat_get_narrow(RIG * rig, vfo_t vfo, ncboolean * narrow);
static int newcat_set_faststep(RIG * rig, ncboolean fast_step);
static int newcat_get_faststep(RIG * rig, ncboolean * fast_step);
/*
* ************************************
@ -1364,16 +1366,78 @@ int newcat_get_xit(RIG * rig, vfo_t vfo, shortfreq_t * xit)
int newcat_set_ts(RIG * rig, vfo_t vfo, shortfreq_t ts)
{
int err, i;
pbwidth_t width;
rmode_t mode;
ncboolean ts_match;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = newcat_get_mode(rig, vfo, &mode, &width);
if (err < 0)
return err;
/* assume 2 tuning steps per mode */
for (i = 0, ts_match = FALSE; i < TSLSTSIZ && rig->caps->tuning_steps[i].ts; i++)
if (rig->caps->tuning_steps[i].modes & mode) {
if (ts <= rig->caps->tuning_steps[i].ts) {
err = newcat_set_faststep(rig, FALSE);
if (err != RIG_OK)
return err;
}
else {
err = newcat_set_faststep(rig, TRUE);
if (err != RIG_OK)
return err;
}
ts_match = TRUE;
break;
} /* if mode */
rig_debug(RIG_DEBUG_TRACE, "ts_match = %d, i = %d, ts = %d\n", ts_match, i, ts);
if (ts_match)
return RIG_OK;
else
return -RIG_ENAVAIL;
}
int newcat_get_ts(RIG * rig, vfo_t vfo, shortfreq_t * ts)
{
pbwidth_t width;
rmode_t mode;
ncboolean fast_step = FALSE;
ncboolean ts_match;
int err, i;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = newcat_get_mode(rig, vfo, &mode, &width);
if (err < 0)
return err;
err = newcat_get_faststep(rig, &fast_step);
if (err < 0)
return err;
/* assume 2 tuning steps per mode */
for (i = 0, ts_match = FALSE; i < TSLSTSIZ && rig->caps->tuning_steps[i].ts; i++)
if (rig->caps->tuning_steps[i].modes & mode) {
if (fast_step == FALSE)
*ts = rig->caps->tuning_steps[i].ts;
else
*ts = rig->caps->tuning_steps[i+1].ts;
ts_match = TRUE;
break;
}
rig_debug(RIG_DEBUG_TRACE, "ts_match = %d, i = %d, i+1 = %d, *ts = %d\n", ts_match, i, i+1, *ts);
if (ts_match)
return RIG_OK;
else
return -RIG_ENAVAIL;
}
@ -1417,7 +1481,7 @@ int newcat_set_ctcss_tone(RIG * rig, vfo_t vfo, tone_t tone)
int err;
char main_sub_vfo = '0';
int i;
ncboolean tone_match = FALSE;
ncboolean tone_match;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
@ -1436,7 +1500,7 @@ int newcat_set_ctcss_tone(RIG * rig, vfo_t vfo, tone_t tone)
if (newcat_is_rig(rig, RIG_MODEL_FT9000) || newcat_is_rig(rig, RIG_MODEL_FT2000))
main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0';
for (i = 0; rig->caps->ctcss_list[i] != 0; i++)
for (i = 0, tone_match = FALSE; rig->caps->ctcss_list[i] != 0; i++)
if (tone == rig->caps->ctcss_list[i]) {
tone_match = TRUE;
break;
@ -1651,6 +1715,9 @@ int newcat_set_powerstat(RIG * rig, powerstat_t status)
}
/*
* This functions returns an error if the rig is off, dah
*/
int newcat_get_powerstat(RIG * rig, powerstat_t * status)
{
struct newcat_priv_data *priv;
@ -1663,6 +1730,8 @@ int newcat_get_powerstat(RIG * rig, powerstat_t * status)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
*status = RIG_POWER_OFF;
if (!newcat_valid_command(rig, command))
return -RIG_ENAVAIL;
@ -1687,7 +1756,7 @@ int newcat_get_powerstat(RIG * rig, powerstat_t * status)
err, priv->ret_data, priv->ret_data[2]);
if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting ANT\n");
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting PWR STATE\n");
return RIG_OK;
}
@ -2996,6 +3065,9 @@ int newcat_get_txvfo(RIG * rig, vfo_t * txvfo) {
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", "FT", cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
/* Get TX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
@ -3068,6 +3140,8 @@ int newcat_set_txvfo(RIG * rig, vfo_t txvfo) {
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", "FT", p1, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
/* Set TX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
@ -3076,6 +3150,7 @@ int newcat_set_txvfo(RIG * rig, vfo_t txvfo) {
return RIG_OK;
}
/*
* Uses "FR" command
* Calls newcat_get_vfo() for FT450 rig that does not support "FR"
@ -3105,6 +3180,9 @@ int newcat_get_rxvfo(RIG * rig, vfo_t * rxvfo) {
}
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
/* Get RX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
@ -3152,6 +3230,7 @@ int newcat_get_rxvfo(RIG * rig, vfo_t * rxvfo) {
return RIG_OK;
}
/*
* Uses "FR" command
* Calls newcat_set_vfo() for FT450 rig that does not support "FR"
@ -3199,6 +3278,8 @@ int newcat_set_rxvfo(RIG * rig, vfo_t rxvfo) {
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
/* Set RX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
@ -3272,9 +3353,8 @@ int newcat_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow)
struct newcat_priv_data *priv;
struct rig_state *state;
int err;
char cmdstr[16];
char main_sub_vfo = '0';
char c = '0';
char c;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
@ -3292,14 +3372,16 @@ int newcat_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow)
if (narrow == TRUE)
c = '1';
else
c = '0';
snprintf(cmdstr, sizeof(cmdstr), "NA%c%c%c", main_sub_vfo, c, cat_term);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "NA%c%c%c", main_sub_vfo, c, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
err = write_block(&state->rigport, cmdstr, strlen(cmdstr));
if (err != RIG_OK)
return err;
return RIG_OK;
}
@ -3488,6 +3570,8 @@ int newcat_set_rxbandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "NA%c%c%cSH%c%s%c",
main_sub_vfo, narrow, cat_term, main_sub_vfo, width_str, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
/* Set RX Bandwidth */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
@ -3644,3 +3728,82 @@ int newcat_get_rxbandwidth(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t *width)
return RIG_OK;
}
int newcat_set_faststep(RIG * rig, ncboolean fast_step)
{
struct newcat_priv_data *priv;
struct rig_state *state;
int err;
char c;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!newcat_valid_command(rig, "FS"))
return -RIG_ENAVAIL;
if (fast_step == TRUE)
c = '1';
else
c = '0';
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "FS%c%c", c, cat_term);
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
return err;
}
int newcat_get_faststep(RIG * rig, ncboolean * fast_step)
{
struct newcat_priv_data *priv;
struct rig_state *state;
int err;
char command[] = "FS";
char c;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!newcat_valid_command(rig, command))
return -RIG_ENAVAIL;
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
/* Get Fast Step */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
err = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), &cat_term, sizeof(cat_term));
if (err < 0)
return err;
/* Check that command termination is correct */
if (strchr(&cat_term, priv->ret_data[strlen(priv->ret_data) - 1]) == NULL) {
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, priv->ret_data);
return -RIG_EPROTO;
}
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, NA value = %c\n", __func__,
err, priv->ret_data, priv->ret_data[3]);
if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting NA\n");
return RIG_OK;
}
c = priv->ret_data[2];
if (c == '1')
*fast_step = TRUE;
else
*fast_step = FALSE;
return RIG_OK;
}

Wyświetl plik

@ -13,7 +13,7 @@
* FT-950, FT-450. Much testing remains. -N0NB
*
*
* $Id: newcat.h,v 1.15 2008-12-27 08:08:47 mrtembry Exp $
* $Id: newcat.h,v 1.16 2008-12-28 00:25:31 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -149,8 +149,9 @@ int newcat_set_ctcss_tone(RIG * rig, vfo_t vfo, tone_t tone);
int newcat_get_ctcss_tone(RIG * rig, vfo_t vfo, tone_t * tone);
int newcat_set_ctcss_sql(RIG * rig, vfo_t vfo, tone_t tone);
int newcat_get_ctcss_sql(RIG * rig, vfo_t vfo, tone_t * tone);
int newcat_get_powerstat(RIG * rig, powerstat_t * status);
int newcat_set_powerstat(RIG * rig, powerstat_t status);
int newcat_get_powerstat(RIG * rig, powerstat_t * status);
int newcat_set_ts(RIG * rig, vfo_t vfo, shortfreq_t ts);
int newcat_get_ts(RIG * rig, vfo_t vfo, shortfreq_t * ts);
#endif /* _NEWCAT_H */