improved & hardend newcat_set_conf and newcat_get_conf;

implemented confparams array with TOK_FAST_SET_CMD for 'fast_set_commands';
implemented .cfgparams for Yaesu FT950;
Hamlib-3.1
Tobias Wellnitz 2016-06-05 21:46:55 +00:00
rodzic eff99058d6
commit 431e884a87
4 zmienionych plików z 80 dodań i 28 usunięć

Wyświetl plik

@ -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,

Wyświetl plik

@ -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 */

Wyświetl plik

@ -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,17 +367,42 @@ 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;
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:
priv->fast_set_commands = (int)val;
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:
@ -374,17 +412,33 @@ int newcat_set_conf(RIG *rig, token_t token, const char *val){
return ret;
}
/*
* rig_get_config
*
*/
int newcat_get_conf(RIG *rig, token_t token, char *val){
int ret = RIG_OK;
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))))

Wyświetl plik

@ -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);