Implement rig_get_clock for TS-890S

Should also work for TS-990S, but no H/W to test
Plus stub for set_clock.
pull/1610/head
George Baltz N3GB 2024-09-06 04:20:42 -04:00
rodzic 676c39a9d0
commit 99535c0682
4 zmienionych plików z 66 dodań i 1 usunięć

Wyświetl plik

@ -6006,6 +6006,65 @@ int kenwood_set_ext_parm(RIG *rig, hamlib_token_t token, value_t val)
RETURNFUNC(-RIG_EINVAL);
}
/*
* kenwood_set_clock
*/
int kenwood_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset)
{
return -RIG_ENIMPL;
}
/*
* kenwood_get_clock
*/
int kenwood_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset)
{
int retval;
int fields, zone;
char ans[20];
// Make sure the clock has been set at least once
retval = kenwood_transaction(rig, "CK1", ans, sizeof(ans));
if (retval != RIG_OK) {return retval;}
if (ans[3] != '1')
{
return -RIG_ENAVAIL;
}
// Get the local clock
retval = kenwood_transaction(rig, "CK0", ans, sizeof(ans));
if (retval != RIG_OK) {return retval;}
fields = sscanf(ans, "CK0%2d%2d%2d%2d%2d%2d", year, month, day, hour, min, sec);
// TS-890S doesn't define what P6 is, but it sure looks like seconds to me.
// TS-990S doesn't have a P6, so set it to 0
if (fields < 6)
{
*sec = 0;
}
// Add the century
if (*year <= 20) //TODO: Update this every decade or so
{
*year += 100;
}
*year += 2000; //TODO: Update this every century or so
// Now figure out the time zone
retval = kenwood_transaction(rig, "CK2", ans, sizeof(ans));
if (retval != RIG_OK) {return retval;}
zone = atoi(&ans[3]); // UTC offset in 15 minute intervals, centered on 56
zone = (zone / 4) * 100 + (zone % 4) * 15; // Pack as hours * 100 + minutes
*utc_offset = zone - 1400;
// No msec available
*msec = 0;
return RIG_OK;
}
int kenwood_get_ext_parm(RIG *rig, hamlib_token_t token, value_t *val)
{
int err;

Wyświetl plik

@ -264,6 +264,8 @@ int kenwood_get_id(RIG *rig, char *buf);
int kenwood_get_if(RIG *rig);
int kenwood_send_voice_mem(RIG *rig, vfo_t vfo, int bank);
int kenwood_stop_voice_mem(RIG *rig, vfo_t vfo);
int kenwood_get_clock(RIG *rig, int *year, int *month, int *day, int *hour, int *min, int *sec, double *msec, int *utc_offset);
int kenwood_set_clock(RIG *rig, int year, int month, int day, int hour, int min, int sec, double msec, int utc_offset);
int kenwood_set_trn(RIG *rig, int trn);
int kenwood_get_trn(RIG *rig, int *trn);

Wyświetl plik

@ -661,5 +661,7 @@ struct rig_caps ts890s_caps =
.has_set_func = TS890_FUNC_ALL,
.set_func = ts890_set_func,
.get_func = ts890_get_func,
.get_clock = kenwood_get_clock,
.set_clock = kenwood_set_clock,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
};

Wyświetl plik

@ -373,6 +373,8 @@ struct rig_caps ts990s_caps =
.set_powerstat = kenwood_set_powerstat,
.get_powerstat = kenwood_get_powerstat,
.reset = kenwood_reset,
.get_clock = kenwood_get_clock,
.set_clock = kenwood_set_clock,
.hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS
};
@ -381,7 +383,7 @@ struct rig_caps ts990s_caps =
*/
/*
* ts2000_get_level
* ts990s_get_level
* Assumes rig!=NULL, val!=NULL
*/