Fix ID5100 get/set_mode

Remove ID rigs freq_len check as civ_731 setting should cover it
https://github.com/Hamlib/Hamlib/issues/1204
pull/1215/head
Mike Black W9MDB 2023-01-04 06:57:12 -06:00
rodzic 9c5809ffba
commit 138795668f
3 zmienionych plików z 62 dodań i 13 usunięć

Wyświetl plik

@ -1324,14 +1324,7 @@ int icom_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
RETURNFUNC2(retval);
}
if (ICOM_IS_ID5100 || ICOM_IS_ID4100 || ICOM_IS_ID31 || ICOM_IS_ID51)
{
freq_len = 5;
}
else
{
freq_len = priv->civ_731_mode ? 4 : 5;
}
freq_len = priv->civ_731_mode ? 4 : 5;
/*
* to_bcd requires nibble len

Wyświetl plik

@ -31,7 +31,7 @@
#include <sys/time.h>
#endif
#define BACKEND_VER "20230103"
#define BACKEND_VER "20230104"
#define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31)
#define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51)

Wyświetl plik

@ -26,6 +26,8 @@
#include "hamlib/rig.h"
#include "idx_builtin.h"
#include "icom.h"
#include "icom_defs.h"
#include "frame.h"
/*
* Specs and protocol details comes from the chapter 13 of ID-5100_Full-Inst_Manual.pdf
@ -39,7 +41,7 @@
* - Single/dual watch (RIG_LEVEL_BALANCE)
*/
#define ID5100_MODES (RIG_MODE_FM|RIG_MODE_DSTAR)
#define ID5100_MODES (RIG_MODE_AM|RIG_MODE_AMN|RIG_MODE_FM|RIG_MODE_FMN|RIG_MODE_DSTAR)
#define ID5100_ALL_RX_MODES (RIG_MODE_AM|ID5100_MODES)
#define ID5100_VFO_ALL (RIG_VFO_MAIN|RIG_VFO_SUB)
@ -70,7 +72,61 @@
*/
#define ID5100_STR_CAL UNKNOWN_IC_STR_CAL
int id5100_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
{
int retval;
unsigned char modebuf;
unsigned char ackbuf[MAXFRAMELEN];
int icmode = 2;
int ack_len = sizeof(ackbuf);
switch (mode)
{
case RIG_MODE_AM: icmode = 2; modebuf = 1; break;
case RIG_MODE_AMN: icmode = 2; modebuf = 2; break;
case RIG_MODE_FM: icmode = 5; modebuf = 1; break;
case RIG_MODE_FMN: icmode = 5; modebuf = 2; break;
case RIG_MODE_DSTAR: icmode = 17; modebuf = 1; break;
default:
rig_debug(RIG_DEBUG_ERR, "%s: Unknown mode=%s\n", __func__, rig_strrmode(mode));
return -RIG_EINVAL;
}
retval = icom_transaction(rig, C_SET_MODE, icmode, &modebuf, 1, ackbuf,
&ack_len);
return retval;
}
int id5100_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
{
int retval;
int mode_len;
unsigned char modebuf[4];
retval = icom_transaction(rig, C_RD_MODE, -1, NULL, 0, modebuf, &mode_len);
if (retval != RIG_OK)
{
return retval;
}
switch (modebuf[1])
{
case 2: *mode = modebuf[3] == 1 ? RIG_MODE_AM : RIG_MODE_AMN; break;
case 5: *mode = modebuf[3] == 1 ? RIG_MODE_FM : RIG_MODE_FMN; break;
case 17: *mode = RIG_MODE_DSTAR; break;
}
return RIG_OK;
}
/*
*/
@ -102,7 +158,7 @@ const struct rig_caps id5100_caps =
.write_delay = 0,
.post_write_delay = 0,
.timeout = 1000,
.retry = 3,
.retry = 0,
.has_get_func = ID5100_FUNC_ALL,
.has_set_func = ID5100_FUNC_ALL,
.has_get_level = ID5100_LEVEL_ALL,
@ -184,8 +240,8 @@ const struct rig_caps id5100_caps =
.set_freq = icom_set_freq,
.get_freq = icom_get_freq,
.set_mode = icom_set_mode,
.get_mode = icom_get_mode,
.set_mode = id5100_set_mode,
.get_mode = id5100_get_mode,
.set_vfo = icom_set_vfo,
.set_powerstat = icom_set_powerstat,