Add ctcss_list and dcs_list to rigctld so rigcctld caps reflects the connected rig

https://github.com/Hamlib/Hamlib/issues/659
pull/691/head
Mike Black W9MDB 2021-04-29 10:49:29 -05:00
rodzic 4e60ebf1d6
commit 386b08dc4f
21 zmienionych plików z 131 dodań i 42 usunięć

Wyświetl plik

@ -214,6 +214,8 @@ typedef struct s_rig RIG;
*
* Digitally-Coded Squelch codes are simple direct integers.
*/
#define CTCSS_LIST_SIZE 60
#define DCS_LIST_SIZE 128
typedef unsigned int tone_t;
@ -1639,8 +1641,8 @@ struct rig_caps {
const struct confparams *extfuncs; /*!< Extension func list, \sa ext.c */
int *ext_tokens; /*!< Extension token list */
const tone_t *ctcss_list; /*!< CTCSS tones list, zero ended */
const tone_t *dcs_list; /*!< DCS code list, zero ended */
tone_t *ctcss_list; /*!< CTCSS tones list, zero ended */
tone_t *dcs_list; /*!< DCS code list, zero ended */
int preamp[HAMLIB_MAXDBLSTSIZ]; /*!< Preamp list in dB, 0 terminated */
int attenuator[HAMLIB_MAXDBLSTSIZ]; /*!< Preamp list in dB, 0 terminated */

Wyświetl plik

@ -41,7 +41,7 @@
#include "dummy.h"
#define CMD_MAX 64
#define BUF_MAX 96
#define BUF_MAX 1024
#define CHKSCN1ARG(a) if ((a) != 1) return -RIG_EPROTO; else do {} while(0)
@ -198,6 +198,48 @@ static int netrigctl_cleanup(RIG *rig)
return RIG_OK;
}
int parse_array_int(const char *s, const char *delim, int *array, int array_len)
{
char *p;
char *dup = strdup(s);
char *rest = dup;
int n=0;
ENTERFUNC;
while((p = strtok_r(rest, delim, &rest)))
{
if (n == array_len) { // too many items
return n;
}
array[n] = atoi(p);
//printf("%d\n", array[n]);
++n;
}
free(dup);
return n;
}
int parse_array_double(const char *s, const char *delim, double *array, int array_len)
{
char *p;
char *dup = strdup(s);
char *rest = dup;
int n=0;
ENTERFUNC;
while((p = strtok_r(rest, delim, &rest)))
{
if (n == array_len) { // too many items
return n;
}
array[n] = atof(p);
//printf("%f\n", array[n]);
++n;
}
free(dup);
return n;
}
static int netrigctl_open(RIG *rig)
{
int ret, len, i;
@ -576,7 +618,7 @@ static int netrigctl_open(RIG *rig)
do
{
char setting[32], value[256];
char setting[32], value[1024];
ret = read_string(&rig->state.rigport, buf, BUF_MAX, "\n", 1);
strtok(buf, "\r\n"); // chop the EOL
@ -587,7 +629,7 @@ static int netrigctl_open(RIG *rig)
if (strncmp(buf, "done", 4) == 0) { return RIG_OK; }
if (sscanf(buf, "%31[^=]=%255[^\t\n]", setting, value) == 2)
if (sscanf(buf, "%31[^=]=%1024[^\t\n]", setting, value) == 2)
{
if (strcmp(setting, "vfo_ops") == 0)
{
@ -679,7 +721,7 @@ static int netrigctl_open(RIG *rig)
if (!has) { rig->caps->power2mW = NULL; }
}
else if (strcmp(setting, "has_mw2power") == 0)
else if (strcmp(setting, "has_mW2power") == 0)
{
int has = strtol(value, NULL, 0);
@ -692,6 +734,26 @@ static int netrigctl_open(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: timeout value = '%s', final timeout=%d\n",
__func__, value, rig->caps->timeout);
}
else if (strcmp(setting, "ctcss_list") == 0)
{
int i;
int n;
double ctcss[CTCSS_LIST_SIZE];
rig->caps->ctcss_list = calloc(CTCSS_LIST_SIZE, sizeof(tone_t));
n = parse_array_double(value, " \n\r", ctcss, CTCSS_LIST_SIZE);
for(i=0;i<CTCSS_LIST_SIZE && ctcss[i] != 0;++i) rig->caps->ctcss_list[i] = ctcss[i]*10;
if (n < CTCSS_LIST_SIZE) rig->caps->ctcss_list[n] = 0;
}
else if (strcmp(setting,"dcs_list") == 0)
{
int i;
int n;
int dcs[DCS_LIST_SIZE+1];
rig->caps->dcs_list = calloc(DCS_LIST_SIZE, sizeof(tone_t));
n = parse_array_int(value, " \n\r", dcs, DCS_LIST_SIZE);
for(i=0;i<DCS_LIST_SIZE && dcs[i] != 0; i++) rig->caps->dcs_list[i] = dcs[i];
if (n < DCS_LIST_SIZE) rig->caps->dcs_list[n] = 0;
}
else
{
// not an error -- just a warning for backward compatibility

Wyświetl plik

@ -157,7 +157,7 @@ rmode_t kenwood_mode_table[KENWOOD_MODE_TABLE_MAX] =
/*
* 38 CTCSS sub-audible tones
*/
const tone_t kenwood38_ctcss_list[] =
tone_t kenwood38_ctcss_list[] =
{
670, 719, 744, 770, 797, 825, 854, 885, 915, 948,
974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318,
@ -170,7 +170,7 @@ const tone_t kenwood38_ctcss_list[] =
/*
* 42 CTCSS sub-audible tones
*/
const tone_t kenwood42_ctcss_list[] =
tone_t kenwood42_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915, 948,
974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318,
@ -184,7 +184,7 @@ const tone_t kenwood42_ctcss_list[] =
*
* See enum rig_conf_e and struct confparams in rig.h
*/
const struct confparams kenwood_cfg_params[] =
struct confparams kenwood_cfg_params[] =
{
{
TOK_FINE, "fine", "Fine", "Fine step mode",

Wyświetl plik

@ -50,7 +50,7 @@
#define TOK_FUNC_FILTER_WIDTH_DATA TOKEN_BACKEND(6) // Data communications mode that affects SL/SH/FW commands
/* Token structure assigned to .cfgparams in rig_caps */
extern const struct confparams kenwood_cfg_params[];
extern struct confparams kenwood_cfg_params[];
/*
@ -173,8 +173,8 @@ struct kenwood_priv_data
extern rmode_t kenwood_mode_table[KENWOOD_MODE_TABLE_MAX];
extern const tone_t kenwood38_ctcss_list[];
extern const tone_t kenwood42_ctcss_list[];
extern tone_t kenwood38_ctcss_list[];
extern tone_t kenwood42_ctcss_list[];
int kenwood_transaction(RIG *rig, const char *cmdstr, char *data, size_t datasize);
int kenwood_safe_transaction(RIG *rig, const char *cmd, char *buf,

Wyświetl plik

@ -130,8 +130,8 @@ const struct rig_caps pihpsdr_caps =
.parm_gran = {},
.vfo_ops = PIHPSDR_VFO_OP,
.scan_ops = PIHPSDR_SCAN_OP,
.ctcss_list = static_common_ctcss_list,
.dcs_list = static_common_dcs_list,
.ctcss_list = common_ctcss_list,
.dcs_list = common_dcs_list,
.preamp = { 20, RIG_DBLST_END, }, /* FIXME: real preamp? */
.attenuator = { 20, RIG_DBLST_END, },
.max_rit = kHz(20),

Wyświetl plik

@ -71,7 +71,7 @@
.dcs_sql=1,
/* CTCSS 01..42 */
static const tone_t thf6_ctcss_list[] =
static tone_t thf6_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,

Wyświetl plik

@ -65,7 +65,7 @@
.dcs_sql=1,
/* CTCSS 01..42 */
static const tone_t thf7_ctcss_list[] =
static tone_t thf7_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,

Wyświetl plik

@ -65,7 +65,7 @@ static int ts2000_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan);
/*
* 38 CTCSS sub-audible tones + 1750 tone
*/
const tone_t ts2000_ctcss_list[] =
tone_t ts2000_ctcss_list[] =
{
670, 719, 744, 770, 797, 825, 854, 885, 915, 948,
974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, 1318,
@ -79,7 +79,7 @@ const tone_t ts2000_ctcss_list[] =
/*
* 103 available DCS codes
*/
static const tone_t ts2000_dcs_list[] =
tone_t ts2000_dcs_list[] =
{
23, 25, 26, 31, 32, 36, 43, 47, 51, 53,
54, 65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131,

Wyświetl plik

@ -76,7 +76,7 @@
* Don't even touch a single bit! indexes will be used in the protocol!
* 51 tones, the 60.0 Hz tone is missing.
*/
const tone_t pcr_ctcss_list[] =
tone_t pcr_ctcss_list[] =
{
670, 693, 710, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,
@ -91,7 +91,7 @@ const tone_t pcr_ctcss_list[] =
* Don't even touch a single bit! indexes will be used in the protocol!
* 104 codes
*/
const tone_t pcr_dcs_list[] =
tone_t pcr_dcs_list[] =
{
23, 25, 26, 31, 32, 36, 43, 47, 51, 53,
54, 65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131,

Wyświetl plik

@ -81,8 +81,8 @@ struct pcr_priv_caps
#define pcr_caps(rig) ((struct pcr_priv_caps *)(rig)->caps->priv)
extern const tone_t pcr_ctcss_list[];
extern const tone_t pcr_dcs_list[];
extern tone_t pcr_ctcss_list[];
extern tone_t pcr_dcs_list[];
int pcr_init(RIG *rig);
int pcr_cleanup(RIG *rig);

Wyświetl plik

@ -53,7 +53,7 @@
{ 255, 60 }, \
} }
static const tone_t bc898_ctcss_list[] =
static tone_t bc898_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,

Wyświetl plik

@ -55,7 +55,7 @@ uniden_id_string_list[] =
};
const tone_t uniden_ctcss_list[] =
tone_t uniden_ctcss_list[] =
{
670, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230,
@ -64,7 +64,7 @@ const tone_t uniden_ctcss_list[] =
2418, 2503, 0
};
const tone_t uniden_dcs_list[] =
tone_t uniden_dcs_list[] =
{
23, 25, 26, 31, 32, 36, 43, 47, 51, 53,
54, 65, 71, 72, 73, 74, 114, 115, 116, 122,

Wyświetl plik

@ -51,11 +51,11 @@
{ 255, 60 }, \
} }
extern const tone_t uniden_ctcss_list[];
extern const tone_t uniden_dcs_list[];
extern tone_t uniden_ctcss_list[];
extern tone_t uniden_dcs_list[];
int uniden_transaction (RIG *rig, const char *cmdstr, int cmd_len,
const char *replystr, char *data, size_t *datasize);
const char *replystr, char *data, size_t *datasize);
int uniden_set_freq(RIG *rig, vfo_t vfo, freq_t freq);
int uniden_get_freq(RIG *rig, vfo_t vfo, freq_t *freq);
int uniden_get_freq_2(RIG *rig, vfo_t vfo, freq_t *freq);

Wyświetl plik

@ -120,7 +120,7 @@ static const yaesu_cmd_set_t ncmd[] =
};
static const tone_t ft100_ctcss_list[] =
static tone_t ft100_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915, \
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273, \
@ -129,7 +129,7 @@ static const tone_t ft100_ctcss_list[] =
2503, 0
};
static const tone_t ft100_dcs_list[] =
static tone_t ft100_dcs_list[] =
{
23, 25, 26, 31, 32, 36, 43, 47, 51, 53, \
54, 65, 71, 72, 73, 74, 114, 115, 116, 122, 125, 131, \

Wyświetl plik

@ -157,7 +157,7 @@ static const yaesu_cmd_set_t ncmd[] =
/**
* 33 CTCSS sub-audible tones
*/
static const tone_t ft1000mp_ctcss_list[] =
static tone_t ft1000mp_ctcss_list[] =
{
670, 719, 770, 825, 885,
948, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,

Wyświetl plik

@ -80,7 +80,7 @@ static int ft736_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone);
/* Some tones are present twice, the second value is
* higher Q (80), according to manual.
*/
static const tone_t ft736_ctcss_list[] =
static tone_t ft736_ctcss_list[] =
{
670, 719, 770, 825, 885, 948, 1000, 1035, 1072, 1109,
1148, 1188, 1230, 1273, 1318, 1365, 1413, 1462, 1514, 1567,

Wyświetl plik

@ -249,7 +249,7 @@ struct ft767_priv_data
unsigned char ack_cmd[5];
};
const tone_t static_767gx_ctcss_list[] =
tone_t static_767gx_ctcss_list[] =
{
CTCSS_TONE_LIST
};

Wyświetl plik

@ -193,7 +193,7 @@ static const yaesu_cmd_set_t ncmd[] =
* 39 CTCSS sub-audible tones
* c.f. ft847_set_ctcss_tone()
*/
static const tone_t ft847_ctcss_list[] =
static tone_t ft847_ctcss_list[] =
{
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,

Wyświetl plik

@ -44,7 +44,7 @@
/**
* 52 CTCSS sub-audible tones
*/
const tone_t full_ctcss_list[] = { FULL_CTCSS_LIST };
tone_t full_ctcss_list[] = { FULL_CTCSS_LIST };
/**
* 50 CTCSS sub-audible tones, from 67.0Hz to 254.1Hz
@ -53,17 +53,17 @@ const tone_t full_ctcss_list[] = { FULL_CTCSS_LIST };
* backends depend on it. If you need to, create a copy for your
* own caps. --SF
*/
const tone_t common_ctcss_list[] = { COMMON_CTCSS_LIST };
tone_t common_ctcss_list[] = { COMMON_CTCSS_LIST };
/**
* 104 DCS codes
*/
const tone_t common_dcs_list[] = { COMMON_DCS_LIST };
tone_t common_dcs_list[] = { COMMON_DCS_LIST };
/**
* 106 DCS codes
*/
const tone_t full_dcs_list[] = { FULL_DCS_LIST };
tone_t full_dcs_list[] = { FULL_DCS_LIST };
#endif

Wyświetl plik

@ -37,10 +37,12 @@
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541, \
0,
#if 0
static const tone_t static_full_ctcss_list[] =
{
FULL_CTCSS_LIST
};
#endif
#define FULL_CTCSS_LIST_COUNT 52
@ -60,10 +62,12 @@ static const tone_t static_full_ctcss_list[] =
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541, \
0,
#if 0
static const tone_t static_common_ctcss_list[] =
{
COMMON_CTCSS_LIST
};
#endif
#define COMMON_CTCSS_LIST_COUNT 50
@ -83,10 +87,12 @@ static const tone_t static_common_ctcss_list[] =
662, 664, 703, 712, 723, 731, 732, 734, 743, 754, \
0,
#if 0
static const tone_t static_common_dcs_list[] =
{
COMMON_DCS_LIST
};
#endif
#define COMMON_DCS_LIST_COUNT 104
@ -105,10 +111,12 @@ static const tone_t static_common_dcs_list[] =
662, 664, 703, 712, 723, 731, 732, 734, 743, 754, \
0,
#if 0
static const tone_t static_full_dcs_list[] =
{
FULL_DCS_LIST
};
#endif
#define FULL_DCS_LIST_COUNT 106
@ -124,10 +132,10 @@ static const tone_t static_full_dcs_list[] =
#else
extern const HAMLIB_EXPORT_VAR(tone_t) full_ctcss_list[];
extern const HAMLIB_EXPORT_VAR(tone_t) common_ctcss_list[];
extern const HAMLIB_EXPORT_VAR(tone_t) full_dcs_list[];
extern const HAMLIB_EXPORT_VAR(tone_t) common_dcs_list[];
extern HAMLIB_EXPORT_VAR(tone_t) full_ctcss_list[];
extern HAMLIB_EXPORT_VAR(tone_t) common_ctcss_list[];
extern HAMLIB_EXPORT_VAR(tone_t) full_dcs_list[];
extern HAMLIB_EXPORT_VAR(tone_t) common_dcs_list[];
#endif

Wyświetl plik

@ -4350,6 +4350,23 @@ declare_proto_rig(dump_state)
fprintf(fout, "has_power2mW=%d\n", rig->caps->power2mW != NULL);
fprintf(fout, "has_mW2power=%d\n", rig->caps->mW2power != NULL);
fprintf(fout, "timeout=%d\n", rig->caps->timeout);
fprintf(fout, "ctcss_list=");
for (i = 0; i < CTCSS_LIST_SIZE && rig->caps->ctcss_list[i] != 0; i++)
{
fprintf(fout,
" %u.%1u",
rig->caps->ctcss_list[i] / 10, rig->caps->ctcss_list[i] % 10);
}
fprintf(fout, "\n");
fprintf(fout, "dcs_list=");
for (i = 0; i < DCS_LIST_SIZE && rig->caps->dcs_list[i] != 0; i++)
{
fprintf(fout,
" %u",
rig->caps->dcs_list[i]);
}
fprintf(fout, "\n");
fprintf(fout, "done\n");
}