Read eeprom value for digital mode from FT-857

From Michal:

"I have been playing a lot recently with PSK modes using fldigi. I have
noticed that the yaesu ft-857 backend doesn't distinguish between upper
and lower sideband digital mode (menu item 38).  This causes lot of
trouble on bands where USB is used (when QSY button is pressed in
fldigi, or when calculating the real QSO frequency).

With some use of undocumented CAT features and some research I have
put together small patch, that reads EEPROM data. When SW asks hamlib
what mode is being used, hamlib will also consider the
value from eeprom.

When changing the mode in the menu, new value will become available in
the EEPROM _after_ pressing the "FUNC" button.

Setting mode from SW is left untouched, as writing to EEPROM is
potentially dangerous (and I don't feel like destroying my rig, yet)"

Signed-off-by: Nate Bargmann <n0nb@n0nb.us>
Hamlib-3.0
Michal Demin 2012-05-10 15:08:07 +02:00 zatwierdzone przez Nate Bargmann
rodzic e8d429fc45
commit de329c1ed7
2 zmienionych plików z 51 dodań i 1 usunięć

Wyświetl plik

@ -119,8 +119,17 @@ 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 ft857_digi {
FT857_DIGI_RTTY_L = 0,
FT857_DIGI_RTTY_U,
FT857_DIGI_PSK_L,
FT857_DIGI_PSK_U,
FT857_DIGI_USER_L,
FT857_DIGI_USER_U,
};
#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)
@ -134,6 +143,8 @@ static const yaesu_cmd_set_t ncmd[] = {
#define FT857_VFO_ALL (RIG_VFO_A|RIG_VFO_B)
#define FT857_ANTS 0
static int ft857_send_icmd(RIG *rig, int index, unsigned char *data);
const struct rig_caps ft857_caps = {
.rig_model = RIG_MODEL_FT857,
.model_name = "FT-857",
@ -372,6 +383,30 @@ static int check_cache_timeout(struct timeval *tv)
}
}
static int ft857_read_eeprom(RIG *rig, unsigned short addr, unsigned char *out)
{
struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
unsigned char data[YAESU_CMD_LENGTH];
int n;
memcpy(data, (char *)p->pcs[FT857_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 ft857_get_status(RIG *rig, int status)
{
struct ft857_priv_data *p = (struct ft857_priv_data *) rig->state.priv;
@ -411,6 +446,13 @@ static int ft857_get_status(RIG *rig, int status)
if (n != len)
return -RIG_EIO;
if (status == FT857_NATIVE_CAT_GET_FREQ_MODE_STATUS) {
if ((n = ft857_read_eeprom(rig, 0x0078, &p->fm_status[5])) < 0)
return n;
p->fm_status[5] >>= 5;
}
gettimeofday(tv, NULL);
return RIG_OK;
@ -475,6 +517,13 @@ int ft857_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width)
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;
}
break;
case 0x0c:
case 0x8c:

Wyświetl plik

@ -110,6 +110,7 @@ enum ft857_native_cmd_e {
FT857_NATIVE_CAT_PWR_WAKE,
FT857_NATIVE_CAT_PWR_ON,
FT857_NATIVE_CAT_PWR_OFF,
FT857_NATIVE_CAT_EEPROM_READ,
FT857_NATIVE_SIZE /* end marker */
};
@ -130,7 +131,7 @@ struct ft857_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];
};