kopia lustrzana https://github.com/Hamlib/Hamlib
Merge pull request #1722 from N0NB/aclog_get_freq-thousands_separator
Avoid truncating AC Log frequencies above 1 GHzpull/1725/head
commit
fe3bb8b84a
|
@ -19,6 +19,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -421,9 +422,14 @@ static rmode_t modeMapGetHamlib(const char *modeACLog)
|
|||
/*
|
||||
* aclog_get_freq
|
||||
* Assumes rig!=NULL, STATE(rig)->priv!=NULL, freq!=NULL
|
||||
*
|
||||
* string='<CMD><READBMFRESPONSE><BAND>23</BAND><MODE>SSB</MODE><MODETEST>PH</MODETEST><FREQ>1,296.171100</FREQ></CMD> '
|
||||
*/
|
||||
static int aclog_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
||||
{
|
||||
int i, j = 0;
|
||||
char f_string[32];
|
||||
|
||||
char value[MAXARGLEN];
|
||||
struct aclog_priv_data *priv = (struct aclog_priv_data *) STATE(rig)->priv;
|
||||
|
||||
|
@ -461,7 +467,30 @@ static int aclog_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
|
|||
char *p = strstr(value, "<FREQ>");
|
||||
*freq = 0;
|
||||
|
||||
if (p) { sscanf(p, "<FREQ>%'lf", freq); }
|
||||
if (p)
|
||||
{
|
||||
// Move the pointer to the first digit.
|
||||
p += strlen("<FREQ>");
|
||||
|
||||
// Parse "1,296.171100" ignoring the comma.
|
||||
for (i = 0; p[i] != '<'; i++)
|
||||
{
|
||||
if (isdigit(p[i]))
|
||||
{
|
||||
f_string[j++] = p[i];
|
||||
}
|
||||
else if (ispunct(p[i]) && p[i] == '.')
|
||||
{
|
||||
f_string[j++] = p[i];
|
||||
}
|
||||
}
|
||||
|
||||
f_string[j] = '\0';
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: f_string=%s\n", __func__, f_string);
|
||||
|
||||
*freq = strtold(f_string, NULL);
|
||||
rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq);
|
||||
}
|
||||
|
||||
*freq *= 1e6; // convert from MHz to Hz
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue