diff --git a/yaesu/ft950.c b/yaesu/ft950.c index 474c9658b..20f7ed928 100644 --- a/yaesu/ft950.c +++ b/yaesu/ft950.c @@ -190,6 +190,7 @@ const struct rig_caps ft950_caps = { .rig_open = newcat_open, /* port opened */ .rig_close = newcat_close, /* port closed */ + .cfgparams = newcat_cfg_params, .set_conf = newcat_set_conf, .get_conf = newcat_get_conf, .set_freq = newcat_set_freq, diff --git a/yaesu/ft950.h b/yaesu/ft950.h index bb6609b44..ce4ac6f84 100644 --- a/yaesu/ft950.h +++ b/yaesu/ft950.h @@ -118,6 +118,7 @@ /* Delay sequential fast writes */ -#define FT950_POST_WRITE_DELAY 5 +//#define FT950_POST_WRITE_DELAY 5 +#define FT950_POST_WRITE_DELAY 0 #endif /* _FT950_H */ diff --git a/yaesu/newcat.c b/yaesu/newcat.c index 1ebd01ead..899f11188 100644 --- a/yaesu/newcat.c +++ b/yaesu/newcat.c @@ -214,6 +214,19 @@ static const yaesu_newcat_commands_t valid_commands[] = { }; int valid_commands_count = sizeof(valid_commands) / sizeof(yaesu_newcat_commands_t); + /* + * configuration Tokens + * + */ + +#define TOK_FAST_SET_CMD TOKEN_BACKEND(1) + +const struct confparams newcat_cfg_params[] = { + { TOK_FAST_SET_CMD, "fast_set_commands", "High troughput of commands", "Enabled high throughput of >200 messages/sec by not waiting for ACK/NAK of messages", "0", RIG_CONF_NUMERIC, { .n = { 0, 1, 1 } } + }, + { RIG_CONF_END, NULL, } +}; + /* NewCAT Internal Functions */ static ncboolean newcat_is_rig(RIG * rig, rig_model_t model); static int newcat_get_tx_vfo(RIG * rig, vfo_t * tx_vfo); @@ -354,37 +367,78 @@ int newcat_close(RIG *rig) { return RIG_OK; } + +/* + * rig_set_config + * + */ + int newcat_set_conf(RIG *rig, token_t token, const char *val){ - int ret = RIG_OK; if (rig == NULL){ return -RIG_EARG; } - struct newcat_priv_data *priv = rig->state.priv; - switch (token) { - case TOK_FAST_SET_CMD: - priv->fast_set_commands = (int)val; - break; + int ret = RIG_OK; + struct newcat_priv_data *priv; - default: - ret = -RIG_EINVAL; + priv = (struct newcat_priv_data*)rig->state.priv; + + if (priv == NULL){ + return -RIG_EINTERNAL; + } + + switch (token) { + case TOK_FAST_SET_CMD: ; + char *end; + long value; + //using strtol because atoi can lead to undefined behaviour + value = strtol(val, &end, 10); + if (end == val){ + return -RIG_EINVAL; + } + if ((value == 0) || (value == 1)){ + priv->fast_set_commands = (int)value; + } + else { + return -RIG_EINVAL; + } + break; + + default: + ret = -RIG_EINVAL; } return ret; } -int newcat_get_conf(RIG *rig, token_t token, char *val){ - int ret = RIG_OK; - if (rig == NULL) { +/* + * rig_get_config + * + */ + +int newcat_get_conf(RIG *rig, token_t token, char *val){ + + if (rig == NULL){ return -RIG_EARG; } - struct newcat_priv_data *priv = rig->state.priv; + int ret = RIG_OK; + struct newcat_priv_data *priv; + + priv = (struct newcat_priv_data*)rig->state.priv; + + if (priv == NULL){ + return -RIG_EINTERNAL; + } + switch (token) { case TOK_FAST_SET_CMD: - val = (char*)priv->fast_set_commands; + if (sizeof(val) < 2){ + return -RIG_ENOMEM; + } + sprintf(val, "%d", priv->fast_set_commands); break; default: ret = -RIG_EINVAL; @@ -4376,11 +4430,6 @@ int newcat_set_cmd (RIG *rig) int retry_count = 0; int rc = -RIG_EPROTO; - /* skip validation if high throughput is needed */ - if (priv->fast_set_commands == 1){ - return RIG_OK; - } - /* pick a basic quick query command for verification */ char const * const verify_cmd = RIG_MODEL_FT9000 == rig->caps->rig_model ? "AI;" : "ID;"; @@ -4394,6 +4443,12 @@ int newcat_set_cmd (RIG *rig) return rc; } + /* skip validation if high throughput is needed */ + if (priv->fast_set_commands == TRUE){ + serial_flush (&state->rigport); + return RIG_OK; + } + /* send the verification command */ rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", verify_cmd); if (RIG_OK != (rc = write_block(&state->rigport, verify_cmd, strlen(verify_cmd)))) diff --git a/yaesu/newcat.h b/yaesu/newcat.h index b5e48967c..fadf90cc9 100644 --- a/yaesu/newcat.h +++ b/yaesu/newcat.h @@ -69,6 +69,8 @@ typedef char ncboolean; .ctcss_sql = 1,\ } +extern const struct confparams newcat_cfg_params[]; + /* * future - private data * @@ -117,13 +119,6 @@ struct newcat_priv_data { * */ - /* - * configuration Tokens - * - */ - -#define TOK_FAST_SET_CMD TOKEN_BACKEND(1) - /* * newcat function definitions. * @@ -134,8 +129,8 @@ int newcat_cleanup(RIG *rig); int newcat_open(RIG *rig); int newcat_close(RIG *rig); -int newcat_set_conf(RIG *, token_t, const char *val); -int newcat_get_conf(RIG *, token_t, char *val); +int newcat_set_conf(RIG *rig, token_t token, const char *val); +int newcat_get_conf(RIG *rig, token_t token, char *val); int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq); int newcat_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);