astyle files prepping for 4.1 release

pull/518/head
Michael Black W9MDB 2021-01-15 16:48:32 -06:00
rodzic 28c7ee7f88
commit 598b105e79
8 zmienionych plików z 140 dodań i 80 usunięć

Wyświetl plik

@ -715,7 +715,7 @@ int icom_get_usb_echo_off(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s: ack_len=%d\n", __func__, ack_len);
if (retval == -RIG_ETIMEOUT) return retval;
if (retval == -RIG_ETIMEOUT) { return retval; }
if (retval == RIG_OK)
{

Wyświetl plik

@ -342,7 +342,7 @@ int dwtdll_cleanup(RIG *rig)
struct dwtdll_priv_data *priv = (struct dwtdll_priv_data *)rig->state.priv;
/* Clean up the dll access */
if (priv) FreeLibrary(priv->dll);
if (priv) { FreeLibrary(priv->dll); }
if (rig->state.priv)
{

Wyświetl plik

@ -345,7 +345,7 @@ int elektor507_cleanup(RIG *rig)
rig->state.priv;
/* Clean up the dll access */
if (priv) FreeLibrary(priv->extra_priv.dll);
if (priv) { FreeLibrary(priv->extra_priv.dll); }
if (rig->state.priv)
{

Wyświetl plik

@ -272,7 +272,7 @@ int g3_cleanup(RIG *rig)
struct g3_priv_data *priv = (struct g3_priv_data *)rig->state.priv;
/* Clean up the dll access */
if (priv) FreeLibrary(priv->dll);
if (priv) { FreeLibrary(priv->dll); }
if (rig->state.priv)
{

Wyświetl plik

@ -540,6 +540,7 @@ int newcat_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%s: rig_id=%d\n", __func__, priv->rig_id);
#if 0 // possible future enhancement?
// some rigs have a CAT TOT timeout that defaults to 10ms
// so we'll increase CAT timeout to 100ms
if (priv->rig_id == NC_RIGID_FT2000
@ -550,9 +551,11 @@ int newcat_open(RIG *rig)
{
int err;
char *cmd = "EX0291%c";
if (priv->rig_id == NC_RIGID_FT950) cmd = "EX0271%c";
else if (priv->rig_id == NC_RIGID_FT891) cmd = "EX05071c";
else if (priv->rig_id == NC_RIGID_FT991) cmd = "EX0321c";
if (priv->rig_id == NC_RIGID_FT950) { cmd = "EX0271%c"; }
else if (priv->rig_id == NC_RIGID_FT891) { cmd = "EX05071c"; }
else if (priv->rig_id == NC_RIGID_FT991) { cmd = "EX0321c"; }
snprintf(priv->cmd_str, sizeof(priv->cmd_str), cmd, cat_term);
if (RIG_OK != (err = newcat_set_cmd(rig)))
@ -560,6 +563,7 @@ int newcat_open(RIG *rig)
return err;
}
}
#endif
rig_debug(RIG_DEBUG_VERBOSE, "%s: returning RIG_OK\n", __func__);
@ -813,7 +817,8 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
if (RIG_OK != (err = newcat_set_cmd(rig)))
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#1=%s\n", __func__,
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#1=%s\n",
__func__,
rigerror(err));
}
else
@ -822,17 +827,25 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
// is redundant for rigs where band stack includes both vfos
vfo_t vfotmp;
err = rig_get_vfo(rig, &vfotmp);
if (err != RIG_OK) return err;
if (err != RIG_OK) { return err; }
err = rig_set_vfo(rig, vfotmp == RIG_VFO_MAIN ? RIG_VFO_SUB : RIG_VFO_MAIN);
if (err != RIG_OK) return err;
if (err != RIG_OK) { return err; }
if (RIG_OK != (err = newcat_set_cmd(rig)))
{
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#2=%s\n", __func__,
rig_debug(RIG_DEBUG_ERR, "%s: Unexpected error with BS command#2=%s\n",
__func__,
rigerror(err));
}
// switch back to the starting vfo
err = rig_set_vfo(rig, vfotmp == RIG_VFO_MAIN ? RIG_VFO_MAIN : RIG_VFO_SUB);
if (err != RIG_OK) return err;
if (err != RIG_OK) { return err; }
// after band select re-read things -- may not have to change anything
freq_t tmp_freqA, tmp_freqB;
rmode_t tmp_mode;
@ -841,10 +854,12 @@ int newcat_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
rig_get_freq(rig, RIG_VFO_SUB, &tmp_freqB);
rig_get_mode(rig, RIG_VFO_MAIN, &tmp_mode, &tmp_width);
rig_get_mode(rig, RIG_VFO_SUB, &tmp_mode, &tmp_width);
if ((target_vfo == 0 && tmp_freqA == freq)
|| (target_vfo == 1 && tmp_freqB == freq))
{
rig_debug(RIG_DEBUG_VERBOSE, "%s: freq after band select already set to %"PRIfreq"\n", __func__, freq);
rig_debug(RIG_DEBUG_VERBOSE,
"%s: freq after band select already set to %"PRIfreq"\n", __func__, freq);
return RIG_OK; // we're done then!!
}
}
@ -3309,7 +3324,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
break;
case RIG_LEVEL_IF: {
case RIG_LEVEL_IF:
{
pbwidth_t width;
rmode_t mode = 0;
@ -3362,11 +3378,13 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
// Some Yaesu rigs reject this command in AM/FM modes
if (is_ft991 || is_ftdx5000 || is_ftdx101)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN || mode & RIG_MODE_FMN)
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN)
{
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -3415,7 +3433,8 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KS%03d%c", val.i, cat_term);
break;
case RIG_LEVEL_MICGAIN: {
case RIG_LEVEL_MICGAIN:
{
pbwidth_t width;
rmode_t mode = 0;
@ -3449,6 +3468,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -3655,6 +3675,7 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
priv->cmd_str[2] = main_sub_vfo;
}
}
break;
case RIG_LEVEL_COMP:
@ -4087,7 +4108,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
cat_term);
break;
case RIG_LEVEL_IF: {
case RIG_LEVEL_IF:
{
pbwidth_t width;
rmode_t mode = 0;
@ -4112,11 +4134,13 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
// Some Yaesu rigs reject this command in AM/FM modes
if (is_ft991 || is_ftdx5000 || is_ftdx101)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN || mode & RIG_MODE_FMN)
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN)
{
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -4138,7 +4162,8 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
snprintf(priv->cmd_str, sizeof(priv->cmd_str), "KS%c", cat_term);
break;
case RIG_LEVEL_MICGAIN: {
case RIG_LEVEL_MICGAIN:
{
pbwidth_t width;
rmode_t mode = 0;
@ -4162,6 +4187,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -4966,7 +4992,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
switch (func)
{
case RIG_FUNC_ANF: {
case RIG_FUNC_ANF:
{
pbwidth_t width;
rmode_t mode = 0;
@ -4996,10 +5023,12 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
case RIG_FUNC_MN: {
case RIG_FUNC_MN:
{
pbwidth_t width;
rmode_t mode = 0;
@ -5029,6 +5058,7 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -5120,7 +5150,8 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
break;
case RIG_FUNC_NR: {
case RIG_FUNC_NR:
{
pbwidth_t width;
rmode_t mode = 0;
@ -5150,10 +5181,12 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
case RIG_FUNC_COMP: {
case RIG_FUNC_COMP:
{
pbwidth_t width;
rmode_t mode = 0;
@ -5182,12 +5215,14 @@ int newcat_set_func(RIG *rig, vfo_t vfo, setting_t func, int status)
// Some Yaesu rigs reject this command in AM/FM/RTTY modes
if (is_ft991 || is_ftdx5000 || is_ftdx101)
{
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN || mode & RIG_MODE_FMN ||
if (mode & RIG_MODE_AM || mode & RIG_MODE_FM || mode & RIG_MODE_AMN
|| mode & RIG_MODE_FMN ||
mode & RIG_MODE_RTTY || mode & RIG_MODE_RTTYR)
{
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -5263,7 +5298,8 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
switch (func)
{
case RIG_FUNC_ANF: {
case RIG_FUNC_ANF:
{
pbwidth_t width;
rmode_t mode = 0;
@ -5292,6 +5328,7 @@ int newcat_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
priv->question_mark_response_means_rejected = 1;
}
}
break;
}
@ -9259,6 +9296,7 @@ int newcat_get_cmd(RIG *rig)
while (rc != RIG_OK && retry_count++ <= state->rigport.retry)
{
rig_flush(&state->rigport); /* discard any unsolicited data */
if (rc != -RIG_BUSBUSY)
{
/* send the command */
@ -9326,6 +9364,7 @@ int newcat_get_cmd(RIG *rig)
break; /* retry */
case '?':
/* The ? response is ambiguous and undocumented by Yaesu, but for get commands it seems to
* indicate that the rig rejected the command because the state of the rig is not valid for the command
* or that the command parameter is invalid. Retrying the command does not fix the issue,
@ -9346,7 +9385,8 @@ int newcat_get_cmd(RIG *rig)
*/
if (priv->question_mark_response_means_rejected)
{
rig_debug(RIG_DEBUG_ERR, "%s: Command rejected by the rig (get): '%s'\n", __func__,
rig_debug(RIG_DEBUG_ERR, "%s: Command rejected by the rig (get): '%s'\n",
__func__,
priv->cmd_str);
return -RIG_ERJCTED;
}
@ -9404,6 +9444,7 @@ int newcat_set_cmd_validate(RIG *rig)
int rc = -RIG_EPROTO;
rig_debug(RIG_DEBUG_TRACE, "%s: priv->cmd_str=%s\n", __func__, priv->cmd_str);
if ((strncmp(priv->cmd_str, "FA", 2) == 0) && (strlen(priv->cmd_str) > 3))
{
strcpy(valcmd, "FA;");
@ -9439,6 +9480,7 @@ int newcat_set_cmd_validate(RIG *rig)
rig_debug(RIG_DEBUG_ERR, "%s: %s not implemented\n", __func__, priv->cmd_str);
return -RIG_ENIMPL;
}
while (rc != RIG_OK && retry++ < retries)
{
int bytes;
@ -9446,28 +9488,38 @@ int newcat_set_cmd_validate(RIG *rig)
rig_flush(&state->rigport); /* discard any unsolicited data */
snprintf(cmd, sizeof(cmd), "%s%s", priv->cmd_str, valcmd);
rc = write_block(&state->rigport, cmd, strlen(cmd));
if (rc != RIG_OK) return -RIG_EIO;
if (rc != RIG_OK) { return -RIG_EIO; }
bytes = read_string(&state->rigport, priv->ret_data, sizeof(priv->ret_data),
&cat_term, sizeof(cat_term));
if (strncmp(priv->cmd_str,"FT",2)==0 && strncmp(priv->ret_data,"FT",2)==0)
if (strncmp(priv->cmd_str, "FT", 2) == 0
&& strncmp(priv->ret_data, "FT", 2) == 0)
{
// FT command does not echo what's sent so we just check the basic command
return RIG_OK;
}
if (strncmp(priv->cmd_str,"TX",2)==0 && strncmp(priv->ret_data,"TX",2)==0)
if (strncmp(priv->cmd_str, "TX", 2) == 0
&& strncmp(priv->ret_data, "TX", 2) == 0)
{
// TX command does not echo what's sent so we just check the basic command
return RIG_OK;
}
if (bytes > 0)
{
// if they match we are validated
if (strcmp(priv->cmd_str, priv->ret_data)==0) return RIG_OK;
else rc = -RIG_EPROTO;
if (strcmp(priv->cmd_str, priv->ret_data) == 0) { return RIG_OK; }
else { rc = -RIG_EPROTO; }
}
rig_debug(RIG_DEBUG_ERR, "%s: cmd validation failed, '%s'!='%s', try#%d\n", __func__, priv->cmd_str, priv->ret_data, retry);
rig_debug(RIG_DEBUG_ERR, "%s: cmd validation failed, '%s'!='%s', try#%d\n",
__func__, priv->cmd_str, priv->ret_data, retry);
hl_usleep(sleepms * 1000);
}
return -RIG_EPROTO;
}
/*
@ -9498,7 +9550,9 @@ int newcat_set_cmd(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "cmd_str = %s\n", priv->cmd_str);
rc = newcat_set_cmd_validate(rig);
if (rc==RIG_OK) {
if (rc == RIG_OK)
{
rig_debug(RIG_DEBUG_TRACE, "%s: cmd_validate OK\n", __func__);
return RIG_OK;
}
@ -9507,7 +9561,9 @@ int newcat_set_cmd(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: set_cmd_validate failed\n", __func__);
return rc;
}
rig_debug(RIG_DEBUG_TRACE, "%s: newcat_set_cmd_validate not implemented...continuing\n", __func__);
rig_debug(RIG_DEBUG_TRACE,
"%s: newcat_set_cmd_validate not implemented...continuing\n", __func__);
if (RIG_OK != (rc = write_block(&state->rigport, priv->cmd_str,
strlen(priv->cmd_str))))
@ -9522,7 +9578,8 @@ int newcat_set_cmd(RIG *rig)
}
if (strncmp(priv->cmd_str, "BS", 2) == 0)
{ // the BS command needs time to do it's thing
{
// the BS command needs time to do it's thing
hl_usleep(200 * 1000);
priv->cache_start.tv_sec = 0; // invalidate the cache
}
@ -9596,7 +9653,8 @@ int newcat_set_cmd(RIG *rig)
*/
if (priv->question_mark_response_means_rejected)
{
rig_debug(RIG_DEBUG_ERR, "%s: Command rejected by the rig (set): '%s'\n", __func__,
rig_debug(RIG_DEBUG_ERR, "%s: Command rejected by the rig (set): '%s'\n",
__func__,
priv->cmd_str);
return -RIG_ERJCTED;
}

Wyświetl plik

@ -1636,6 +1636,7 @@ int HAMLIB_API parse_hoststr(char *hoststr, char host[256], char port[6])
// Handle device names 1st
if (strstr(hoststr, "/dev")) { return -1; }
if (strstr(hoststr, "/")) { return -1; } // posible path -- no hostname starts with /
if (strncasecmp(hoststr, "com", 3) == 0) { return -1; }

Wyświetl plik

@ -428,7 +428,8 @@ RIG *HAMLIB_API rig_init(rig_model_t rig_model)
// if we don't have list1 we'll try list2
if (rs->rx_range_list == NULL)
{
rig_debug(RIG_DEBUG_TRACE, "%s: rx_range_list1 is empty, using rx_range_list2\n", __func__);
rig_debug(RIG_DEBUG_TRACE,
"%s: rx_range_list1 is empty, using rx_range_list2\n", __func__);
memcpy(rs->tx_range_list, caps->rx_range_list2,
sizeof(struct freq_range_list)*FRQRANGESIZ);
memcpy(rs->rx_range_list, caps->tx_range_list2,