From d0b19252343ab4c584db3467b39de5dcce701309 Mon Sep 17 00:00:00 2001 From: George Baltz N3GB Date: Mon, 4 Nov 2024 16:09:24 -0500 Subject: [PATCH] Annotate legacy (undocumented) commands in simts890.c Allow them to be disabled Relevant to issues #1380 and #899 --- simulators/simts890.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/simulators/simts890.c b/simulators/simts890.c index 8f41bff99..f1ab8f6c3 100644 --- a/simulators/simts890.c +++ b/simulators/simts890.c @@ -21,7 +21,16 @@ struct ip_mreq #include //#include +/* Definitions */ +/* The TS-890S has some undocumented commands, left over from older + * Kenwood models. They have newer counterparts with more functionality, + * but are still around for legacy software. If you want to see if your + * app is only using the latest-and-greatest, comment out the next define. + */ +#define LEGACY +// Size of command buffer #define BUFSIZE 256 +// Number of selectable bands #define NBANDS 11 /* Type we're emulating - K=The Americas(default), E=Europe */ #if !defined(TYPE) @@ -30,6 +39,7 @@ struct ip_mreq /* Define a macro for sending response back to the app * This will allow us to reroute output to a buffering routine * Needed to handle multiple commands in a single message + * Also makes it easy to trace */ #if defined(TRACE) #define OUTPUT(s) {printf("Resp:\"%s\"\n", s); write(fd, s, strlen(s)); } @@ -251,6 +261,7 @@ int main(int argc, char *argv[]) kvfop_t *const vfoAB[2] = {&vfoA, &vfoB}; // 0=A, 1=B, fixed kvfop_t *vfoLR[2] = {&vfoA, &vfoB}; // 0=Left, 1=Right, can change +#if defined(LEGACY) /* 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 @@ -312,12 +323,16 @@ int main(int argc, char *argv[]) buf[1] = toupper(buf[1]); if (strcmp(buf, "IF;") == 0) - { + { // Reads the tranceiver status +#if defined(LEGACY) char ifbuf[256]; hl_usleep(mysleep * 1000); sprintf(ifbuf, IFformat, (*vfoLR[0])->freq, (ptt + ptt_mic + ptt_data + ptt_tune) > 0 ? 1 : 0, (*vfoLR[0])->mode, sp); OUTPUT(ifbuf); +#else + cmd_err = 1; +#endif } else if (strncmp(buf, "AN", 2) == 0) { @@ -938,6 +953,22 @@ int main(int argc, char *argv[]) sscanf(&buf[3], "%1X", &(*vfoLR[idx])->mode); } } + else if (strncmp(buf, "MD", 2) == 0) + { // Sets and reads the operating mode status +#if defined(LEGACY) + if (buf[2] == ';') + { + snprintf(buf, sizeof(buf), "MD%X;", (*vfoLR[0])->mode); + OUTPUT(buf); + } + else + { + sscanf(buf, "MD%1X", &(*vfoLR[0])->mode); + } +#else + cmd_err = 1; +#endif + } else if (strncmp(buf, "RM", 2) == 0) { // Meter