Merge pull request #1511 from GeoBaltz/fix11

Clean up ts890.c & simts890.c
pull/1513/head
Michael Black 2024-02-13 16:15:23 -06:00 zatwierdzone przez GitHub
commit 2b22a42e73
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 64 dodań i 19 usunięć

Wyświetl plik

@ -194,16 +194,13 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
levelint = ackbuf[2] - '0'; /* atoi */
if (levelint >= 0 && levelint < rig->caps->agc_level_count)
{
val->i = rig->caps->agc_levels[levelint];
}
else
if (levelint < 0 || levelint >= rig->caps->agc_level_count)
{
rig_debug(RIG_DEBUG_ERR, "%s: unknown agc value: %s\n", __func__, ackbuf);
return -RIG_EPROTO;
}
val->i = rig->caps->agc_levels[levelint];
return RIG_OK;
case RIG_LEVEL_ALC:
@ -292,7 +289,7 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
case RIG_LEVEL_RFPOWER_METER_WATTS:
{
cal_table_float_t *table;
ptt_t ptt;
ptt_t ptt = RIG_PTT_OFF;
/* Values taken from the TS-890S In-Depth Manual (IDM), p. 8
* 0.03 - 21.5 MHz, Preamp 1
*/
@ -360,7 +357,7 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
if (level == RIG_LEVEL_RFPOWER_METER_WATTS)
{
val->f = rig_raw2val(val->i, &power_meter);
val->f = roundf(rig_raw2val(val->i, &power_meter));
}
else
{
@ -476,7 +473,6 @@ static struct kenwood_priv_caps ts890s_priv_caps =
/*
* TS-890S rig capabilities
* Copied from ts480_caps, many of the values have not been verified.
* Notice that some rigs share the same functions.
*/
struct rig_caps ts890s_caps =

Wyświetl plik

@ -21,8 +21,6 @@ struct ip_mreq
int mysleep = 20;
float freqA = 14074000;
float freqB = 14074500;
int filternum1 = 7;
int filternum2 = 8;
int datamode = 0;
@ -108,12 +106,45 @@ int main(int argc, char *argv[])
int fd = openPort(argv[1]);
int freqa = 14074000, freqb = 140735000;
int modeA = 1, modeB = 2;
int cmd_err = 0;
char *err_txt[] = { "?;", "E;", "O;" };
/* The IF command is not documented for the TS-890S, and is supposed
* to be supplanted by SF. However, it is still there for legacy S/W.
* This description is taken from the TS-590S/SG manual, with values
* reflecting a real TS-890S.
*/
char IFformat[] = "IF" // Output only
"%011d" // P1 freq(Hz)
" " // P2 ??
" 0000" // P3 RIT/XIT freq(Hz)
"0" // P4 RIT on/off
"0" // P5 XIT on/off
"000" // P6,P7 mem channel
"%1d" // P8 RX/TX
"%1X" // P9 Operating mode (See MD command)
"0" // P10 Function?
"0" // P11 Scan status?
"0" // P12 Simplex/Split
"0" // P13 Tone/CTCSS (not on TS-890S)
"00" // P14 Tone/CTCSS freq (not on TS-890S)
"0;"; // P15 Always zero
char SFformat[] = "SF" // Input/Output
"%1d" // P1 VFOA/VFOB
"%011d" // P2 Freq(Hz)
"%1X;"; // P3 Mode
while (1)
{
hl_usleep(10);
buf[0] = 0;
/* Clean up from last continue - pass along any errors found */
if (cmd_err != 0)
{
write(fd, err_txt[cmd_err - 1], strlen(err_txt[cmd_err - 1]));
cmd_err = 0;
}
if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); }
// else { return 0; }
@ -144,7 +175,9 @@ int main(int argc, char *argv[])
printf("%s\n", buf);
hl_usleep(mysleep * 1000);
// pbuf = "IF000503130001000+0000000000030000000;"
sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa);
// sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa);
sprintf(ifbuf, IFformat, freqa,
(ptt + ptt_mic + ptt_data + ptt_tune) > 0 ? 1 : 0, modeA);
//pbuf = "IF00010138698 +00000000002000000 ;
write(fd, ifbuf, strlen(ifbuf));
continue;
@ -297,21 +330,38 @@ int main(int argc, char *argv[])
}
else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0)
{
SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2],
buf[2] == '0' ? freqA : freqB,
buf[2] == '0' ? modeA + '0' : modeB + '0');
int tmpvfo = buf[2] - '0';
SNPRINTF(buf, sizeof(buf), SFformat, tmpvfo,
tmpvfo == 0 ? freqa : freqb,
tmpvfo == 0 ? modeA : modeB);
write(fd, buf, strlen(buf));
continue;
}
else if (strncmp(buf, "SF", 2) == 0)
{
mode_t tmpmode = buf[14];
int tmpvfo, tmpfreq;
mode_t tmpmode;
if (buf[2] == '0') { modeA = tmpmode - '0'; }
else { modeB = tmpmode - '0'; }
if (sscanf(buf, SFformat, &tmpvfo, &tmpfreq, &tmpmode) != 3)
{
printf("Error decoding SF:%s\n", buf);
cmd_err = 1;
continue;
}
printf("modeA=%c, modeB=%c\n", modeA, modeB);
//printf("tmpvfo=%d, tmpfreq=%d, tmpmode=%d\n", tmpvfo, tmpfreq, tmpmode);
if (tmpvfo == 0)
{
modeA = tmpmode;
freqa = tmpfreq;
}
else
{
modeB = tmpmode;
freqb = tmpfreq;
}
printf("modeA=%X, modeB=%X\n", modeA, modeB);
continue;
}
else if (strncmp(buf, "MD;", 3) == 0)
@ -454,7 +504,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "Unknown command: %s\n", buf);
}
}
return 0;