From 4ef5bd414293e310d2e161232adc3cae88d6b070 Mon Sep 17 00:00:00 2001 From: George Baltz N3GB Date: Thu, 1 Feb 2024 16:18:24 -0500 Subject: [PATCH 1/2] Add calibration table for TS-890S RFPOWER_METER_WATTS Make sure we only get RFPOWER_WATTS during xmit, and STRENGTH during receive; else return -RIG_ENAVAIL. --- rigs/kenwood/ts890s.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/rigs/kenwood/ts890s.c b/rigs/kenwood/ts890s.c index 05c3dc9a9..4de3ee9df 100644 --- a/rigs/kenwood/ts890s.c +++ b/rigs/kenwood/ts890s.c @@ -292,6 +292,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; /* Values taken from the TS-890S In-Depth Manual (IDM), p. 8 * 0.03 - 21.5 MHz, Preamp 1 */ @@ -311,6 +312,20 @@ int kenwood_ts890_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) {48, 20}, {59, 40}, {70, 60} } }; + static cal_table_t power_meter = + { + 7, { { 0, 0}, { 5, 5}, { 10, 10}, {19, 25}, + { 35, 50}, { 59, 100}, { 70, 150} + } + }; + + /* Make sure we're asking the right question */ + kenwood_get_ptt(rig, vfo, &ptt); + if ((ptt == RIG_PTT_OFF) != (level == RIG_LEVEL_STRENGTH)) + { + /* We're sorry, the number you have dialed is not in service */ + return -RIG_ENAVAIL; + } /* Find out which meter type is in use */ retval = kenwood_safe_transaction(rig, "EX00011", ackbuf, sizeof(ackbuf), 11); @@ -345,7 +360,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 = round(val->i / 70.0 * 150); + val->f = rig_raw2val(val->i, &power_meter); } else { From b6dc6110a61e53b91f2a44a41eb1857246b425d9 Mon Sep 17 00:00:00 2001 From: George Baltz N3GB Date: Thu, 1 Feb 2024 17:29:10 -0500 Subject: [PATCH 2/2] Bring simts890.c a little closer to the real thing Still needs more work. --- simulators/simts890.c | 51 +++++++++++-------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) diff --git a/simulators/simts890.c b/simulators/simts890.c index f1d42e2b2..b6746e706 100644 --- a/simulators/simts890.c +++ b/simulators/simts890.c @@ -1,5 +1,5 @@ // can run this using rigctl/rigctld and socat pty devices -// gcc -o simyaesu simyaesu.c +// gcc -o simts890 -l hamlib simts890.c #define _XOPEN_SOURCE 700 // since we are POSIX here we need this #if 0 @@ -149,24 +149,24 @@ int main(int argc, char *argv[]) write(fd, ifbuf, strlen(ifbuf)); continue; } - else if (strcmp(buf, "NB;") == 0) + else if (strcmp(buf, "NB1;") == 0) { hl_usleep(mysleep * 1000); - pbuf = "NB0;"; + pbuf = "NB10;"; write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "RA;") == 0) { hl_usleep(mysleep * 1000); - pbuf = "RA01;"; + pbuf = "RA1;"; /* -6dB */ write(fd, pbuf, strlen(pbuf)); continue; } else if (strcmp(buf, "RG;") == 0) { hl_usleep(mysleep * 1000); - pbuf = "RG055;"; + pbuf = "RG255;"; write(fd, pbuf, strlen(pbuf)); continue; } @@ -187,7 +187,7 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "FV;") == 0) { hl_usleep(mysleep * 1000); - pbuf = "FV1.2;"; + pbuf = "FV1.04;"; write(fd, pbuf, strlen(pbuf)); continue; } @@ -216,14 +216,12 @@ int main(int argc, char *argv[]) printf("%s\n", buf); continue; } - else if (strcmp(buf, "FW;") == 0) + else if (strcmp(buf, "FW1;") == 0) { //usleep(mysleep * 1000); - pbuf = "FW240"; + pbuf = "FW10;"; write(fd, pbuf, strlen(pbuf)); hl_usleep(20 * 1000); - pbuf = "0;"; - write(fd, pbuf, strlen(pbuf)); continue; } else if (strncmp(buf, "FW", 2) == 0) @@ -252,30 +250,12 @@ int main(int argc, char *argv[]) } #endif - else if (strcmp(buf, "VS;") == 0) - { - printf("%s\n", buf); - hl_usleep(mysleep * 1000); - pbuf = "VS0;"; - write(fd, pbuf, strlen(pbuf)); - continue; - } else if (strcmp(buf, "EX00011;") == 0) { pbuf = "EX00011 001;"; write(fd, pbuf, strlen(pbuf)); continue; } - else if (strcmp(buf, "EX032;") == 0) - { - static int ant = 0; - ant = (ant + 1) % 3; - printf("%s\n", buf); - hl_usleep(mysleep * 1000); - SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); - write(fd, buf, strlen(buf)); - continue; - } else if (strncmp(buf, "EX", 2) == 0) { continue; @@ -315,11 +295,6 @@ int main(int argc, char *argv[]) write(fd, buf, strlen(buf)); continue; } - else if (strncmp(buf, "SA;", 3) == 0) - { - SNPRINTF(buf, sizeof(buf), "SA0;"); - write(fd, buf, strlen(buf)); - } else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) { SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], @@ -413,13 +388,13 @@ int main(int argc, char *argv[]) switch (buf[2]) { - case ';': ptt = 1; - - case '0': ptt_mic = 1; - + case ';': + case '0': ptt = ptt_mic = 1; + break; case '1': ptt_data = 1; - + break; case '2': ptt_tune = 1; + break; } continue;