From c1f8b091abe305dadbf9a08777532bd1b9ce23ad Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Thu, 22 Feb 2024 08:02:41 -0600 Subject: [PATCH] Update simts990.c to work with FLRig --- simulators/simts990.c | 355 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 316 insertions(+), 39 deletions(-) diff --git a/simulators/simts990.c b/simulators/simts990.c index 506da6876..555aeeddb 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -29,9 +29,36 @@ int datamode = 0; int vfo, vfo_tx, ptt, ptt_data, ptt_mic, ptt_tune; int operatingband; int split; -int modeMain = 2; -int modeSub = 2; int keyspd = 20; +int rg0 = 50; +int rg1 = 50; +int sq0 = 0; +int sq1 = 0; +int mg = 0; +int nt0 = 0; +int nt1 = 0; +int nr0 = 0; +int nr1 = 0; +int gc0 = 0; +int gc1 = 0; +int mv0 = 0; +int mv1 = 0; +int pa0 = 0; +int pa1 = 0; +int ra0 = 0; +int ra1 = 0; +int rl0 = 0; +int rl1 = 0; +int ml = 0; +int ag0 = 0; +int ag1 = 0; +int sl0 = 0; +int sl1 = 0; +int sh0 = 0; +int sh1 = 0; +int mo0 = 0; +int mo1 = 0; +int pc = 50; #if defined(WIN32) || defined(_WIN32) @@ -107,33 +134,36 @@ int main(int argc, char *argv[]) char *pbuf; int fd = openPort(argv[1]); int freqa = 14074000, freqb = 140735000; - int modeA = 1, modeB = 2; + char modeA = '1', modeB = '2'; while (1) { hl_usleep(10); buf[0] = 0; - if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + //if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + getmyline(fd, buf); // else { return 0; } - if (strncmp(buf, "RM2", 3) == 0) + if (strncmp(buf, "AC000;", 3) == 0) + { + continue; + } + else if (strncmp(buf, "RMA2", 3) == 0) { pbuf = "RM20020;"; write(fd, pbuf, strlen(pbuf)); } - else if (strcmp(buf, "RM5;") == 0) + else if (strcmp(buf, "RM51;") == 0) { - printf("%s\n", buf); hl_usleep(mysleep * 1000); - pbuf = "RM5100000;"; + pbuf = "RM5100001;"; write(fd, pbuf, strlen(pbuf)); } else if (strcmp(buf, "AN0;") == 0) { - printf("%s\n", buf); hl_usleep(mysleep * 1000); pbuf = "AN030;"; write(fd, pbuf, strlen(pbuf)); @@ -141,7 +171,6 @@ int main(int argc, char *argv[]) else if (strcmp(buf, "IF;") == 0) { char ifbuf[256]; - printf("%s\n", buf); hl_usleep(mysleep * 1000); // pbuf = "IF000503130001000+0000000000030000000;" sprintf(ifbuf, "IF%011d1000+0000002000000000000;", freqa); @@ -195,7 +224,6 @@ int main(int argc, char *argv[]) { SNPRINTF(buf, sizeof(buf), "IS+0000;"); write(fd, buf, strlen(buf)); - printf("%s\n", buf); continue; } else if (strncmp(buf, "IS", 2) == 0) @@ -206,16 +234,18 @@ int main(int argc, char *argv[]) { SNPRINTF(buf, sizeof(buf), "SM0035;"); write(fd, buf, strlen(buf)); - printf("%s\n", buf); continue; } else if (strncmp(buf, "PC;", 3) == 0) { - SNPRINTF(buf, sizeof(buf), "PC100;"); + SNPRINTF(buf, sizeof(buf), "PC%03d;", pc); write(fd, buf, strlen(buf)); - printf("%s\n", buf); continue; } + else if (strncmp(buf, "PC", 2) == 0) + { + sscanf(buf, "PC%d", &pc); + } else if (strcmp(buf, "FW;") == 0) { //usleep(mysleep * 1000); @@ -232,7 +262,6 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "ID;") == 0) { - printf("%s\n", buf); hl_usleep(mysleep * 1000); int id = 24; SNPRINTF(buf, sizeof(buf), "ID%03d;", id); @@ -245,7 +274,6 @@ int main(int argc, char *argv[]) { if (strcmp(buf, "AI;")) { - printf("%s\n", buf); hl_usleep(mysleep * 1000); n = fprintf(fp, "%s", "AI0;"); } @@ -254,7 +282,6 @@ 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)); @@ -264,7 +291,6 @@ int main(int argc, char *argv[]) { 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)); @@ -318,7 +344,7 @@ int main(int argc, char *argv[]) { SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], buf[2] == '0' ? freqA : freqB, - buf[2] == '0' ? modeA + '0' : modeB + '0'); + buf[2] == '0' ? modeA : modeB); write(fd, buf, strlen(buf)); continue; } @@ -326,25 +352,12 @@ int main(int argc, char *argv[]) { mode_t tmpmode = buf[14]; - if (buf[2] == '0') { modeA = tmpmode - '0'; } - else { modeB = tmpmode - '0'; } + modeA = tmpmode; printf("modeA=%c, modeB=%c\n", modeA, modeB); continue; } - else if (strncmp(buf, "MD;", 3) == 0) - { - SNPRINTF(buf, sizeof(buf), "MD%d;", - modeA); // not worried about modeB yet for simulator - write(fd, buf, strlen(buf)); - continue; - } - else if (strncmp(buf, "MD", 2) == 0) - { - sscanf(buf, "MD%d", &modeA); // not worried about modeB yet for simulator - continue; - } else if (strncmp(buf, "FL;", 3) == 0) { SNPRINTF(buf, sizeof(buf), "FL%03d%03d;", filternum1, filternum2); @@ -380,13 +393,11 @@ int main(int argc, char *argv[]) { SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); write(fd, buf, strlen(buf)); - printf("%s\n", buf); continue; } else if (strncmp(buf, "DA", 2) == 0) { sscanf(buf, "DA%d", &datamode); - printf("%s\n", buf); continue; } else if (strncmp(buf, "BD;", 3) == 0) @@ -447,27 +458,293 @@ int main(int argc, char *argv[]) } else if (strncmp(buf, "OM0;", 4) == 0) { - sprintf(buf, "OM0%d;", modeMain); + sprintf(buf, "OM0%c;", modeA); write(fd, buf, strlen(buf)); } else if (strncmp(buf, "OM0", 3) == 0) { - sscanf(buf, "OM0%d", &modeMain); + modeA = buf[3]; } else if (strncmp(buf, "OM1;", 4) == 0) { - sprintf(buf, "OM1%d;", modeSub); + sprintf(buf, "OM1%c;", modeB); write(fd, buf, strlen(buf)); } else if (strncmp(buf, "OM1", 3) == 0) { - sscanf(buf, "OM1%d", &modeSub); + modeB = buf[3]; } else if (strcmp(buf, "RM;") == 0) { sprintf(buf, "RM2%04d;", 10); write(fd, buf, strlen(buf)); } + else if (strcmp(buf, "RG0;") == 0) + { + sprintf(buf, "RG0%03d;", rg0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RG0", 3) == 0) + { + sscanf(buf, "RG0%d", &rg0); + } + else if (strcmp(buf, "RG1;") == 0) + { + sprintf(buf, "RG1%03d;", rg1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RG1", 3) == 0) + { + sscanf(buf, "RG0%d", &rg1); + } + else if (strcmp(buf, "SQ0;") == 0) + { + sprintf(buf, "SQ0%03d;", sq0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SQ0", 3) == 0) + { + sscanf(buf, "SQ0%d", &sq0); + } + else if (strcmp(buf, "SQ1;") == 0) + { + sprintf(buf, "SQ1%03d;", sq1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SQ1", 3) == 0) + { + sscanf(buf, "SQ1%d", &sq1); + } + + else if (strcmp(buf, "MG;") == 0) + { + sprintf(buf, "MG%03d;", mg); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MG", 2) == 0) + { + sscanf(buf, "MG%d", &mg); + } + + else if (strcmp(buf, "ML;") == 0) + { + sprintf(buf, "ML%03d;", ml); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "ML", 2) == 0) + { + sscanf(buf, "ML%d", &ml); + } + + else if (strcmp(buf, "NT0;") == 0) + { + sprintf(buf, "NT0%03d;", nt0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "NT0", 3) == 0) + { + sscanf(buf, "NT0%d", &nt0); + } + else if (strcmp(buf, "NT1;") == 0) + { + sprintf(buf, "NT1%03d;", nt1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "NT1", 3) == 0) + { + sscanf(buf, "NT1%d", &nt1); + } + + else if (strcmp(buf, "NR0;") == 0) + { + sprintf(buf, "NR0%03d;", nr0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "NR0", 3) == 0) + { + sscanf(buf, "NR0%d", &nr0); + } + else if (strcmp(buf, "NR1;") == 0) + { + sprintf(buf, "NR1%03d;", nr1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "NR1", 3) == 0) + { + sscanf(buf, "NR1%d", &nr1); + } + + else if (strcmp(buf, "GC0;") == 0) + { + sprintf(buf, "GC0%03d;", gc0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "GC0", 3) == 0) + { + sscanf(buf, "GC0%d", &gc0); + } + else if (strcmp(buf, "GC1;") == 0) + { + sprintf(buf, "GC1%03d;", gc1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "GC1", 3) == 0) + { + sscanf(buf, "GC1%d", &gc1); + } + + else if (strcmp(buf, "MV0;") == 0) + { + sprintf(buf, "MV0%03d;", mv0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MV0", 3) == 0) + { + sscanf(buf, "MV0%d", &mv0); + } + else if (strcmp(buf, "MV1;") == 0) + { + sprintf(buf, "MV1%03d;", mv1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MV1", 3) == 0) + { + sscanf(buf, "MV1%d", &mv1); + } + + else if (strcmp(buf, "PA0;") == 0) + { + sprintf(buf, "PA0%03d;", pa0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "PA0", 3) == 0) + { + sscanf(buf, "PA0%d", &pa0); + } + else if (strcmp(buf, "PA1;") == 0) + { + sprintf(buf, "PA1%03d;", pa1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "PA1", 3) == 0) + { + sscanf(buf, "PA1%d", &pa1); + } + + else if (strcmp(buf, "RA0;") == 0) + { + sprintf(buf, "RA0%03d;", ra0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RA0", 3) == 0) + { + sscanf(buf, "RA0%d", &ra0); + } + else if (strcmp(buf, "RA1;") == 0) + { + sprintf(buf, "RA1%03d;", ra1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RA1", 3) == 0) + { + sscanf(buf, "RA1%d", &ra1); + } + + else if (strcmp(buf, "RL10;") == 0) + { + sprintf(buf, "RL10%02d;", rl0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RL10", 3) == 0) + { + sscanf(buf, "RL10%d", &rl0); + } + else if (strcmp(buf, "RL11;") == 0) + { + sprintf(buf, "RL11%02d;", rl1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "RL1", 3) == 0) + { + sscanf(buf, "RL1%d", &rl1); + } + + else if (strcmp(buf, "AG0;") == 0) + { + sprintf(buf, "AG0%03d;", ag0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "AG0", 3) == 0) + { + sscanf(buf, "AG0%d", &ag0); + } + else if (strcmp(buf, "AG1;") == 0) + { + sprintf(buf, "AG1%03d;", ag1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "AG1", 3) == 0) + { + sscanf(buf, "AG1%d", &ag1); + } + + else if (strcmp(buf, "SL0;") == 0) + { + sprintf(buf, "SL0%03d;", sl0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SL0", 3) == 0) + { + sscanf(buf, "SL0%d", &sl0); + } + else if (strcmp(buf, "SL1;") == 0) + { + sprintf(buf, "SL1%03d;", sl1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SL1", 3) == 0) + { + sscanf(buf, "SL1%d", &sl1); + } + + else if (strcmp(buf, "SH0;") == 0) + { + sprintf(buf, "SH0%03d;", sh0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SH0", 3) == 0) + { + sscanf(buf, "SH0%d", &sh0); + } + else if (strcmp(buf, "SH1;") == 0) + { + sprintf(buf, "SH1%03d;", sh1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SH1", 3) == 0) + { + sscanf(buf, "SH1%d", &sh1); + } + + else if (strcmp(buf, "MO0;") == 0) + { + sprintf(buf, "MO0%d;", mo0); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MO0", 3) == 0) + { + sscanf(buf, "MO0%d", &mo0); + } + else if (strcmp(buf, "MO1;") == 0) + { + sprintf(buf, "MO1%d;", mo1); + write(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MO1", 3) == 0) + { + sscanf(buf, "MO1%d", &mo1); + } + else if (strlen(buf) > 0) { fprintf(stderr, "Unknown command: %s\n", buf);