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 * 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 * 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, .get_ctcss_sql = newcat_get_ctcss_sql,
.set_powerstat = newcat_set_powerstat, .set_powerstat = newcat_set_powerstat,
.get_powerstat = newcat_get_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 * 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 * 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_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_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow);
static int newcat_get_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,17 +1366,79 @@ 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 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__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return -RIG_ENAVAIL; 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) 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__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return -RIG_ENAVAIL; 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; int err;
char main_sub_vfo = '0'; char main_sub_vfo = '0';
int i; int i;
ncboolean tone_match = FALSE; ncboolean tone_match;
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; 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)) if (newcat_is_rig(rig, RIG_MODEL_FT9000) || newcat_is_rig(rig, RIG_MODEL_FT2000))
main_sub_vfo = (RIG_VFO_B == vfo) ? '1' : '0'; 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]) { if (tone == rig->caps->ctcss_list[i]) {
tone_match = TRUE; tone_match = TRUE;
break; 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) int newcat_get_powerstat(RIG * rig, powerstat_t * status)
{ {
struct newcat_priv_data *priv; 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__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
*status = RIG_POWER_OFF;
if (!newcat_valid_command(rig, command)) if (!newcat_valid_command(rig, command))
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
@ -1687,7 +1756,7 @@ int newcat_get_powerstat(RIG * rig, powerstat_t * status)
err, priv->ret_data, priv->ret_data[2]); err, priv->ret_data, priv->ret_data[2]);
if (strcmp(priv->ret_data, "?;") == 0) { 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; return RIG_OK;
} }
@ -2986,52 +3055,55 @@ ncboolean newcat_is_rig(RIG * rig, rig_model_t model) {
* newcat_get_txvfo does not set priv->curr_vfo * newcat_get_txvfo does not set priv->curr_vfo
*/ */
int newcat_get_txvfo(RIG * rig, vfo_t * txvfo) { int newcat_get_txvfo(RIG * rig, vfo_t * txvfo) {
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
struct rig_state *state; struct rig_state *state;
int err; int err;
char c; char c;
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", "FT", cat_term); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", "FT", cat_term);
/* Get TX VFO */
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)); rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
if (err < 0)
return err;
/* Check that command termination is correct */ /* Get TX VFO */
if (strchr(&cat_term, priv->ret_data[strlen(priv->ret_data) - 1]) == NULL) { err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, priv->ret_data); if (err != RIG_OK)
return err;
return -RIG_EPROTO; err = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), &cat_term, sizeof(cat_term));
} if (err < 0)
return err;
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, TX_VFO value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]); /* 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);
if (strcmp(priv->ret_data, "?;") == 0) { return -RIG_EPROTO;
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting TX_VFO\n"); }
return RIG_OK;
}
c = priv->ret_data[2]; rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, TX_VFO value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]);
switch (c) {
case '0':
*txvfo = RIG_VFO_A;
break;
case '1' :
*txvfo = RIG_VFO_B;
break;
default:
return -RIG_EPROTO;
}
return RIG_OK; if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting TX_VFO\n");
return RIG_OK;
}
c = priv->ret_data[2];
switch (c) {
case '0':
*txvfo = RIG_VFO_A;
break;
case '1' :
*txvfo = RIG_VFO_B;
break;
default:
return -RIG_EPROTO;
}
return RIG_OK;
} }
@ -3039,208 +3111,217 @@ int newcat_get_txvfo(RIG * rig, vfo_t * txvfo) {
* newcat_set_txvfo does not set priv->curr_vfo * newcat_set_txvfo does not set priv->curr_vfo
*/ */
int newcat_set_txvfo(RIG * rig, vfo_t txvfo) { int newcat_set_txvfo(RIG * rig, vfo_t txvfo) {
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
struct rig_state *state; struct rig_state *state;
int err; int err;
char p1; char p1;
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
err = newcat_set_vfo_from_alias(rig, &txvfo); err = newcat_set_vfo_from_alias(rig, &txvfo);
if (err < 0) if (err < 0)
return err; return err;
switch (txvfo) { switch (txvfo) {
case RIG_VFO_A: case RIG_VFO_A:
p1 = '0'; p1 = '0';
break; break;
case RIG_VFO_B: case RIG_VFO_B:
p1 = '1'; p1 = '1';
break; break;
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
} }
if (newcat_is_rig(rig, RIG_MODEL_FT950)) if (newcat_is_rig(rig, RIG_MODEL_FT950))
p1 = p1 + 2; /* FT950 non-Toggle */ p1 = p1 + 2; /* FT950 non-Toggle */
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", "FT", p1, cat_term); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", "FT", p1, cat_term);
/* Set TX VFO */ rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK; /* Set TX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK;
} }
/* /*
* Uses "FR" command * Uses "FR" command
* Calls newcat_get_vfo() for FT450 rig that does not support "FR" * Calls newcat_get_vfo() for FT450 rig that does not support "FR"
* newcat_get_vfo() Calls newcat_get_rxvfo() for rigs that do not support "VS" * newcat_get_vfo() Calls newcat_get_rxvfo() for rigs that do not support "VS"
*/ */
int newcat_get_rxvfo(RIG * rig, vfo_t * rxvfo) { int newcat_get_rxvfo(RIG * rig, vfo_t * rxvfo) {
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
struct rig_state *state; struct rig_state *state;
int err; int err;
char c; char c;
char command[] = "FR"; char command[] = "FR";
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!newcat_valid_command(rig, command)) { if (!newcat_valid_command(rig, command)) {
if (newcat_is_rig(rig, RIG_MODEL_FT450)) { /* No "FR" command */ if (newcat_is_rig(rig, RIG_MODEL_FT450)) { /* No "FR" command */
err = newcat_get_vfo(rig, rxvfo); err = newcat_get_vfo(rig, rxvfo);
if (err < 0) if (err < 0)
return err; return err;
return RIG_OK; return RIG_OK;
} }
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
} }
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c", command, cat_term);
/* Get RX VFO */
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)); rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
if (err < 0)
return err;
/* Check that command termination is correct */ /* Get RX VFO */
if (strchr(&cat_term, priv->ret_data[strlen(priv->ret_data) - 1]) == NULL) { err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
rig_debug(RIG_DEBUG_ERR, "%s: Command is not correctly terminated '%s'\n", __func__, priv->ret_data); if (err != RIG_OK)
return err;
return -RIG_EPROTO; err = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data), &cat_term, sizeof(cat_term));
} if (err < 0)
return err;
rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, RX_VFO value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]); /* 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);
if (strcmp(priv->ret_data, "?;") == 0) { return -RIG_EPROTO;
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting RX_VFO\n"); }
return RIG_OK;
}
c = priv->ret_data[2]; rig_debug(RIG_DEBUG_TRACE, "%s: read count = %d, ret_data = %s, RX_VFO value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]);
switch (c) {
case '0': /* Main Band VFO_A RX, Sub Band VFO_B OFF */
case '1': /* Main Band VFO_A Mute, Sub Band VFO_B OFF */
*rxvfo = RIG_VFO_A;
break;
case '2' : /* Main Band VFO_A RX, Sub Band VFO_B RX */
case '3' : /* Main Band VFO_A Mute, Sub Band VFO_B RX */
*rxvfo = RIG_VFO_A;
/* FIXME: if (is_rig/is_rigid?(rig, RIG_MODEL_FT9000_CONTEST)) *rxvfo = RIG_VFO_B; */
break;
case '4' : /* FT950 Main Band VFO_B RX */
case '5' : /* FT950 Main Band VFO_B Mute */
*rxvfo = RIG_VFO_B;
break;
default:
return -RIG_EPROTO;
}
priv->current_vfo = *rxvfo; /* Track Main Band RX VFO */ if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting RX_VFO\n");
return RIG_OK;
}
return RIG_OK; c = priv->ret_data[2];
switch (c) {
case '0': /* Main Band VFO_A RX, Sub Band VFO_B OFF */
case '1': /* Main Band VFO_A Mute, Sub Band VFO_B OFF */
*rxvfo = RIG_VFO_A;
break;
case '2' : /* Main Band VFO_A RX, Sub Band VFO_B RX */
case '3' : /* Main Band VFO_A Mute, Sub Band VFO_B RX */
*rxvfo = RIG_VFO_A;
/* FIXME: if (is_rig/is_rigid?(rig, RIG_MODEL_FT9000_CONTEST)) *rxvfo = RIG_VFO_B; */
break;
case '4' : /* FT950 Main Band VFO_B RX */
case '5' : /* FT950 Main Band VFO_B Mute */
*rxvfo = RIG_VFO_B;
break;
default:
return -RIG_EPROTO;
}
priv->current_vfo = *rxvfo; /* Track Main Band RX VFO */
return RIG_OK;
} }
/* /*
* Uses "FR" command * Uses "FR" command
* Calls newcat_set_vfo() for FT450 rig that does not support "FR" * Calls newcat_set_vfo() for FT450 rig that does not support "FR"
* newcat_set_vfo() Calls newcat_set_rxvfo() for rigs that do not support "VS" * newcat_set_vfo() Calls newcat_set_rxvfo() for rigs that do not support "VS"
*/ */
int newcat_set_rxvfo(RIG * rig, vfo_t rxvfo) { int newcat_set_rxvfo(RIG * rig, vfo_t rxvfo) {
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
struct rig_state *state; struct rig_state *state;
int err; int err;
char p1; char p1;
char command[] = "FR"; char command[] = "FR";
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; state = &rig->state;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
if (!newcat_valid_command(rig, command)) { if (!newcat_valid_command(rig, command)) {
if (newcat_is_rig(rig, RIG_MODEL_FT450)) { /* No "FR" command */ if (newcat_is_rig(rig, RIG_MODEL_FT450)) { /* No "FR" command */
err = newcat_set_vfo(rig, rxvfo); err = newcat_set_vfo(rig, rxvfo);
if (err < 0) if (err < 0)
return err; return err;
return RIG_OK; return RIG_OK;
} }
return -RIG_ENAVAIL; return -RIG_ENAVAIL;
} }
err = newcat_set_vfo_from_alias(rig, &rxvfo); err = newcat_set_vfo_from_alias(rig, &rxvfo);
if (err < 0) if (err < 0)
return err; return err;
switch (rxvfo) { switch (rxvfo) {
case RIG_VFO_A: case RIG_VFO_A:
p1 = '0'; p1 = '0';
break; break;
case RIG_VFO_B: case RIG_VFO_B:
p1 = '2'; /* Main Band VFO_A, Sub Band VFO_B on certain radios */ p1 = '2'; /* Main Band VFO_A, Sub Band VFO_B on certain radios */
if (newcat_is_rig(rig, RIG_MODEL_FT950)) if (newcat_is_rig(rig, RIG_MODEL_FT950))
p1 = '4'; p1 = '4';
break; break;
default: default:
return -RIG_EINVAL; return -RIG_EINVAL;
} }
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term); snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s%c%c", command, p1, cat_term);
/* Set RX VFO */ rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
priv->current_vfo = rxvfo; /* Track Main Band RX VFO */ /* Set RX VFO */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK; priv->current_vfo = rxvfo; /* Track Main Band RX VFO */
return RIG_OK;
} }
int newcat_set_vfo_from_alias(RIG * rig, vfo_t * vfo) { int newcat_set_vfo_from_alias(RIG * rig, vfo_t * vfo) {
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
rig_debug(RIG_DEBUG_TRACE, "%s: alias vfo = 0x%02x\n", __func__, *vfo); rig_debug(RIG_DEBUG_TRACE, "%s: alias vfo = 0x%02x\n", __func__, *vfo);
switch (*vfo) { switch (*vfo) {
case RIG_VFO_A: case RIG_VFO_A:
case RIG_VFO_B: case RIG_VFO_B:
case RIG_VFO_MEM: case RIG_VFO_MEM:
/* passes through */ /* passes through */
break; break;
case RIG_VFO_CURR: /* RIG_VFO_RX == RIG_VFO_CURR */ case RIG_VFO_CURR: /* RIG_VFO_RX == RIG_VFO_CURR */
case RIG_VFO_VFO: case RIG_VFO_VFO:
*vfo = priv->current_vfo; *vfo = priv->current_vfo;
break; break;
case RIG_VFO_TX: case RIG_VFO_TX:
/* set to another vfo for split or uplink */ /* set to another vfo for split or uplink */
*vfo = (priv->current_vfo == RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_B; *vfo = (priv->current_vfo == RIG_VFO_B) ? RIG_VFO_A : RIG_VFO_B;
break; break;
case RIG_VFO_MAIN: case RIG_VFO_MAIN:
*vfo = RIG_VFO_A; *vfo = RIG_VFO_A;
break; break;
case RIG_VFO_SUB: case RIG_VFO_SUB:
*vfo = RIG_VFO_B; *vfo = RIG_VFO_B;
break; break;
default: default:
rig_debug(RIG_DEBUG_TRACE, "Unrecognized. vfo= %d\n", *vfo); rig_debug(RIG_DEBUG_TRACE, "Unrecognized. vfo= %d\n", *vfo);
return -RIG_EINVAL; return -RIG_EINVAL;
} }
return RIG_OK; return RIG_OK;
} }
/* /*
@ -3255,15 +3336,15 @@ int newcat_set_vfo_from_alias(RIG * rig, vfo_t * vfo) {
* *
*/ */
int newcat_scale_float(int scale, float fval) { int newcat_scale_float(int scale, float fval) {
float f; float f;
float fudge = 0.003; float fudge = 0.003;
if ((fval + fudge) > 1.0) if ((fval + fudge) > 1.0)
f = scale * fval; f = scale * fval;
else else
f = scale * (fval + fudge); f = scale * (fval + fudge);
return (int) f; return (int) f;
} }
@ -3272,9 +3353,8 @@ int newcat_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow)
struct newcat_priv_data *priv; struct newcat_priv_data *priv;
struct rig_state *state; struct rig_state *state;
int err; int err;
char cmdstr[16];
char main_sub_vfo = '0'; char main_sub_vfo = '0';
char c = '0'; char c;
priv = (struct newcat_priv_data *)rig->state.priv; priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state; state = &rig->state;
@ -3292,14 +3372,16 @@ int newcat_set_narrow(RIG * rig, vfo_t vfo, ncboolean narrow)
if (narrow == TRUE) if (narrow == TRUE)
c = '1'; 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);
err = write_block(&state->rigport, cmdstr, strlen(cmdstr)); rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
if (err != RIG_OK)
return err;
return RIG_OK; err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
return err;
} }
@ -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", 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); 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 */ /* Set RX Bandwidth */
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str)); err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK) 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; 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 * 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 * 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_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_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_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_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 */ #endif /* _NEWCAT_H */