Do not crash if expected CTCSS tones not sepcified

Also added expected CTCSS tones to Icom IC-7300 capabilities.
Hamlib-3.1
Bill Somerville 2016-04-21 11:04:04 +01:00
rodzic 5c947caf53
commit 7ddb7841f6
2 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -40,7 +40,7 @@
#include "frame.h"
#include "misc.h"
#include "bandplan.h"
#include "tones.h"
/* AM Data mode needs adding - this would require one more mode 'RIG_MODE_PKTAM' to rig.h */
#define IC7300_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_SSB|RIG_MODE_RTTY|RIG_MODE_RTTYR|RIG_MODE_PKTLSB|RIG_MODE_PKTUSB)
@ -115,7 +115,7 @@ const struct rig_caps ic7300_caps = {
[LVL_RAWSTR] = { .min = { .i = 0 }, .max = { .i = 255 } },
},
.parm_gran = {},
.ctcss_list = NULL,
.ctcss_list = full_ctcss_list,
.dcs_list = NULL,
.preamp = { 10, RIG_DBLST_END, }, /* FIXME: TBC it's a guess*/
.attenuator = { 20, RIG_DBLST_END, }, /* value taken from p.45 of manual*/

Wyświetl plik

@ -2623,12 +2623,14 @@ int icom_set_ctcss_tone(RIG *rig, vfo_t vfo, tone_t tone)
caps = rig->caps;
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) {
if (caps->ctcss_list[i] == tone)
break;
if (caps->ctcss_list) {
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) {
if (caps->ctcss_list[i] == tone)
break;
}
if (caps->ctcss_list[i] != tone)
return -RIG_EINVAL;
}
if (caps->ctcss_list[i] != tone)
return -RIG_EINVAL;
/* Sent as frequency in tenth of Hz */
@ -2677,6 +2679,8 @@ int icom_get_ctcss_tone(RIG *rig, vfo_t vfo, tone_t *tone)
tone_len -= 2;
*tone = from_bcd_be(tonebuf+2, tone_len*2);
if (!caps->ctcss_list) return RIG_OK;
/* check this tone exists. That's better than nothing. */
for (i = 0; caps->ctcss_list[i] != 0 && i<52; i++) {
if (caps->ctcss_list[i] == *tone)