kopia lustrzana https://github.com/Hamlib/Hamlib
Fix FT-817/857/897 issues and add some missing functionality
Correctly read SPLIT status TX STATUS is documented incorrectly. Implement get_split_vfo () on all rigs. Allow either RTTY or PKTUSB to be set, both go to DIG mode and rig must be set appropriately. get_mode() returns what is actually set for the rig DIG mode.libusb-1-0
rodzic
aebe52a45e
commit
d438b73b8e
168
yaesu/ft817.c
168
yaesu/ft817.c
|
@ -80,7 +80,7 @@ static const yaesu_cmd_set_t ncmd[] = {
|
|||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* lock on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x80 } }, /* lock off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* ptt on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x88 } }, /* ptt off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x88 } }, /* ptt off */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* set freq */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main USB */
|
||||
|
@ -113,16 +113,26 @@ static const yaesu_cmd_set_t ncmd[] = {
|
|||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* pwr wakeup sequence */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* pwr on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x8f } }, /* pwr off */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xbb } }, /* eeprom read */
|
||||
};
|
||||
|
||||
enum ft817_digi {
|
||||
FT817_DIGI_RTTY_L = 0,
|
||||
FT817_DIGI_RTTY_U,
|
||||
FT817_DIGI_PSK_L,
|
||||
FT817_DIGI_PSK_U,
|
||||
FT817_DIGI_USER_L,
|
||||
FT817_DIGI_USER_U,
|
||||
};
|
||||
|
||||
#define FT817_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_PKTFM|\
|
||||
RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT817_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB|RIG_MODE_RTTY)
|
||||
#define FT817_CWN_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_RTTY)
|
||||
#define FT817_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM|RIG_MODE_PKTFM)
|
||||
|
||||
#define FT817_OTHER_TX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT817_AM_TX_MODES (RIG_MODE_AM)
|
||||
|
||||
#define FT817_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
|
||||
|
@ -257,7 +267,6 @@ const struct rig_caps ft817_caps = {
|
|||
|
||||
.str_cal = FT817_STR_CAL,
|
||||
|
||||
.priv = NULL,
|
||||
.rig_init = ft817_init,
|
||||
.rig_cleanup = ft817_cleanup,
|
||||
.rig_open = ft817_open,
|
||||
|
@ -266,72 +275,24 @@ const struct rig_caps ft817_caps = {
|
|||
.get_freq = ft817_get_freq,
|
||||
.set_mode = ft817_set_mode,
|
||||
.get_mode = ft817_get_mode,
|
||||
.set_vfo = NULL,
|
||||
.get_vfo = NULL,
|
||||
.set_ptt = ft817_set_ptt,
|
||||
.get_ptt = ft817_get_ptt,
|
||||
.get_dcd = ft817_get_dcd,
|
||||
.set_rptr_shift = ft817_set_rptr_shift,
|
||||
.get_rptr_shift = NULL,
|
||||
.set_rptr_offs = ft817_set_rptr_offs,
|
||||
.get_rptr_offs = NULL,
|
||||
.set_split_freq = NULL,
|
||||
.get_split_freq = NULL,
|
||||
.set_split_mode = NULL,
|
||||
.get_split_mode = NULL,
|
||||
.set_split_vfo = ft817_set_split_vfo,
|
||||
.get_split_vfo = NULL, /* possible, but works only if PTT is ON */
|
||||
.get_split_vfo = ft817_get_split_vfo,
|
||||
.set_rit = ft817_set_rit,
|
||||
.get_rit = NULL,
|
||||
.set_xit = NULL,
|
||||
.get_xit = NULL,
|
||||
.set_ts = NULL,
|
||||
.get_ts = NULL,
|
||||
.set_dcs_code = ft817_set_dcs_code,
|
||||
.get_dcs_code = NULL,
|
||||
.set_tone = NULL,
|
||||
.get_tone = NULL,
|
||||
.set_ctcss_tone = ft817_set_ctcss_tone,
|
||||
.get_ctcss_tone = NULL,
|
||||
.set_dcs_sql = ft817_set_dcs_sql,
|
||||
.get_dcs_sql = NULL,
|
||||
.set_tone_sql = NULL,
|
||||
.get_tone_sql = NULL,
|
||||
.set_ctcss_sql = ft817_set_ctcss_sql,
|
||||
.get_ctcss_sql = NULL,
|
||||
.power2mW = ft817_power2mW,
|
||||
.mW2power = ft817_mW2power,
|
||||
.set_powerstat = ft817_set_powerstat,
|
||||
.get_powerstat = NULL,
|
||||
.reset = NULL,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
.set_level = NULL,
|
||||
.get_level = ft817_get_level,
|
||||
.set_func = ft817_set_func,
|
||||
.get_func = NULL,
|
||||
.set_parm = NULL,
|
||||
.get_parm = NULL,
|
||||
.set_ext_level = NULL,
|
||||
.get_ext_level = NULL,
|
||||
.set_ext_parm = NULL,
|
||||
.get_ext_parm = NULL,
|
||||
.set_conf = NULL,
|
||||
.get_conf = NULL,
|
||||
.send_dtmf = NULL,
|
||||
.recv_dtmf = NULL,
|
||||
.send_morse = NULL,
|
||||
.set_bank = NULL,
|
||||
.set_mem = NULL,
|
||||
.get_mem = NULL,
|
||||
.vfo_op = ft817_vfo_op,
|
||||
.scan = NULL,
|
||||
.set_trn = NULL,
|
||||
.get_trn = NULL,
|
||||
.decode_event = NULL,
|
||||
.set_channel = NULL,
|
||||
.get_channel = NULL,
|
||||
/* there are some more */
|
||||
};
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
@ -411,6 +372,30 @@ static int check_cache_timeout(struct timeval *tv)
|
|||
}
|
||||
}
|
||||
|
||||
static int ft817_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out)
|
||||
{
|
||||
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
||||
unsigned char data[YAESU_CMD_LENGTH];
|
||||
int n;
|
||||
|
||||
memcpy(data, (char *)p->pcs[FT817_NATIVE_CAT_EEPROM_READ].nseq, YAESU_CMD_LENGTH);
|
||||
|
||||
data[0] = addr >> 8;
|
||||
data[1] = addr & 0xfe;
|
||||
|
||||
write_block(&rig->state.rigport, (char *) data, YAESU_CMD_LENGTH);
|
||||
|
||||
if ((n = read_block(&rig->state.rigport, (char *) data, 2)) < 0)
|
||||
return n;
|
||||
|
||||
if (n != 2)
|
||||
return -RIG_EIO;
|
||||
|
||||
*out = data[addr % 2];
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int ft817_get_status(RIG *rig, int status)
|
||||
{
|
||||
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
||||
|
@ -450,6 +435,13 @@ static int ft817_get_status(RIG *rig, int status)
|
|||
if (n != len)
|
||||
return -RIG_EIO;
|
||||
|
||||
if (status == FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS) {
|
||||
if ((n = ft817_read_eeprom(rig, 0x0065, &p->fm_status[5])) < 0)
|
||||
return n;
|
||||
|
||||
p->fm_status[5] >>= 5;
|
||||
}
|
||||
|
||||
gettimeofday(tv, NULL);
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -486,10 +478,7 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
/* set normal width now, narrow will override this later */
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
|
||||
switch (p->fm_status[4]) {
|
||||
switch (p->fm_status[4] & 0x7f) {
|
||||
case 0x00:
|
||||
*mode = RIG_MODE_LSB;
|
||||
break;
|
||||
|
@ -511,35 +500,64 @@ int ft817_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
case 0x08:
|
||||
*mode = RIG_MODE_FM;
|
||||
break;
|
||||
case 0x0A:
|
||||
*mode = RIG_MODE_RTTY;
|
||||
break;
|
||||
case 0x0a:
|
||||
switch (p->fm_status[5])
|
||||
{
|
||||
case FT817_DIGI_RTTY_L: *mode = RIG_MODE_RTTY; break;
|
||||
case FT817_DIGI_RTTY_U: *mode = RIG_MODE_RTTYR; break;
|
||||
case FT817_DIGI_PSK_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT817_DIGI_PSK_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
case FT817_DIGI_USER_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT817_DIGI_USER_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
}
|
||||
break;
|
||||
case 0x0C:
|
||||
*mode = RIG_MODE_PKTFM;
|
||||
break;
|
||||
|
||||
/* "extra modes" which are not documented in the manual */
|
||||
case 0x82:
|
||||
*mode = RIG_MODE_CW;
|
||||
*width = rig_passband_narrow (rig, RIG_MODE_CW);
|
||||
break;
|
||||
case 0x83:
|
||||
*mode = RIG_MODE_CWR;
|
||||
*width = rig_passband_narrow (rig, RIG_MODE_CW);
|
||||
break;
|
||||
case 0x8A:
|
||||
*mode = RIG_MODE_RTTY;
|
||||
*width = rig_passband_narrow (rig, RIG_MODE_CW);
|
||||
break;
|
||||
|
||||
default:
|
||||
*mode = RIG_MODE_NONE;
|
||||
}
|
||||
|
||||
if (p->fm_status[4] & 0x80) /* narrow */
|
||||
{
|
||||
*width = rig_passband_narrow (rig, *mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ft817_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
||||
{
|
||||
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
||||
int n;
|
||||
|
||||
if (vfo != RIG_VFO_CURR)
|
||||
return -RIG_ENTARGET;
|
||||
|
||||
if (check_cache_timeout(&p->tx_status_tv))
|
||||
if ((n = ft817_get_status(rig, FT817_NATIVE_CAT_GET_TX_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
if (p->tx_status & 0x80)
|
||||
{
|
||||
// TX status not valid when in RX
|
||||
unsigned char c;
|
||||
if ((n = ft817_read_eeprom(rig, 0x007a, &c)) < 0) /* get split status */
|
||||
return n;
|
||||
*split = (c & 0x80) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
*split = (p->tx_status & 0x20) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
int ft817_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt)
|
||||
{
|
||||
struct ft817_priv_data *p = (struct ft817_priv_data *) rig->state.priv;
|
||||
|
|
|
@ -106,6 +106,7 @@ enum ft817_native_cmd_e {
|
|||
FT817_NATIVE_CAT_PWR_WAKE,
|
||||
FT817_NATIVE_CAT_PWR_ON,
|
||||
FT817_NATIVE_CAT_PWR_OFF,
|
||||
FT817_NATIVE_CAT_EEPROM_READ,
|
||||
FT817_NATIVE_SIZE /* end marker */
|
||||
};
|
||||
|
||||
|
@ -126,7 +127,7 @@ struct ft817_priv_data {
|
|||
|
||||
/* freq & mode status */
|
||||
struct timeval fm_status_tv;
|
||||
unsigned char fm_status[YAESU_CMD_LENGTH];
|
||||
unsigned char fm_status[YAESU_CMD_LENGTH+1];
|
||||
};
|
||||
|
||||
/* fixme: why declare static? it has no effect */
|
||||
|
@ -152,6 +153,7 @@ static int ft817_set_rit (RIG *rig, vfo_t vfo, shortfreq_t rit);
|
|||
static int ft817_get_dcd (RIG *rig, vfo_t vfo, dcd_t *dcd);
|
||||
static int ft817_set_powerstat (RIG *rig, powerstat_t status);
|
||||
static int ft817_vfo_op (RIG *rig, vfo_t vfo, vfo_op_t op);
|
||||
static int ft817_get_split_vfo (RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo);
|
||||
static int ft817_set_split_vfo (RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo);
|
||||
static int ft817_power2mW (RIG *rig, unsigned int *mwpower, float power,
|
||||
freq_t freq, rmode_t mode);
|
||||
|
|
|
@ -84,7 +84,7 @@ static const yaesu_cmd_set_t ncmd[] = {
|
|||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* lock on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x80 } }, /* lock off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* ptt on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x88 } }, /* ptt off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x88 } }, /* ptt off */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* set freq */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main USB */
|
||||
|
@ -133,12 +133,12 @@ enum ft857_digi {
|
|||
};
|
||||
|
||||
#define FT857_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT857_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB)
|
||||
#define FT857_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM)
|
||||
|
||||
#define FT857_OTHER_TX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|\
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT857_AM_TX_MODES (RIG_MODE_AM)
|
||||
|
||||
#define FT857_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
|
||||
|
@ -255,7 +255,6 @@ const struct rig_caps ft857_caps = {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL,
|
||||
.rig_init = ft857_init,
|
||||
.rig_cleanup = ft857_cleanup,
|
||||
.rig_open = ft857_open,
|
||||
|
@ -264,46 +263,20 @@ const struct rig_caps ft857_caps = {
|
|||
.get_freq = ft857_get_freq,
|
||||
.set_mode = ft857_set_mode,
|
||||
.get_mode = ft857_get_mode,
|
||||
.set_vfo = NULL,
|
||||
.get_vfo = NULL,
|
||||
.set_ptt = ft857_set_ptt,
|
||||
.get_ptt = ft857_get_ptt,
|
||||
.get_dcd = ft857_get_dcd,
|
||||
.set_rptr_shift = ft857_set_rptr_shift,
|
||||
.get_rptr_shift = NULL,
|
||||
.set_rptr_offs = ft857_set_rptr_offs,
|
||||
.get_rptr_offs = NULL,
|
||||
.set_split_freq = NULL,
|
||||
.get_split_freq = NULL,
|
||||
.set_split_mode = NULL,
|
||||
.get_split_mode = NULL,
|
||||
.set_split_vfo = ft857_set_split_vfo,
|
||||
.get_split_vfo = ft857_get_split_vfo,
|
||||
.set_rit = ft857_set_rit,
|
||||
.get_rit = NULL,
|
||||
.set_xit = NULL,
|
||||
.get_xit = NULL,
|
||||
.set_ts = NULL,
|
||||
.get_ts = NULL,
|
||||
.set_dcs_code = ft857_set_dcs_code,
|
||||
.get_dcs_code = NULL,
|
||||
.set_ctcss_tone = ft857_set_ctcss_tone,
|
||||
.get_ctcss_tone = NULL,
|
||||
.set_dcs_sql = ft857_set_dcs_sql,
|
||||
.get_dcs_sql = NULL,
|
||||
.set_ctcss_sql = ft857_set_ctcss_sql,
|
||||
.get_ctcss_sql = NULL,
|
||||
.set_powerstat = NULL,
|
||||
.get_powerstat = NULL,
|
||||
.reset = NULL,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
.set_level = NULL,
|
||||
.get_level = ft857_get_level,
|
||||
.set_func = ft857_set_func,
|
||||
.get_func = NULL,
|
||||
.set_parm = NULL,
|
||||
.get_parm = NULL,
|
||||
.vfo_op = ft857_vfo_op,
|
||||
};
|
||||
|
||||
|
@ -490,7 +463,7 @@ int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
switch (p->fm_status[4]) {
|
||||
switch (p->fm_status[4] & 0x7f) {
|
||||
case 0x00:
|
||||
*mode = RIG_MODE_LSB;
|
||||
break;
|
||||
|
@ -498,11 +471,9 @@ int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
*mode = RIG_MODE_USB;
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x82:
|
||||
*mode = RIG_MODE_CW;
|
||||
break;
|
||||
case 0x03:
|
||||
case 0x83:
|
||||
*mode = RIG_MODE_CWR;
|
||||
break;
|
||||
case 0x04:
|
||||
|
@ -512,29 +483,34 @@ int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
*mode = RIG_MODE_WFM;
|
||||
break;
|
||||
case 0x08:
|
||||
case 0x88:
|
||||
*mode = RIG_MODE_FM;
|
||||
break;
|
||||
case 0x0a:
|
||||
case 0x8a:
|
||||
*mode = RIG_MODE_RTTY;
|
||||
if (p->fm_status[5] == FT857_DIGI_RTTY_U) {
|
||||
*mode = RIG_MODE_RTTYR;
|
||||
} else if (p->fm_status[5] == FT857_DIGI_PSK_U || p->fm_status[5] == FT857_DIGI_USER_U) {
|
||||
*mode = RIG_MODE_PKTUSB;
|
||||
} else if (p->fm_status[5] == FT857_DIGI_PSK_L || p->fm_status[5] == FT857_DIGI_USER_L) {
|
||||
*mode = RIG_MODE_PKTLSB;
|
||||
}
|
||||
switch (p->fm_status[5])
|
||||
{
|
||||
case FT857_DIGI_RTTY_L: *mode = RIG_MODE_RTTY; break;
|
||||
case FT857_DIGI_RTTY_U: *mode = RIG_MODE_RTTYR; break;
|
||||
case FT857_DIGI_PSK_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT857_DIGI_PSK_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
case FT857_DIGI_USER_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT857_DIGI_USER_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
}
|
||||
break;
|
||||
case 0x0c:
|
||||
case 0x8c:
|
||||
*mode = RIG_MODE_PKTFM;
|
||||
break;
|
||||
default:
|
||||
*mode = RIG_MODE_NONE;
|
||||
}
|
||||
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
if (p->fm_status[4] & 0x80) /* narrow */
|
||||
{
|
||||
*width = rig_passband_narrow (rig, *mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -551,7 +527,18 @@ int ft857_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
|||
if ((n = ft857_get_status(rig, FT857_NATIVE_CAT_GET_TX_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
*split = ((p->tx_status & 0x20) == 0) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
if (p->tx_status & 0x80)
|
||||
{
|
||||
// TX status not valid when in RX
|
||||
unsigned char c;
|
||||
if ((n = ft857_read_eeprom(rig, 0x008d, &c)) < 0) /* get split status */
|
||||
return n;
|
||||
*split = (c & 0x80) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
*split = (p->tx_status & 0x20) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -752,6 +739,9 @@ int ft857_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|
|||
case RIG_MODE_RTTY:
|
||||
index = FT857_NATIVE_CAT_SET_MODE_DIG;
|
||||
break;
|
||||
case RIG_MODE_PKTUSB:
|
||||
index = FT857_NATIVE_CAT_SET_MODE_DIG;
|
||||
break;
|
||||
case RIG_MODE_FM:
|
||||
index = FT857_NATIVE_CAT_SET_MODE_FM;
|
||||
break;
|
||||
|
|
112
yaesu/ft897.c
112
yaesu/ft897.c
|
@ -121,7 +121,7 @@ static const yaesu_cmd_set_t ncmd[] = {
|
|||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* lock on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x80 } }, /* lock off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x08 } }, /* ptt on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x01, 0x88 } }, /* ptt off */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x88 } }, /* ptt off */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0x01 } }, /* set freq */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main LSB */
|
||||
{ 1, { 0x01, 0x00, 0x00, 0x00, 0x07 } }, /* mode set main USB */
|
||||
|
@ -157,16 +157,25 @@ static const yaesu_cmd_set_t ncmd[] = {
|
|||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x00 } }, /* pwr wakeup sequence */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x0f } }, /* pwr on */
|
||||
{ 1, { 0x00, 0x00, 0x00, 0x00, 0x8f } }, /* pwr off */
|
||||
{ 0, { 0x00, 0x00, 0x00, 0x00, 0xbb } }, /* eeprom read */
|
||||
};
|
||||
|
||||
enum ft897_digi {
|
||||
FT897_DIGI_RTTY_L = 0,
|
||||
FT897_DIGI_RTTY_U,
|
||||
FT897_DIGI_PSK_L,
|
||||
FT897_DIGI_PSK_U,
|
||||
FT897_DIGI_USER_L,
|
||||
FT897_DIGI_USER_U,
|
||||
};
|
||||
|
||||
#define FT897_ALL_RX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|\
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT897_SSB_CW_RX_MODES (RIG_MODE_CW|RIG_MODE_CWR|RIG_MODE_USB|RIG_MODE_LSB)
|
||||
#define FT897_AM_FM_RX_MODES (RIG_MODE_AM|RIG_MODE_FM)
|
||||
|
||||
#define FT897_OTHER_TX_MODES (RIG_MODE_AM|RIG_MODE_CW|RIG_MODE_USB|\
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM)
|
||||
RIG_MODE_LSB|RIG_MODE_RTTY|RIG_MODE_FM|RIG_MODE_PKTUSB)
|
||||
#define FT897_AM_TX_MODES (RIG_MODE_AM)
|
||||
|
||||
#define FT897_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
|
||||
|
@ -281,7 +290,6 @@ const struct rig_caps ft897_caps = {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
.priv = NULL,
|
||||
.rig_init = ft897_init,
|
||||
.rig_cleanup = ft897_cleanup,
|
||||
.rig_open = ft897_open,
|
||||
|
@ -290,46 +298,20 @@ const struct rig_caps ft897_caps = {
|
|||
.get_freq = ft897_get_freq,
|
||||
.set_mode = ft897_set_mode,
|
||||
.get_mode = ft897_get_mode,
|
||||
.set_vfo = NULL,
|
||||
.get_vfo = NULL,
|
||||
.set_ptt = ft897_set_ptt,
|
||||
.get_ptt = ft897_get_ptt,
|
||||
.get_dcd = ft897_get_dcd,
|
||||
.set_rptr_shift = ft897_set_rptr_shift,
|
||||
.get_rptr_shift = NULL,
|
||||
.set_rptr_offs = ft897_set_rptr_offs,
|
||||
.get_rptr_offs = NULL,
|
||||
.set_split_freq = NULL,
|
||||
.get_split_freq = NULL,
|
||||
.set_split_mode = NULL,
|
||||
.get_split_mode = NULL,
|
||||
.set_split_vfo = ft897_set_split_vfo,
|
||||
.get_split_vfo = ft897_get_split_vfo,
|
||||
.set_rit = ft897_set_rit,
|
||||
.get_rit = NULL,
|
||||
.set_xit = NULL,
|
||||
.get_xit = NULL,
|
||||
.set_ts = NULL,
|
||||
.get_ts = NULL,
|
||||
.set_dcs_code = ft897_set_dcs_code,
|
||||
.get_dcs_code = NULL,
|
||||
.set_ctcss_tone = ft897_set_ctcss_tone,
|
||||
.get_ctcss_tone = NULL,
|
||||
.set_dcs_sql = ft897_set_dcs_sql,
|
||||
.get_dcs_sql = NULL,
|
||||
.set_ctcss_sql = ft897_set_ctcss_sql,
|
||||
.get_ctcss_sql = NULL,
|
||||
.set_powerstat = NULL,
|
||||
.get_powerstat = NULL,
|
||||
.reset = NULL,
|
||||
.set_ant = NULL,
|
||||
.get_ant = NULL,
|
||||
.set_level = NULL,
|
||||
.get_level = ft897_get_level,
|
||||
.set_func = ft897_set_func,
|
||||
.get_func = NULL,
|
||||
.set_parm = NULL,
|
||||
.get_parm = NULL,
|
||||
.vfo_op = ft897_vfo_op,
|
||||
};
|
||||
|
||||
|
@ -410,6 +392,30 @@ static int check_cache_timeout(struct timeval *tv)
|
|||
}
|
||||
}
|
||||
|
||||
static int ft897_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out)
|
||||
{
|
||||
struct ft897_priv_data *p = (struct ft897_priv_data *) rig->state.priv;
|
||||
unsigned char data[YAESU_CMD_LENGTH];
|
||||
int n;
|
||||
|
||||
memcpy(data, (char *)p->pcs[FT897_NATIVE_CAT_EEPROM_READ].nseq, YAESU_CMD_LENGTH);
|
||||
|
||||
data[0] = addr >> 8;
|
||||
data[1] = addr & 0xfe;
|
||||
|
||||
write_block(&rig->state.rigport, (char *) data, YAESU_CMD_LENGTH);
|
||||
|
||||
if ((n = read_block(&rig->state.rigport, (char *) data, 2)) < 0)
|
||||
return n;
|
||||
|
||||
if (n != 2)
|
||||
return -RIG_EIO;
|
||||
|
||||
*out = data[addr % 2];
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
static int ft897_get_status(RIG *rig, int status)
|
||||
{
|
||||
struct ft897_priv_data *p = (struct ft897_priv_data *) rig->state.priv;
|
||||
|
@ -449,6 +455,13 @@ static int ft897_get_status(RIG *rig, int status)
|
|||
if (n != len)
|
||||
return -RIG_EIO;
|
||||
|
||||
if (status == FT897_NATIVE_CAT_GET_FREQ_MODE_STATUS) {
|
||||
if ((n = ft897_read_eeprom(rig, 0x0078, &p->fm_status[5])) < 0)
|
||||
return n;
|
||||
|
||||
p->fm_status[5] >>= 5;
|
||||
}
|
||||
|
||||
gettimeofday(tv, NULL);
|
||||
|
||||
return RIG_OK;
|
||||
|
@ -485,7 +498,7 @@ int ft897_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
if ((n = ft897_get_status(rig, FT897_NATIVE_CAT_GET_FREQ_MODE_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
switch (p->fm_status[4]) {
|
||||
switch (p->fm_status[4] & 0x7f) {
|
||||
case 0x00:
|
||||
*mode = RIG_MODE_LSB;
|
||||
break;
|
||||
|
@ -493,11 +506,9 @@ int ft897_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
*mode = RIG_MODE_USB;
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x82:
|
||||
*mode = RIG_MODE_CW;
|
||||
break;
|
||||
case 0x03:
|
||||
case 0x83:
|
||||
*mode = RIG_MODE_CWR;
|
||||
break;
|
||||
case 0x04:
|
||||
|
@ -507,22 +518,34 @@ int ft897_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
|
|||
*mode = RIG_MODE_WFM;
|
||||
break;
|
||||
case 0x08:
|
||||
case 0x88:
|
||||
*mode = RIG_MODE_FM;
|
||||
break;
|
||||
case 0x0a:
|
||||
case 0x8a:
|
||||
*mode = RIG_MODE_RTTY;
|
||||
switch (p->fm_status[5])
|
||||
{
|
||||
case FT897_DIGI_RTTY_L: *mode = RIG_MODE_RTTY; break;
|
||||
case FT897_DIGI_RTTY_U: *mode = RIG_MODE_RTTYR; break;
|
||||
case FT897_DIGI_PSK_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT897_DIGI_PSK_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
case FT897_DIGI_USER_L: *mode = RIG_MODE_PKTLSB; break;
|
||||
case FT897_DIGI_USER_U: *mode = RIG_MODE_PKTUSB; break;
|
||||
}
|
||||
break;
|
||||
case 0x0c:
|
||||
case 0x8c:
|
||||
*mode = RIG_MODE_PKTFM;
|
||||
break;
|
||||
default:
|
||||
*mode = RIG_MODE_NONE;
|
||||
}
|
||||
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
if (p->fm_status[4] & 0x80) /* narrow */
|
||||
{
|
||||
*width = rig_passband_narrow (rig, *mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
*width = RIG_PASSBAND_NORMAL;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
@ -881,7 +904,18 @@ int ft897_get_split_vfo(RIG *rig, vfo_t vfo, split_t *split, vfo_t *tx_vfo)
|
|||
if ((n = ft897_get_status(rig, FT897_NATIVE_CAT_GET_TX_STATUS)) < 0)
|
||||
return n;
|
||||
|
||||
*split = ((p->tx_status & 0x20) == 0) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
if (p->tx_status & 0x80)
|
||||
{
|
||||
// TX status not valid when in RX
|
||||
unsigned char c;
|
||||
if ((n = ft897_read_eeprom(rig, 0x008d, &c)) < 0) /* get split status */
|
||||
return n;
|
||||
*split = (c & 0x80) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
*split = (p->tx_status & 0x20) ? RIG_SPLIT_ON : RIG_SPLIT_OFF;
|
||||
}
|
||||
|
||||
return RIG_OK;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ enum ft897_native_cmd_e {
|
|||
FT897_NATIVE_CAT_PWR_WAKE,
|
||||
FT897_NATIVE_CAT_PWR_ON,
|
||||
FT897_NATIVE_CAT_PWR_OFF,
|
||||
FT897_NATIVE_CAT_EEPROM_READ,
|
||||
FT897_NATIVE_SIZE /* end marker */
|
||||
};
|
||||
|
||||
|
@ -128,7 +129,7 @@ struct ft897_priv_data {
|
|||
|
||||
/* freq & mode status */
|
||||
struct timeval fm_status_tv;
|
||||
unsigned char fm_status[YAESU_CMD_LENGTH];
|
||||
unsigned char fm_status[YAESU_CMD_LENGTH+1];
|
||||
};
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue