From 24f17730f4ee4032216cb18e8a509fca73751b87 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 4 Jul 2023 17:31:07 -0500 Subject: [PATCH] Add \test command to rigctl -- first test routine is "cw" https://github.com/Hamlib/Hamlib/issues/1281 --- tests/Makefile.am | 4 ++-- tests/rig_tests.c | 30 ++++++++++++++++++++++++++++++ tests/rig_tests.h | 3 +++ tests/rigctl_parse.c | 17 +++++++++++++++++ 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/rig_tests.c create mode 100644 tests/rig_tests.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 0e3d453d8..72717b30e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,9 +17,9 @@ DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom rigctltcp rigctlsync ampctl ampctld rigtestmcast rigtestmcastrx $(TESTLIBUSB) #check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid testsecurity -check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels +check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels testmW2power -RIGCOMMONSRC = rigctl_parse.c rigctl_parse.h dumpcaps.c dumpstate.c uthash.h +RIGCOMMONSRC = rigctl_parse.c rigctl_parse.h dumpcaps.c dumpstate.c uthash.h rig_tests.c rig_tests.h ROTCOMMONSRC = rotctl_parse.c rotctl_parse.h dumpcaps_rot.c uthash.h AMPCOMMONSRC = ampctl_parse.c ampctl_parse.h dumpcaps_amp.c uthash.h diff --git a/tests/rig_tests.c b/tests/rig_tests.c new file mode 100644 index 000000000..8a8a63401 --- /dev/null +++ b/tests/rig_tests.c @@ -0,0 +1,30 @@ +#include +#include +#include + + +int rig_test_cw(RIG *rig) +{ + char *s = "SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS SOS"; + //char *s = "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST"; + int i; + ENTERFUNC; + + for (i = 0; i < strlen(s); ++i) + { + char cw[2]; + cw[0] = s[i]; + cw[1] = '\0'; + + int retval = rig_send_morse(rig, RIG_VFO_CURR, cw); + hl_usleep(100*1000); + + if (retval != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: rig_send_morse error: %s\n", __func__, + rigerror(retval)); + } + } + + RETURNFUNC(RIG_OK); +} diff --git a/tests/rig_tests.h b/tests/rig_tests.h new file mode 100644 index 000000000..7cd3e18a6 --- /dev/null +++ b/tests/rig_tests.h @@ -0,0 +1,3 @@ +#include + +int rig_test_cw(RIG *rig); diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 23e25d566..c0386bd2a 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -36,6 +36,7 @@ #include #include #include +#include // If true adds some debug statements to see flow of rigctl parsing int debugflow = 0; @@ -264,6 +265,7 @@ declare_proto_rig(set_lock_mode); declare_proto_rig(get_lock_mode); declare_proto_rig(send_raw); declare_proto_rig(client_version); +declare_proto_rig(test); /* @@ -379,6 +381,7 @@ static struct test_table test_list[] = { 0xa4, "send_raw", ACTION(send_raw), ARG_NOVFO | ARG_IN1 | ARG_IN2 | ARG_OUT3, "Terminator", "Command", "Send raw answer" }, { 0xa5, "client_version", ACTION(client_version), ARG_NOVFO | ARG_IN1, "Version", "Client version" }, { 0xa6, "get_vfo_list", ACTION(get_vfo_list), ARG_NOVFO }, + { 0xa7, "test", ACTION(test), ARG_NOVFO | ARG_IN, "routine" }, { 0x00, "", NULL }, }; @@ -2437,6 +2440,20 @@ declare_proto_rig(get_vfo_list) RETURNFUNC2(RIG_OK); } +/* '\test' */ +declare_proto_rig(test) +{ + ENTERFUNC2; + if (!strcmp(arg1, "?")) + { + fprintf(fout, "cw\n"); + RETURNFUNC2(RIG_OK); + } + if (strcmp(arg1, "cw")==0) rig_test_cw(rig); + + RETURNFUNC2(RIG_OK); +} + /* '\get_modes' */ declare_proto_rig(get_modes) {