Patch for Icom DCS code handling

* Change magic numbers in icom_set|get_ctcss|dcs_sql|code functions to
constants defined in src/tones.h

* fix a minor bug in icom_get_dcs_code (now ignoring polarity instead of
reporting invalid DCS code when sending reverse pol. DCS code)

* introduce DCS codes to IC-R8600 rig backend

73,
Ekki, DF4OR
pull/71/head
Ekki Plicht (DF4OR) 2018-12-19 17:11:20 +01:00 zatwierdzone przez Nate Bargmann
rodzic daa52e8b10
commit 4e8ba3d6f3
3 zmienionych plików z 21 dodań i 8 usunięć

Wyświetl plik

@ -2959,7 +2959,7 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
caps = rig->caps; caps = rig->caps;
if (caps->ctcss_list) { if (caps->ctcss_list) {
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { for (i = 0; caps->ctcss_list[i] != 0 && i<FULL_CTCSS_LIST_COUNT; i++) {
if (caps->ctcss_list[i] == tone) if (caps->ctcss_list[i] == tone)
break; break;
} }
@ -3018,7 +3018,7 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
if (!caps->ctcss_list) return RIG_OK; if (!caps->ctcss_list) return RIG_OK;
/* check this tone exists. That's better than nothing. */ /* check this tone exists. That's better than nothing. */
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { for (i = 0; caps->ctcss_list[i] != 0 && i<FULL_CTCSS_LIST_COUNT; i++) {
if (caps->ctcss_list[i] == *tone) if (caps->ctcss_list[i] == *tone)
return RIG_OK; return RIG_OK;
} }
@ -3042,7 +3042,7 @@ int icom_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps; caps = rig->caps;
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { for (i = 0; caps->ctcss_list[i] != 0 && i<FULL_CTCSS_LIST_COUNT; i++) {
if (caps->ctcss_list[i] == tone) if (caps->ctcss_list[i] == tone)
break; break;
} }
@ -3097,7 +3097,7 @@ int icom_get_ctcss_sql(RIG *rig, vfo_t vfo, tone_t *tone)
*tone = from_bcd_be(tonebuf+2, tone_len*2); *tone = from_bcd_be(tonebuf+2, tone_len*2);
/* check this tone exists. That's better than nothing. */ /* check this tone exists. That's better than nothing. */
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) { for (i = 0; caps->ctcss_list[i] != 0 && i<FULL_CTCSS_LIST_COUNT; i++) {
if (caps->ctcss_list[i] == *tone) if (caps->ctcss_list[i] == *tone)
return RIG_OK; return RIG_OK;
} }
@ -3121,13 +3121,14 @@ int icom_set_dcs_code(RIG *rig, vfo_t vfo, tone_t code)
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
caps = rig->caps; caps = rig->caps;
for (i = 0; caps->dcs_list[i] != 0 && i<104; i++) { for (i = 0; caps->dcs_list[i] != 0 && i<COMMON_DCS_LIST_COUNT; i++) {
if (caps->dcs_list[i] == code) if (caps->dcs_list[i] == code)
break; break;
} }
if (caps->dcs_list[i] != code) if (caps->dcs_list[i] != code)
return -RIG_EINVAL; return -RIG_EINVAL;
/* DCS Polarity ignored, by setting code_len to 3 it's forced to 0 (= Tx:norm, Rx:norm). */
code_len = 3; code_len = 3;
to_bcd_be(codebuf, code, code_len*2); to_bcd_be(codebuf, code, code_len*2);
@ -3171,11 +3172,15 @@ int icom_get_dcs_code(RIG *rig, vfo_t vfo, tone_t *code)
return -RIG_ERJCTED; return -RIG_ERJCTED;
} }
code_len -= 2; /* buf is cn,sc, polarity, code_lo, code_hi, so code bytes start at 3, len is 2
*code = from_bcd_be(codebuf+2, code_len*2); polarity is not decoded yet, hard to do without breaking ABI
*/
code_len -= 3;
*code = from_bcd_be(codebuf+3, code_len*2);
/* check this code exists. That's better than nothing. */ /* check this code exists. That's better than nothing. */
for (i = 0; caps->dcs_list[i] != 0 && i<104; i++) { for (i = 0; caps->dcs_list[i] != 0 && i<COMMON_DCS_LIST_COUNT; i++) {
if (caps->dcs_list[i] == *code) if (caps->dcs_list[i] == *code)
return RIG_OK; return RIG_OK;
} }

Wyświetl plik

@ -265,6 +265,8 @@ const struct rig_caps icr8600_caps = {
.get_powerstat = icom_get_powerstat, .get_powerstat = icom_get_powerstat,
.set_ctcss_sql = icom_set_ctcss_sql, .set_ctcss_sql = icom_set_ctcss_sql,
.get_ctcss_sql = icom_get_ctcss_sql, .get_ctcss_sql = icom_get_ctcss_sql,
.set_dcs_sql = icom_set_dcs_code,
.get_dcs_sql = icom_get_dcs_code,
.set_channel = icr8600_set_channel, .set_channel = icr8600_set_channel,
.get_channel = icr8600_get_channel, .get_channel = icr8600_get_channel,

Wyświetl plik

@ -42,6 +42,8 @@ static const tone_t static_full_ctcss_list[] =
FULL_CTCSS_LIST FULL_CTCSS_LIST
}; };
#define FULL_CTCSS_LIST_COUNT 52
/* /*
* 50 CTCSS sub-audible tones, from 67.0Hz to 254.1Hz * 50 CTCSS sub-audible tones, from 67.0Hz to 254.1Hz
@ -63,6 +65,8 @@ static const tone_t static_common_ctcss_list[] =
COMMON_CTCSS_LIST COMMON_CTCSS_LIST
}; };
#define COMMON_CTCSS_LIST_COUNT 50
/* /*
* 104 DCS codes * 104 DCS codes
@ -84,6 +88,7 @@ static const tone_t static_common_dcs_list[] =
COMMON_DCS_LIST COMMON_DCS_LIST
}; };
#define COMMON_DCS_LIST_COUNT 104
/* /*
* 106 DCS codes * 106 DCS codes
@ -105,6 +110,7 @@ static const tone_t static_full_dcs_list[] =
FULL_DCS_LIST FULL_DCS_LIST
}; };
#define FULL_DCS_LIST_COUNT 106
/* /*
* These arrays cannot be shared on Win32 systems, * These arrays cannot be shared on Win32 systems,