Added get_rit, set_rit, get_xit, set_xit

git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@2484 7ae35d74-ebe9-4afe-98af-79ac388436b8
Hamlib-1.2.9
Terry Embry, KJ4EED 2008-11-29 19:26:09 +00:00
rodzic edf999b945
commit fc86094b56
3 zmienionych plików z 146 dodań i 13 usunięć

Wyświetl plik

@ -8,7 +8,7 @@
* via serial interface to an FT-950 using the "CAT" interface
*
*
* $Id: ft950.c,v 1.4 2008-11-27 07:46:34 mrtembry Exp $
* $Id: ft950.c,v 1.5 2008-11-29 19:26:09 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -168,8 +168,10 @@ const struct rig_caps ft950_caps = {
.get_ptt = newcat_get_ptt,
// .set_split_vfo = newcat_set_split_vfo,
// .get_split_vfo = newcat_get_split_vfo,
// .set_rit = newcat_set_rit,
// .get_rit = newcat_get_rit,
.set_rit = newcat_set_rit,
.get_rit = newcat_get_rit,
.set_xit = newcat_set_xit,
.get_xit = newcat_get_xit,
.set_ant = newcat_set_ant,
.get_ant = newcat_get_ant,
.get_func = newcat_get_func,

Wyświetl plik

@ -13,7 +13,7 @@
* FT-950, FT-450. Much testing remains. -N0NB
*
*
* $Id: newcat.c,v 1.11 2008-11-28 22:59:08 mrtembry Exp $
* $Id: newcat.c,v 1.12 2008-11-29 19:26:09 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -975,33 +975,161 @@ int newcat_get_split_vfo(RIG * rig, vfo_t vfo, split_t * split, vfo_t *tx_vfo)
int newcat_set_rit(RIG * rig, vfo_t vfo, shortfreq_t rit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct newcat_priv_data *priv;
struct rig_state *state;
int err;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
return -RIG_ENAVAIL;
if (rit == 0)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RT0;");
else if (rit < 0) {
if (rit < -9999)
rit = -9999;
rit = abs(rit);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RC;RD%04ld;RT1;", rit);
}else {
if (rit > 9999)
rit = 9999;
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RC;RU%04ld;RT1;", rit);
}
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK;
}
int newcat_get_rit(RIG * rig, vfo_t vfo, shortfreq_t * rit)
{
struct newcat_priv_data *priv;
struct rig_state *state;
char *retval;
char rit_on;
int err;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
*rit = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return -RIG_ENAVAIL;
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s;", "IF");
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str);
/* Get RIT */
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, RIT value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]);
if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting RIT\n");
return RIG_OK;
}
retval = priv->ret_data + 13;
rit_on = retval[5];
retval[5] = '\0';
if (rit_on == '1')
*rit = (shortfreq_t) atoi(retval);
return RIG_OK;
}
int newcat_set_xit(RIG * rig, vfo_t vfo, shortfreq_t xit)
{
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
struct newcat_priv_data *priv;
struct rig_state *state;
int err;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
return -RIG_ENAVAIL;
if (xit == 0)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "XT0;");
else if (xit < 0) {
if (xit < -9999)
xit = 9999;
xit = abs(xit);
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RC;RD%04ld;XT1;", xit);
}else {
if (xit > 9999)
xit = 9999;
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "RC;RU%04ld;XT1;", xit);
}
err = write_block(&state->rigport, priv->cmd_str, strlen(priv->cmd_str));
if (err != RIG_OK)
return err;
return RIG_OK;
}
int newcat_get_xit(RIG * rig, vfo_t vfo, shortfreq_t * xit)
{
struct newcat_priv_data *priv;
struct rig_state *state;
char *retval;
char xit_on;
int err;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
*xit = 0;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
return -RIG_ENAVAIL;
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "%s;", "IF");
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_str = %s\n", __func__, priv->cmd_str);
/* Get XIT */
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, XIT value = %c\n", __func__, err, priv->ret_data, priv->ret_data[2]);
if (strcmp(priv->ret_data, "?;") == 0) {
rig_debug(RIG_DEBUG_TRACE, "Unrecognized command, getting XIT\n");
return RIG_OK;
}
retval = priv->ret_data + 13;
xit_on = retval[6];
retval[5] = '\0';
if (xit_on == '1')
*xit = (shortfreq_t) atoi(retval);
return RIG_OK;
}
@ -1164,7 +1292,6 @@ int newcat_set_ant(RIG * rig, vfo_t vfo, ant_t ant)
int err;
char command[] = "AN";
char which_ant;
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;
@ -1208,7 +1335,6 @@ int newcat_get_ant(RIG * rig, vfo_t vfo, ant_t * ant)
int err;
char c;
char command[] = "AN";
priv = (struct newcat_priv_data *)rig->state.priv;
state = &rig->state;

Wyświetl plik

@ -12,7 +12,7 @@
* FT-950, FT-450. Much testing remains. -N0NB
*
*
* $Id: newcat.h,v 1.8 2008-11-28 22:58:28 mrtembry Exp $
* $Id: newcat.h,v 1.9 2008-11-29 19:26:09 mrtembry Exp $
*
*
* This library is free software; you can redistribute it and/or
@ -126,5 +126,10 @@ int newcat_vfo_op(RIG * rig, vfo_t vfo, vfo_op_t op);
const char *newcat_get_info(RIG * rig);
ncboolean newcat_is_rig_model(RIG * rig, rig_model_t model);
int newcat_get_rit(RIG * rig, vfo_t vfo, shortfreq_t * rit);
int newcat_set_rit(RIG * rig, vfo_t vfo, shortfreq_t rit);
int newcat_get_xit(RIG * rig, vfo_t vfo, shortfreq_t * xit);
int newcat_set_xit(RIG * rig, vfo_t vfo, shortfreq_t xit);
#endif /* _NEWCAT_H */