Fix rigctld agc level readings -- allow for rig backedn to specify "RIG_AGC_NONE" now for clarity if desired

https://github.com/Hamlib/Hamlib/issues/1155
pull/1215/head
Mike Black W9MDB 2023-01-06 16:21:58 -06:00
rodzic db218e9e73
commit 4a487ffdcc
6 zmienionych plików z 92 dodań i 16 usunięć

1
NEWS
Wyświetl plik

@ -26,6 +26,7 @@ Version 4.6
Version 4.5.4
* 2023-XX-XX
* Fix AGC levels with rigctld
* Fix rig_power2mW so it checks all ranges
* Allow rigctld to start with autopower_on=0 to avoid startup timeouts when rig is powered off
* Fix dummy device to work with grig by disallowing empty "u" call

Wyświetl plik

@ -332,7 +332,7 @@ typedef enum {
*/
/* TODO: kill me, and replace by real AGC delay */
enum agc_level_e {
RIG_AGC_OFF = 0,
RIG_AGC_OFF = 0,
RIG_AGC_SUPERFAST,
RIG_AGC_FAST,
RIG_AGC_SLOW,
@ -340,7 +340,8 @@ enum agc_level_e {
RIG_AGC_MEDIUM,
RIG_AGC_AUTO,
RIG_AGC_LONG,
RIG_AGC_ON /*< Turns AGC ON -- Kenwood -- restores last level set */
RIG_AGC_ON, /*< Turns AGC ON -- Kenwood -- restores last level set */
RIG_AGC_NONE /*< Rig does not have CAT AGC control */
};

Wyświetl plik

@ -811,9 +811,10 @@ static int netrigctl_open(RIG *rig)
}
else if (strcmp(setting, "agc_levels") == 0)
{
int i = 1;
int i = 0;
char *p = strtok(value, " ");
rig->caps->agc_levels[0] = RIG_AGC_OFF;
rig->caps->agc_levels[0] = RIG_AGC_NONE; // default value gets overwritten
rig->caps->agc_level_count = 1;
while (p)
{
@ -823,7 +824,9 @@ static int netrigctl_open(RIG *rig)
if (n == 2)
{
if (agc_code == RIG_AGC_OFF) { p = strtok(NULL, " "); continue; } ;
rig->caps->agc_levels[i++] = agc_code;
rig->caps->agc_level_count++;
rig_debug(RIG_DEBUG_VERBOSE, "%s: rig has agc code=%d, level=%s\n", __func__,
agc_code, agc_string);
}
@ -835,8 +838,6 @@ static int netrigctl_open(RIG *rig)
rig_debug(RIG_DEBUG_VERBOSE, "%d=%s\n", agc_code, agc_string);
p = strtok(NULL, " ");
}
rig->caps->agc_level_count = i;
}
else
{
@ -2735,7 +2736,7 @@ struct rig_caps netrigctl_caps =
RIG_MODEL(RIG_MODEL_NETRIGCTL),
.model_name = "NET rigctl",
.mfg_name = "Hamlib",
.version = "20230104.0",
.version = "20230106.0",
.copyright = "LGPL",
.status = RIG_STATUS_STABLE,
.rig_type = RIG_TYPE_OTHER,

Wyświetl plik

@ -12,6 +12,10 @@
float freqA = 14074000;
float freqB = 14074500;
char tx_vfo = '0';
char rx_vfo = '0';
char modeA = '0';
char modeB = '0';
// ID 0310 == 310, Must drop leading zero
typedef enum nc_rigid_e
@ -104,7 +108,7 @@ int main(int argc, char *argv[])
{
printf("Cmd:%s\n", buf);
}
else { return 0; }
else { continue; }
if (strcmp(buf, "RM5;") == 0)
{
@ -137,6 +141,24 @@ int main(int argc, char *argv[])
if (n <= 0) { perror("IF"); }
}
else if (strcmp(buf, "FA;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FA%08.0f;", freqA);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FA", 2) == 0)
{
sscanf(buf, "FA%f", &freqA);
}
else if (strcmp(buf, "FB;") == 0)
{
SNPRINTF(buf, sizeof(buf), "FB%08.0f;", freqB);
n = write(fd, buf, strlen(buf));
}
else if (strncmp(buf, "FB", 2) == 0)
{
sscanf(buf, "FB%f", &freqB);
}
else if (strcmp(buf, "ID;") == 0)
{
printf("%s\n", buf);
@ -148,6 +170,11 @@ int main(int argc, char *argv[])
if (n <= 0) { perror("ID"); }
}
else if (strcmp(buf, "PS;") == 0)
{
SNPRINTF(buf, sizeof(buf), "PS1;");
n = write(fd, buf, strlen(buf));
}
else if (strcmp(buf, "AI;") == 0)
{
printf("%s\n", buf);
@ -158,6 +185,54 @@ int main(int argc, char *argv[])
if (n <= 0) { perror("ID"); }
}
else if (strcmp(buf, "AI0;") == 0)
{
usleep(50 * 1000);
}
else if (strcmp(buf, "FT;") == 0)
{
usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "FT%c;", tx_vfo);
printf(" FT response#1=%s, tx_vfo=%c\n", buf, tx_vfo);
n = write(fd, buf, strlen(buf));
printf(" FT response#2=%s\n", buf);
if (n < 0) { perror("FT"); }
}
else if (strncmp(buf, "FT", 2) == 0)
{
tx_vfo = buf[2];
if (tx_vfo == '3') { tx_vfo = '1'; }
else if (tx_vfo == '2') { tx_vfo = '0'; }
else { perror("Expected 2 or 3"); }
}
else if (strcmp(buf, "MD0;") == 0)
{
usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD0%c;", modeA);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("MD0;"); }
}
else if (strncmp(buf, "MD0", 3) == 0)
{
modeA = buf[3];
}
else if (strcmp(buf, "MD1;") == 0)
{
usleep(50 * 1000);
SNPRINTF(buf, sizeof(buf), "MD1%c;", modeB);
n = write(fd, buf, strlen(buf));
if (n < 0) { perror("MD0;"); }
}
else if (strncmp(buf, "MD1", 3) == 0)
{
modeB = buf[3];
}
#if 0
else if (strncmp(buf, "AI", 2) == 0)

Wyświetl plik

@ -1282,6 +1282,7 @@ static const struct
{ RIG_AGC_AUTO, "AUTO" },
{ RIG_AGC_LONG, "LONG" },
{ RIG_AGC_ON, "ON" },
{ RIG_AGC_NONE, "NONE" },
{ -1, "" },
};

Wyświetl plik

@ -296,7 +296,6 @@ int dumpcaps(RIG *rig, FILE *fout)
fprintf(fout, "\n");
#if 0
fprintf(fout, "AGC levels:");
const struct icom_priv_caps *priv_caps =
(const struct icom_priv_caps *) rig->caps->priv;
@ -313,6 +312,7 @@ int dumpcaps(RIG *rig, FILE *fout)
}
else
{
for (i = 0; i < HAMLIB_MAX_AGC_LEVELS && i < caps->agc_level_count; i++)
{
fprintf(fout, " %d=%s", caps->agc_levels[i],
@ -320,16 +320,13 @@ int dumpcaps(RIG *rig, FILE *fout)
}
}
#else
//fprintf(fout, "\n");
fprintf(fout, "AGC levels: ");
char buf[1024];
rig_sprintf_agc_levels(rig, buf, (int)sizeof(buf));
fprintf(fout, "%s", buf);
#endif
fprintf(fout, "\n");
if (i == 0)
{
rig_debug(RIG_DEBUG_WARN,
"%s: defaulting to all levels since rig does not have any\n", __func__);
// Fall back to printing out all levels for backwards-compatibility
for (i = RIG_AGC_OFF; i <= RIG_AGC_LAST; i++)
{