Skip to content

Commit

Permalink
Starting to implement Yaeus band change memory
Browse files Browse the repository at this point in the history
BS command has a big response so have to increase some buffer sizes
Hamlib#423

(cherry picked from commit cc465e7)
  • Loading branch information
mdblack98 authored and N0NB committed Oct 29, 2020
1 parent 4e355eb commit bd0bb6a
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
50 changes: 49 additions & 1 deletion rigs/yaesu/newcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,33 @@ static int set_roofing_filter_for_width(RIG *rig, vfo_t vfo, int width);
static int get_roofing_filter(RIG *rig, vfo_t vfo, struct newcat_roofing_filter **roofing_filter);
static ncboolean newcat_valid_command(RIG *rig, char const *const command);

/*
* The BS command needs to know what band we're on so we can restore band info
* So this converts freq to band index
*/
static int newcat_band_index(freq_t freq)
{
// FTDX101D has band=12=MW...what is that?
int band = 11; // general

if (freq >= 1.8) { band = 0; }
else if (freq >= 3.5) { band = 1; }
else if (freq >= 5) { band = 2; }
else if (freq >= 7) { band = 3; }
else if (freq >= 10) { band = 4; }
else if (freq >= 14) { band = 5; }
else if (freq >= 18) { band = 6; }
else if (freq >= 21) { band = 7; }
else if (freq >= 24.5) { band = 8; }
else if (freq >= 28) { band = 9; }
else if (freq >= 50) { band = 10; }
// what about 11-16?
else if (freq >= 70) { band = 17; }

rig_debug(RIG_DEBUG_TRACE, "%s: band=%d\n", __func__, band);
return band;
}

/*
* ************************************
*
Expand Down Expand Up @@ -390,6 +417,7 @@ int newcat_init(RIG *rig)
priv->rig_id = NC_RIGID_NONE;
priv->current_mem = NC_MEM_CHANNEL_NONE;
priv->fast_set_commands = FALSE;
priv->has_bs_cmd = 1; // assume true until proven otherwise..in set_freq

return RIG_OK;
}
Expand Down Expand Up @@ -709,6 +737,26 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
return err;
}

rig_debug(RIG_DEBUG_TRACE, "%s: band changing? old=%d, new=%d\n", __func__,
newcat_band_index(freq), newcat_band_index(rig->state.current_freq));

// Restore band memory if we can
if (priv->has_bs_cmd
&& newcat_band_index(freq) != newcat_band_index(rig->state.current_freq))
{
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "BS%c", cat_term);

if (RIG_OK != (err = newcat_set_cmd(rig)))
{
priv->has_bs_cmd = 0; // guess we can't do this so don't try again
rig_debug(RIG_DEBUG_TRACE, "%s: rig does not have BS command\n", __func__);
}
else
{
rig_debug(RIG_DEBUG_TRACE, "%s: need to restore band settings\n", __func__);
}
}

if (RIG_MODEL_FT450 == caps->rig_model && priv->ret_data[2] != target_vfo)
{
/* revert current VFO */
Expand Down Expand Up @@ -5189,7 +5237,7 @@ int newcat_get_channel(RIG *rig, channel_t *chan, int read_only)
const char *newcat_get_info(RIG *rig)
{
struct newcat_priv_data *priv = (struct newcat_priv_data *)rig->state.priv;
static char idbuf[129]; /* extra large static string array */
static char idbuf[513]; /* extra large static string array */

rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);

Expand Down
6 changes: 3 additions & 3 deletions rigs/yaesu/newcat.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ typedef char ncboolean;
/* shared function version */
#define NEWCAT_VER "20201023"

/* Hopefully large enough for future use, 128 chars plus '\0' */
#define NEWCAT_DATA_LEN 129
/* Hopefully large enough for future use, 512 chars plus '\0' */
#define NEWCAT_DATA_LEN 513

/* arbitrary value for now. 11 bits (8N2+1) == 2.2917 mS @ 4800 bps */
#define NEWCAT_DEFAULT_READ_TIMEOUT (NEWCAT_DATA_LEN * 5)
Expand Down Expand Up @@ -118,7 +118,7 @@ struct newcat_priv_data
struct timespec cache_start;
char last_if_response[NEWCAT_DATA_LEN];
int poweron; /* to prevent powering on more than once */
int question_mark_response_means_rejected;
int has_bs_cmd; // used to restore band memory */
};

/*
Expand Down

0 comments on commit bd0bb6a

Please sign in to comment.