[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. bb87d92f43f2f0599e1e5
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2023-11-19 06:42:06
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Hamlib -- Ham radio control libraries". The branch, master has been updated via bb87d92f43f2f0599e1e573907daf33a6b50286f (commit) via eff7d97c64c1ae43179487ebb245098fa0deb3da (commit) via 58fdb4423f3645b2847809d5371520f506348690 (commit) via 85f828b19f80c169f8e0a0669c27d1860dee40f2 (commit) via 41a1da795cbb7670a11e146d4464451a2d4be330 (commit) via deebca4eaf3fa0e00d6b886c33b9ca36eaba1353 (commit) via 7d9ef323d76e72bcdc6ba0f6684ab97873ad9e92 (commit) via 43545e171a6bbd366e40891cb0349256aaf17b46 (commit) via 16488d3267b93219c70bc302d63a05b9dd54b38d (commit) via c1780b19f4a30697588da277db579825f3698516 (commit) via cb34dc3b207022410d8c44971e285997c05a29c1 (commit) via 4f0393d6add63b0c1460d3f36d32376c5e12116d (commit) via e8d387d51c552c014b19fc2acebfc4b3de871d13 (commit) via 1fce7ced5be4701a067cf4a9e52b88ac9c0f5922 (commit) via 512c82649e4f80d696938bd7843ea8fa2b2444ca (commit) via c348632b262c17121867457f685d06a3111727a2 (commit) via 8478367223f611a4fbc2e677a577664c5611db9c (commit) via f57b7cba71e48dfb3aef258f5e492d2cf06db711 (commit) via 723b835fdde16c774deaa51ba2be39e47436d0e5 (commit) via d868f1a545a753f1b8b1c47b30ae0383b3ff4483 (commit) via 394cb4cbcf53971ac5f5e2ede0b0c488be989528 (commit) via b1b567d64a7d65584377926fa0818fde3b6abf18 (commit) via 176c49240d5d3006a02db2d2db4ef84c6209825b (commit) via e05b79acd311caf0c2c9a14a8711881566a1362a (commit) via e19bdc3d564a774afa853bf8ba9f16a543b68942 (commit) from e7786cee4c4e15aeba8a551622342f4b090a3059 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bb87d92f43f2f0599e1e573907daf33a6b50286f Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Nov 18 10:39:58 2023 -0600 Update simts950 and simts990 diff --git a/simulators/simts950.c b/simulators/simts950.c index bcf8f8053..c0296fce6 100644 --- a/simulators/simts950.c +++ b/simulators/simts950.c @@ -391,6 +391,10 @@ int main(int argc, char *argv[]) continue; } + else if (strcmp(buf, "RX;") == 0) + { + ptt = ptt_mic = ptt_data = ptt_tune = 0; + } else if (strlen(buf) > 0) { fprintf(stderr, "Unknown command: %s\n", buf); diff --git a/simulators/simts990.c b/simulators/simts990.c index a3198b475..24d265e9b 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -394,6 +394,10 @@ int main(int argc, char *argv[]) { continue; } + else if (strcmp(buf, "RX;") == 0) + { + ptt = ptt_mic = ptt_data = ptt_tune = 0; + } else if (strncmp(buf, "TX", 2) == 0) { ptt = ptt_mic = ptt_data = ptt_tune = 0; commit eff7d97c64c1ae43179487ebb245098fa0deb3da Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Nov 17 00:07:04 2023 -0600 Update rigctl.1 diff --git a/doc/man1/rigctl.1 b/doc/man1/rigctl.1 index 6937cb267..771051601 100644 --- a/doc/man1/rigctl.1 +++ b/doc/man1/rigctl.1 @@ -1282,11 +1282,11 @@ option above, will terminate each command string sent to the radio. This character should not be a part of the input string. . .TP -.BR W ", " send_cmd_rx " \(aq" \fICmd\fP\(aq " " \fI[nbytes or terminator char\FP +.BR W ", " send_cmd_rx " \(aq" \fICmd\fP\(aq " " \fInbytes_or_terminator_char\fP Send a raw command string to the radio and expect nbytes returned or the terminator char (e.g. ;). .IP This is useful for testing and troubleshooting radio commands and responses when -developing a backend. If the # of bytes requested is <= the number actually returned no timeout will occur. +developing a backend. If the # of bytes requested is <= the number actually returned no timeout will occur. If a char is provided it will be used to terminate reading the string so ';' is popular for Kenwood/Yaesu commands for example. .IP The command argument can have no spaces in it. For binary protocols enter values as \\0xAA\\0xBB. Expect a commit 58fdb4423f3645b2847809d5371520f506348690 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 16:37:03 2023 -0600 Add callback.c test diff --git a/tests/callback.c b/tests/callback.c new file mode 100644 index 000000000..57cada2af --- /dev/null +++ b/tests/callback.c @@ -0,0 +1,42 @@ +int callback(const struct rig_caps *caps, rig_ptr_t rigp) +{ + RIG *rig = (RIG *) rigp; + + rig = rig_init(caps->rig_model); + + if (!rig) + { + fprintf(stderr, "Unknown rig num: %u\n", caps->rig_model); + fprintf(stderr, "Please check riglist.h\n"); + exit(1); /* whoops! something went wrong (mem alloc?) */ + } + + const char *port = "/dev/pts/3"; + strcpy(rig->state.rigport.pathname, port); + + printf("%20s:", caps->model_name); + fflush(stdout); + struct timeval start, end; + gettimeofday(&start, NULL); + rig_open(rig); + gettimeofday(&end, NULL); + double dstart = start.tv_sec + start.tv_usec / 1e6; + double dend = end.tv_sec + end.tv_usec / (double)1e6; + printf(" %.1f\n", dend - dstart); + + rig_close(rig); /* close port */ + rig_cleanup(rig); /* if you care about memory */ + return 1; +} + +int main(int argc, char *argv[]) +{ + RIG rig; + printf("testing rig timeouts when rig powered off\n"); + + /* Turn off backend debugging output */ + rig_set_debug_level(RIG_DEBUG_NONE); + rig_load_all_backends(); + rig_list_foreach(callback, &rig); + return 0; +} commit 85f828b19f80c169f8e0a0669c27d1860dee40f2 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 16:33:32 2023 -0600 Add sim.h diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 2370ff947..ccdb2957e 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -7462,7 +7462,8 @@ int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) case RIG_FUNC_DUAL_WATCH: if ((RIG_IS_IC9100) || - (RIG_IS_IC9700)) + (RIG_IS_IC9700) || + (RIG_IS_ID5100)) { fct_cn = C_CTL_FUNC; fct_sc = S_MEM_DUALMODE; diff --git a/rigs/icom/id5100.c b/rigs/icom/id5100.c index 613ebcf9a..637fe7afc 100644 --- a/rigs/icom/id5100.c +++ b/rigs/icom/id5100.c @@ -154,7 +154,7 @@ int id5100_set_vfo(RIG *rig, vfo_t vfo) if (vfo == RIG_VFO_A || vfo == RIG_VFO_B) { // and 0x25 works in this mode - priv->x25cmdfails = 0; + priv->x25cmdfails = 1; if (priv->dual_watch) { @@ -222,6 +222,24 @@ int id5100_set_split_vfo(RIG *rig, vfo_t vfo, split_t split, vfo_t tx_vfo) return retval; } +int id5100_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status) +{ + unsigned char ackbuf[MAXFRAMELEN]; + int ack_len = sizeof(ackbuf), retval; + int fct_cn, fct_sc; /* Command Number, Subcommand */ + unsigned char fctbuf[MAXFRAMELEN]; + int fct_len = 0; + + const struct icom_priv_caps *priv_caps = rig->caps->priv; + const struct cmdparams *extcmds = priv_caps->extcmds; + int i; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + ENTERFUNC; + + value_t value; + RETURNFUNC(icom_get_func(rig, vfo, func, status)); +} /* */ static struct icom_priv_caps id5100_priv_caps = @@ -237,7 +255,7 @@ const struct rig_caps id5100_caps = RIG_MODEL(RIG_MODEL_ID5100), .model_name = "ID-5100", .mfg_name = "Icom", - .version = BACKEND_VER ".6", + .version = BACKEND_VER ".7", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_MOBILE, @@ -344,7 +362,7 @@ const struct rig_caps id5100_caps = .decode_event = icom_decode_event, .set_func = icom_set_func, - .get_func = icom_get_func, + .get_func = id5100_get_func, .set_level = icom_set_level, .get_level = icom_get_level, .set_parm = icom_set_parm, diff --git a/simulators/sim.h b/simulators/sim.h new file mode 100644 index 000000000..fda16b2e7 --- /dev/null +++ b/simulators/sim.h @@ -0,0 +1,20 @@ +#include "../src/misc.h" +#include <errno.h> + +#define WRITE(f,b,l) write_sim(f,(const unsigned char*)b,l,__func__,__LINE__) + +int write_sim(int fd, const unsigned char *buf, int buflen, const char *func, + int linenum) +{ + int n; + dump_hex(buf, buflen); + n = write(fd, buf, buflen); + + if (n <= 0) + { + fprintf(stderr, "%s(%d) buf='%s' write error %d: %s\n", func, linenum, buf, n, + strerror(errno)); + } + + return n; +} commit 41a1da795cbb7670a11e146d4464451a2d4be330 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 15:42:52 2023 -0600 Fix build for Apple https://github.com/Hamlib/Hamlib/issues/1430 diff --git a/src/network.c b/src/network.c index aeba822ee..0ccf60990 100644 --- a/src/network.c +++ b/src/network.c @@ -1034,6 +1034,7 @@ int is_wireless() return 0; } #else +#ifndef __APPLE__ #include <sys/ioctl.h> #include <sys/socket.h> #include <unistd.h> @@ -1084,6 +1085,7 @@ int is_wireless() return 0; } #endif +#endif void *multicast_receiver(void *arg) commit deebca4eaf3fa0e00d6b886c33b9ca36eaba1353 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 15:12:01 2023 -0600 Remove voice functions from IC275 -- rig does not have them diff --git a/rigs/icom/ic275.c b/rigs/icom/ic275.c index e3c9561a4..89a4c330a 100644 --- a/rigs/icom/ic275.c +++ b/rigs/icom/ic275.c @@ -143,8 +143,6 @@ const struct rig_caps ic275_caps = .set_mode = icom_set_mode, .get_mode = icom_get_mode, .set_vfo = icom_set_vfo, - .send_voice_mem = icom_send_voice_mem, - .stop_voice_mem = icom_stop_voice_mem, .decode_event = icom_decode_event, .set_mem = icom_set_mem, commit 7d9ef323d76e72bcdc6ba0f6684ab97873ad9e92 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 14:40:54 2023 -0600 Add some needed enums diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index a0cb2486f..c524dd42c 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2256,6 +2256,7 @@ enum rig_function_e { RIG_FUNCTION_IS_ASYNC_FRAME, RIG_FUNCTION_PROCESS_ASYNC_FRAME, RIG_FUNCTION_GET_CONF2, + RIG_FUNCTION_STOP_VOICE_MEM, }; /** @@ -2274,7 +2275,8 @@ enum rig_caps_int_e { RIG_CAPS_RIG_MODEL, RIG_CAPS_PORT_TYPE, RIG_CAPS_PTT_TYPE, - RIG_CAPS_HAS_GET_LEVEL + RIG_CAPS_HAS_GET_LEVEL, + RIG_CAPS_HAS_SET_LEVEL, }; enum rig_caps_cptr_e { commit 43545e171a6bbd366e40891cb0349256aaf17b46 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 14:40:25 2023 -0600 Fix debug statement for mingw diff --git a/src/misc.c b/src/misc.c index c1c91d308..2e2837050 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2676,7 +2676,7 @@ uint64_t HAMLIB_API rig_get_caps_int(rig_model_t rig_model, return caps->port_type; case RIG_CAPS_HAS_GET_LEVEL: - rig_debug(RIG_DEBUG_TRACE, "%s(%d): return %8lx\n", __func__, __LINE__, caps->has_get_level); + rig_debug(RIG_DEBUG_TRACE, "%s(%d): return %08"PRIll"\n", __func__, __LINE__, caps->has_get_level); return caps->has_get_level; default: commit 16488d3267b93219c70bc302d63a05b9dd54b38d Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 09:16:26 2023 -0600 Add -liphlpapi to configure.ac for mingw build https://github.com/Hamlib/Hamlib/issues/1409 diff --git a/configure.ac b/configure.ac index 25f53c6bf..78fa890fe 100644 --- a/configure.ac +++ b/configure.ac @@ -241,7 +241,7 @@ AC_CHECK_FUNC([gethostbyname], [], [AC_CHECK_LIB([ws2_32], [main], - [NET_LIBS="$NET_LIBS -lws2_32"], + [NET_LIBS="$NET_LIBS -lws2_32 -liphlpapi"], [], []) ]) commit c1780b19f4a30697588da277db579825f3698516 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 09:05:29 2023 -0600 Add wireless detection for multicast address -- possible fix for UDP error messages by using 127.0.0.1 instead of IN_ADDR_ANY https://github.com/Hamlib/Hamlib/issues/1409 diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 590e91e67..a0cb2486f 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2288,7 +2288,7 @@ enum rig_caps_cptr_e { * \brief Function to return int value from rig->caps * Does not support > 32-bit rig_caps values */ -extern HAMLIB_EXPORT (long long) rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps); +extern HAMLIB_EXPORT (uint64_t) rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps); /** * \brief Function to return char pointer value from rig->caps diff --git a/simulators/simts990.c b/simulators/simts990.c index c4918d52a..a3198b475 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -456,6 +456,11 @@ int main(int argc, char *argv[]) { sscanf(buf, "OM1%d", &modeSub); } + else if (strcmp(buf,"RM;") == 0) + { + sprintf(buf, "RM2%04d;", 10); + write(fd, buf, strlen(buf)); + } else if (strlen(buf) > 0) { fprintf(stderr, "Unknown command: %s\n", buf); diff --git a/src/misc.c b/src/misc.c index c238e7ada..c1c91d308 100644 --- a/src/misc.c +++ b/src/misc.c @@ -2640,7 +2640,7 @@ void *HAMLIB_API rig_get_function_ptr(rig_model_t rig_model, * \param RIG* and rig_caps_int_e * \return the corresponding long value -- -RIG_EINVAL is the only error possible */ -long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model, +uint64_t HAMLIB_API rig_get_caps_int(rig_model_t rig_model, enum rig_caps_int_e rig_caps) { const struct rig_caps *caps = rig_get_caps(rig_model); @@ -2676,6 +2676,7 @@ long long HAMLIB_API rig_get_caps_int(rig_model_t rig_model, return caps->port_type; case RIG_CAPS_HAS_GET_LEVEL: + rig_debug(RIG_DEBUG_TRACE, "%s(%d): return %8lx\n", __func__, __LINE__, caps->has_get_level); return caps->has_get_level; default: diff --git a/src/network.c b/src/network.c index a576d90bf..aeba822ee 100644 --- a/src/network.c +++ b/src/network.c @@ -983,6 +983,109 @@ void *multicast_publisher(void *arg) return NULL; } + +#ifdef __MINGW32__ +#include <winsock2.h> +#include <iphlpapi.h> +int is_wireless() +{ + DWORD dwSize = 0; + DWORD dwRetVal = 0; + ULONG flags = GAA_FLAG_INCLUDE_PREFIX; + PIP_ADAPTER_ADDRESSES pAddresses = NULL, pCurrAddresses = NULL; + + // First call to determine actual memory size needed + GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &dwSize); + pAddresses = (IP_ADAPTER_ADDRESSES *)malloc(dwSize); + + // Second call to get the actual data + dwRetVal = GetAdaptersAddresses(AF_UNSPEC, flags, NULL, pAddresses, &dwSize); + + if (dwRetVal == NO_ERROR) + { + for (pCurrAddresses = pAddresses; pCurrAddresses != NULL; + pCurrAddresses = pCurrAddresses->Next) + { + // printf("Adapter name: %s\n", pCurrAddresses->AdapterName); + // printf("Adapter description: %ls\n", pCurrAddresses->Description); + // printf("Adapter type: "); + + if (pCurrAddresses->IfType == IF_TYPE_IEEE80211) + { + // printf("Wireless\n\n"); + return 1; + } + else + { + // printf("Not Wireless\n\n"); + } + } + } + else + { + //printf("GetAdaptersAddresses failed with error: %lu\n", dwRetVal); + } + + if (pAddresses) + { + free(pAddresses); + } + + return 0; +} +#else +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <unistd.h> +#include <linux/wireless.h> +#include <ifaddrs.h> + +int is_wireless_linux(const char *ifname) +{ + int sock = socket(AF_INET, SOCK_DGRAM, 0); + struct iwreq pwrq; + memset(&pwrq, 0, sizeof(pwrq)); + strncpy(pwrq.ifr_name, ifname, IFNAMSIZ); + + if (ioctl(sock, SIOCGIWNAME, &pwrq) != -1) + { + close(sock); + return 1; // Wireless + } + + close(sock); + return 0; // Not wireless +} + +int is_wireless() +{ + struct ifaddrs *ifaddr, *ifa; + + if (getifaddrs(&ifaddr) == -1) + { + perror("getifaddrs"); + return 0; + } + + for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr == NULL) + { + continue; + } + + int iswireless = is_wireless_linux(ifa->ifa_name); + + //printf("%s is %s\n", ifa->ifa_name, iswireless ? "wireless" : "not wireless"); + if (iswireless) {freeifaddrs(ifaddr); return 1;} + } + + freeifaddrs(ifaddr); + return 0; +} +#endif + + void *multicast_receiver(void *arg) { char data[4096]; @@ -1024,8 +1127,15 @@ void *multicast_receiver(void *arg) dest_addr.sin_family = AF_INET; #ifdef __MINGW32__ // Windows cannot bind to multicast group addresses for some unknown reason - dest_addr.sin_addr.s_addr = htonl(INADDR_ANY); - rig_debug(RIG_DEBUG_ERR, "%s(%d): INADDR_ANY=%x,%x\n", htonl(INADDR_ANY), INADDR_ANY); + if (is_wireless()) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: no wireless detect so INADDR_ANY is being used\n", __func__); + } + else + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: wireless detected so localhost is being used\n", __func__); + dest_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); + } #else dest_addr.sin_addr.s_addr = inet_addr(args->multicast_addr); #endif diff --git a/tests/testrig.c b/tests/testrig.c index 18eb45a2e..19701f49c 100644 --- a/tests/testrig.c +++ b/tests/testrig.c @@ -11,7 +11,7 @@ #include <hamlib/config.h> -#define SERIAL_PORT "/dev/ttyUSB0" +#define SERIAL_PORT "/dev/pts/2" int main(int argc, const char *argv[]) @@ -38,9 +38,9 @@ int main(int argc, const char *argv[]) * allocate memory, setup & open port */ + hamlib_port_t myport; if (argc < 2) { - hamlib_port_t myport; /* may be overridden by backend probe */ myport.type.rig = RIG_PORT_SERIAL; myport.parm.serial.rate = 9600; @@ -48,7 +48,6 @@ int main(int argc, const char *argv[]) myport.parm.serial.stop_bits = 1; myport.parm.serial.parity = RIG_PARITY_NONE; myport.parm.serial.handshake = RIG_HANDSHAKE_NONE; - strncpy(myport.pathname, SERIAL_PORT, HAMLIB_FILPATHLEN - 1); rig_load_all_backends(); myrig_model = rig_probe(&myport); @@ -59,6 +58,7 @@ int main(int argc, const char *argv[]) } my_rig = rig_init(myrig_model); + rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), SERIAL_PORT); if (!my_rig) { @@ -77,6 +77,9 @@ int main(int argc, const char *argv[]) exit(2); } + uint64_t levels = rig_get_caps_int(my_rig->caps->rig_model, RIG_CAPS_HAS_GET_LEVEL); + printf("HAS_GET_LEVEL=0x%8lx, SWR=%8llx,true=%d\n", levels, levels & RIG_LEVEL_SWR, (levels & RIG_LEVEL_SWR) == RIG_LEVEL_SWR); + char val[256]; retcode = rig_get_conf2(my_rig, rig_token_lookup(my_rig, "write_delay"), val, sizeof(val)); commit cb34dc3b207022410d8c44971e285997c05a29c1 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 16 09:02:32 2023 -0600 Add stop_voice_mem to some icom rigs Also add send_voice_mem to IC275 diff --git a/rigs/icom/ic275.c b/rigs/icom/ic275.c index 89a4c330a..e3c9561a4 100644 --- a/rigs/icom/ic275.c +++ b/rigs/icom/ic275.c @@ -143,6 +143,8 @@ const struct rig_caps ic275_caps = .set_mode = icom_set_mode, .get_mode = icom_get_mode, .set_vfo = icom_set_vfo, + .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .decode_event = icom_decode_event, .set_mem = icom_set_mem, diff --git a/rigs/icom/ic7300.c b/rigs/icom/ic7300.c index a9a68838e..ad1bf47f2 100644 --- a/rigs/icom/ic7300.c +++ b/rigs/icom/ic7300.c @@ -929,6 +929,7 @@ const struct rig_caps ic7300_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .set_clock = ic7300_set_clock, .get_clock = ic7300_get_clock, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS @@ -1251,6 +1252,7 @@ struct rig_caps ic9700_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .set_clock = ic9700_set_clock, .get_clock = ic9700_get_clock, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS @@ -1525,6 +1527,7 @@ const struct rig_caps ic705_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS }; @@ -1795,6 +1798,7 @@ const struct rig_caps ic905_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS, }; diff --git a/rigs/icom/ic7610.c b/rigs/icom/ic7610.c index 1ba953daa..ce327e324 100644 --- a/rigs/icom/ic7610.c +++ b/rigs/icom/ic7610.c @@ -603,6 +603,7 @@ struct rig_caps ic7610_caps = .stop_morse = icom_stop_morse, .wait_morse = rig_wait_morse, .send_voice_mem = icom_send_voice_mem, + .stop_voice_mem = icom_stop_voice_mem, .set_clock = ic7610_set_clock, .get_clock = ic7610_get_clock, .hamlib_check_rig_caps = HAMLIB_CHECK_RIG_CAPS diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index adf8898ce..2370ff947 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -9500,6 +9500,10 @@ int icom_get_level_raw(RIG *rig, setting_t level, int cmd, int subcmd, RETURNFUNC(RIG_OK); } +int icom_stop_voice_mem(RIG *rig, vfo_t vfo) +{ + return icom_send_voice_mem(rig, vfo, 0); +} /* * icom_send_voice_mem * Assumes rig!=NULL, rig->state.priv!=NULL diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index a29cfe221..a16230076 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -35,7 +35,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20231113" +#define BACKEND_VER "20231116" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) @@ -390,6 +390,7 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq, int icom_send_morse(RIG *rig, vfo_t vfo, const char *msg); int icom_stop_morse(RIG *rig, vfo_t vfo); int icom_send_voice_mem(RIG *rig, vfo_t vfo, int bank); +int icom_stop_voice_mem(RIG *rig, vfo_t vfo); /* Exposed routines */ int icom_get_split_vfos(RIG *rig, vfo_t *rx_vfo, vfo_t *tx_vfo); int icom_set_raw(RIG *rig, int cmd, int subcmd, int subcmdbuflen, commit 4f0393d6add63b0c1460d3f36d32376c5e12116d Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 15 07:38:13 2023 -0600 Add simic275.c diff --git a/simulators/simic275.c b/simulators/simic275.c new file mode 100644 index 000000000..388ddd2f7 --- /dev/null +++ b/simulators/simic275.c @@ -0,0 +1,603 @@ +// simicom will show the pts port to use for rigctl on Unix +// using virtual serial ports on Windows is to be developed yet +// Needs a lot of improvement to work on all Icoms +// gcc -g -Wall -o simicom simicom.c -lhamlib +// On mingw in the hamlib src directory +// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 +#define _XOPEN_SOURCE 700 +// since we are POSIX here we need this +#if 0 +struct ip_mreq +{ + int dummy; +}; +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/time.h> +#include <hamlib/rig.h> +#include "../src/misc.h" +#include <termios.h> +#include <unistd.h> + + +#define BUFSIZE 256 +#define X25 + +int civ_731_mode = 0; +vfo_t current_vfo = RIG_VFO_A; +int split = 0; + +// we make B different from A to ensure we see a difference at startup +float freqA = 14074000; +float freqB = 14074500; +mode_t modeA = RIG_MODE_PKTUSB; +mode_t modeB = RIG_MODE_PKTUSB; +int datamodeA = 0; +int datamodeB = 0; +pbwidth_t widthA = 0; +pbwidth_t widthB = 1; +ant_t ant_curr = 0; +int ant_option = 0; +int ptt = 0; +int satmode = 0; +int agc_time = 1; +int ovf_status = 0; +int powerstat = 1; +int transceive = 0; +int keyspd = 20; +int rigtime = 1230; + +void dumphex(const unsigned char *buf, int n) +{ + for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } + + printf("\n"); +} + +int +frameGet(int fd, unsigned char *buf) +{ + int i = 0, n; + memset(buf, 0, BUFSIZE); + unsigned char c; + +again: + + while (read(fd, &c, 1) > 0) + { + buf[i++] = c; + //printf("i=%d, c=0x%02x\n",i,c); + + if (c == 0xfd) + { + char mytime[256]; + date_strget(mytime, sizeof(mytime), 1); + printf("%s:", mytime); dumphex(buf, i); + // echo + n = write(fd, buf, i); + + if (n != i) { printf("%s: error on write: %s\n", __func__, strerror(errno)); } + + return i; + } + + if (i > 2 && c == 0xfe) + { + printf("Turning power on due to 0xfe string\n"); + powerstat = 1; + int j; + + for (j = i; j < 175; ++j) + { + if (read(fd, &c, 1) < 0) { break; } + } + + i = 0; + goto again; + } + } + + printf("Error??? c=x%02x\n", c); + + return 0; +} + +void frameParse(int fd, unsigned char *frame, int len) +{ + double freq; + int n = 0; + + dumphex(frame, len); + + if (frame[0] != 0xfe && frame[1] != 0xfe) + { + printf("expected fe fe, got "); + dumphex(frame, len); + return; + } + + switch (frame[4]) + { + case 0x03: + + //from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2); + if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) + { + printf("get_freqA\n"); + to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2); + } + else + { + printf("get_freqB\n"); + to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2); + } + + frame[10] = 0xfd; + + if (powerstat) + { + n = write(fd, frame, 11); + } + + break; + + case 0x04: + if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) + { + printf("get_modeA\n"); + frame[5] = modeA; + frame[6] = widthA; + } + else + { + printf("get_modeB\n"); + frame[5] = modeB; + frame[6] = widthB; + } + + frame[7] = 0xfd; + n = write(fd, frame, 8); + break; + + case 0x05: + freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); + printf("set_freq to %.0f\n", freq); + + if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { freqA = freq; } + else { freqB = freq; } + + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + break; + + case 0x06: + if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { modeA = frame[6]; } + else { modeB = frame[6]; } + + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + break; + + case 0x07: + + switch (frame[5]) + { + case 0x00: current_vfo = RIG_VFO_A; break; + + case 0x01: current_vfo = RIG_VFO_B; break; + + case 0xa0: current_vfo = freq = freqA; freqA = freqB; freqB = freq; break; + + case 0xb0: current_vfo = RIG_VFO_MAIN; break; + + case 0xd0: current_vfo = RIG_VFO_MAIN; break; + + case 0xd1: current_vfo = RIG_VFO_SUB; break; + } + + printf("set_vfo to %s\n", rig_strvfo(current_vfo)); + + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + break; + + case 0x0f: + if (frame[5] == 0) { split = 0; } + else if (frame[5] == 1) { split = 1; } + else { frame[6] = split; } + + if (frame[5] == 0xfd) + { + printf("get split %d\n", 1); + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + printf("set split %d\n", 1); + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + } + + break; + + case 0x12: // we're simulating the 3-byte version -- not the 2-byte + if (frame[5] != 0xfd) + { + printf("Set ant %d\n", -1); + ant_curr = frame[5]; + ant_option = frame[6]; + dump_hex(frame, 8); + } + else + { + printf("Get ant\n"); + } + + frame[5] = ant_curr; + frame[6] = ant_option; + frame[7] = 0xfd; + printf("write 8 bytes\n"); + dump_hex(frame, 8); + n = write(fd, frame, 8); + break; + + case 0x14: + switch (frame[5]) + { + static int power_level = 0; + + case 0x07: + case 0x08: + if (frame[6] != 0xfd) + { + frame[6] = 0xfb; + dumphex(frame, 7); + n = write(fd, frame, 7); + printf("ACK x14 x08\n"); + } + else + { + to_bcd(&frame[6], (long long)128, 2); + frame[8] = 0xfb; + dumphex(frame, 9); + n = write(fd, frame, 9); + printf("SEND x14 x08\n"); + } + + break; + + case 0x0a: + printf("Using power level %d\n", power_level); + power_level += 10; + + if (power_level > 250) { power_level = 0; } + + to_bcd(&frame[6], (long long)power_level, 2); + frame[8] = 0xfd; + n = write(fd, frame, 9); + break; + + case 0x0c: + dumphex(frame, 10); + printf("subcmd=0x0c #1\n"); + + if (frame[6] != 0xfd) // then we have data + { + printf("subcmd=0x0c #1\n"); + keyspd = from_bcd(&frame[6], 2); + frame[6] = 0xfb; + n = write(fd, frame, 7); + } + else + { + printf("subcmd=0x0c #1\n"); + to_bcd(&frame[6], keyspd, 2); + frame[8] = 0xfd; + n = write(fd, frame, 9); + } + + break; + } + + break; + + + case 0x15: + switch (frame[5]) + { + static int meter_level = 0; + + case 0x07: + frame[6] = ovf_status; + frame[7] = 0xfd; + n = write(fd, frame, 8); + ovf_status = ovf_status == 0 ? 1 : 0; + break; + + case 0x11: + printf("Using meter level %d\n", meter_level); + meter_level += 10; + + if (meter_level > 250) { meter_level = 0; } + + to_bcd(&frame[6], (long long)meter_level, 2); + frame[8] = 0xfd; + n = write(fd, frame, 9); + break; + } + + case 0x16: + switch (frame[5]) + { + case 0x5a: + if (frame[6] == 0xfe) + { + satmode = frame[6]; + } + else + { + frame[6] = satmode; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + + break; + } + + break; + + case 0x19: // miscellaneous things + frame[5] = 0x94; + frame[6] = 0xfd; + n = write(fd, frame, 7); + break; + + case 0x1a: // miscellaneous things + switch (frame[5]) + { + case 0x03: // width + if (current_vfo == RIG_VFO_A || current_vfo == RIG_VFO_MAIN) { frame[6] = widthA; } + else { frame[6] = widthB; } + + frame[7] = 0xfd; + n = write(fd, frame, 8); + break; + + case 0x04: // AGC TIME + printf("frame[6]==x%02x, frame[7]=0%02x\n", frame[6], frame[7]); + + if (frame[6] == 0xfd) // the we are reading + { + frame[6] = agc_time; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + printf("AGC_TIME RESPONSE******************************"); + agc_time = frame[6]; + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + } + + break; + + case 0x05: + // FE FE 70 E0 1A 05 00 92 00 FD + printf("0x05 received\n"); + + if (frame[6] == 0x00 && frame[7] == 0x92) + { + if (frame[8] == 0x00) + { + printf("0x05 0x00 0x92 received\n"); + transceive = frame[8]; + frame[6] = 0xfb; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + frame[8] = transceive; + frame[9] = 0xfb; + frame[10] = 0xfd; + n = write(fd, frame, 11); + } + } + // FE FE 70 E0 1A 05 00 41 00 FD + else if (frame[6] == 0x00 && frame[7] == 0x41) + { + if (frame[8] != 0xfd) + { + printf("0x05 0x00 0x41 received\n"); + rigtime = frame[8] * 100 + frame[9]; + frame[6] = 0xfb; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + frame[8] = rigtime / 100; + frame[9] = rigtime % 100; + frame[10] = 0xfd; + n = write(fd, frame, 11); + } + } + + break; + + case 0x06: // Data mode + if (frame[6] == 0xfd) // then we're replying with mode + { + frame[6] = datamodeA; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + datamodeA = frame[6]; + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + } + + break; + + } + + break; + + case 0x1c: + switch (frame[5]) + { + case 0: + if (frame[6] == 0xfd) + { + frame[6] = ptt; + frame[7] = 0xfd; + n = write(fd, frame, 8); + } + else + { + ptt = frame[6]; + frame[4] = 0xfb; + frame[5] = 0xfd; + n = write(fd, frame, 6); + } + + break; + + } + + break; + + + case 0x25: + printf("x25 send nak\n"); + frame[4] = 0xfa; + frame[5] = 0xfd; + n = write(fd, frame, 6); + break; + + case 0x26: + printf("x26 send nak\n"); + frame[4] = 0xfa; + frame[5] = 0xfd; + n = write(fd, frame, 6); + break; + + default: printf("cmd 0x%02x unknown\n", frame[4]); + } + + if (n == 0) { printf("Write failed=%s\n", strerror(errno)); } + +// don't care about the rig type yet + +} + +#if defined(WIN32) || defined(_WIN32) +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd; + fd = open(comport, O_RDWR); + + if (fd < 0) + { + perror(comport); + } + + return fd; +} + +#else +int openPort(char *comport) // doesn't matter for using pts devices +{ + int fd = posix_openpt(O_RDWR); + char *name = ptsname(fd); + + if (name == NULL) + { + perror("pstname"); + return -1; + } + + printf("name=%s\n", name); + + if (fd == -1 || grantpt(fd) == -1 || unlockpt(fd) == -1) + { + perror("posix_openpt"); + return -1; + } + + return fd; +} +#endif + +void rigStatus() +{ + char vfoa = current_vfo == RIG_VFO_A ? '*' : ' '; + char vfob = current_vfo == RIG_VFO_B ? '*' : ' '; + printf("%cVFOA: mode=%d datamode=%d width=%ld freq=%.0f\n", vfoa, modeA, + datamodeA, + widthA, + freqA); + printf("%cVFOB: mode=%d datamode=%d width=%ld freq=%.0f\n", vfob, modeB, + datamodeB, + widthB, + freqB); +} + +int main(int argc, char **argv) +{ + unsigned char buf[256]; + int fd = openPort(argv[1]); + + printf("%s: %s\n", argv[0], rig_version()); + printf("x25/x26 command rejected\n"); +#if defined(WIN32) || defined(_WIN32) + + if (argc != 2) + { + printf("Missing comport argument\n"); + printf("%s [comport]\n", argv[0]); + exit(1); + } + +#endif + + while (1) + { + int len = frameGet(fd, buf); + + if (len <= 0) + { + close(fd); + fd = openPort(argv[1]); + } + + if (powerstat) + { + frameParse(fd, buf, len); + } + else + { + hl_usleep(1000 * 1000); + } + + rigStatus(); + } + + return 0; +} commit e8d387d51c552c014b19fc2acebfc4b3de871d13 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 23:54:56 2023 -0600 Update actions in c-cpp.yml diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 30663e032..52fb2d589 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: bootstrap run: | sudo apt install libusb-1.0-0-dev commit 1fce7ced5be4701a067cf4a9e52b88ac9c0f5922 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 23:44:47 2023 -0600 Really fix modeMapGetHamblib in Flrig to find mode in multiple mode list https://github.com/Hamlib/Hamlib/issues/1428 diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 7c359d6be..ef2160bce 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -716,7 +716,7 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig) modeFLRigCheck, modeMap[i].mode_flrig); if (modeMap[i].mode_flrig - && strstr(modeMap[i].mode_flrig, modeFLRigCheck) == 0) + && strstr(modeMap[i].mode_flrig, modeFLRigCheck)) { return (modeMap[i].mode_hamlib); } diff --git a/simulators/Makefile.am b/simulators/Makefile.am index ad9879b6b..f383f5ce7 100644 --- a/simulators/Makefile.am +++ b/simulators/Makefile.am @@ -8,7 +8,7 @@ DISTCLEANFILES = bin_PROGRAMS = -check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 +check_PROGRAMS = simelecraft simicgeneric simkenwood simyaesu simic9100 simic9700 simft991 simftdx1200 simftdx3000 simjupiter simpowersdr simid5100 simft736 simftdx5000 simtmd700 simrotorez simspid simft817 simts590 simft847 simic7300 simic7000 simic7100 simic7200 simatd578 simic905 simts450 simic7600 simic7610 simic705 simts950 simts990 simic7851 simftdx101 simxiegug90 simqrplabs simft818 simic275 simelecraft_SOURCES = simelecraft.c simkenwood_SOURCES = simkenwood.c diff --git a/simulators/simft817.c b/simulators/simft817.c index 00adb9c3a..a77fd3ddf 100644 --- a/simulators/simft817.c +++ b/simulators/simft817.c @@ -18,6 +18,7 @@ struct ip_mreq #define BUFSIZE 256 +int vfo = 0; // 0=A, !0=B float freqA = 14074000; float freqB = 14074500; char tx_vfo = '0'; @@ -121,7 +122,11 @@ again: case 0x88: printf("PTT OFF\n"); break; - case 0x07: printf("MODE\n"); break; + case 0x07: + printf("MODE %0xx\n", buf[0]); + if (vfo == 0) modeA = buf[0]; + else modeB = buf[0]; + break; case 0x05: printf("CLAR ON\n"); break; @@ -129,7 +134,10 @@ again: case 0xF5: printf("FREQ\n"); break; - case 0x81: printf("VFO TOGGLE\n"); break; + case 0x81: + vfo = !vfo; + printf("VFO TOGGLE, %s active\n", vfo==0?"VFOA":"VFOB"); + break; case 0x02: printf("SPLIT ON\n"); break; commit 512c82649e4f80d696938bd7843ea8fa2b2444ca Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 22:55:25 2023 -0600 Fix modeMapGetHamblib in Flrig to find mode in multiple mode list https://github.com/Hamlib/Hamlib/issues/1428 diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index eb1db8b91..7c359d6be 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -716,7 +716,7 @@ static rmode_t modeMapGetHamlib(const char *modeFLRig) modeFLRigCheck, modeMap[i].mode_flrig); if (modeMap[i].mode_flrig - && strcmp(modeMap[i].mode_flrig, modeFLRigCheck) == 0) + && strstr(modeMap[i].mode_flrig, modeFLRigCheck) == 0) { return (modeMap[i].mode_hamlib); } commit c348632b262c17121867457f685d06a3111727a2 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 17:03:40 2023 -0600 Add ptt_type to rig->caps when set so it can be queried correctly diff --git a/src/conf.c b/src/conf.c index 99fad9154..c6e991c4f 100644 --- a/src/conf.c +++ b/src/conf.c @@ -514,26 +514,32 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) if (!strcmp(val, "RIG")) { rs->pttport.type.ptt = RIG_PTT_RIG; + rig->caps->ptt_type = RIG_PTT_RIG; } else if (!strcmp(val, "RIGMICDATA")) { rs->pttport.type.ptt = RIG_PTT_RIG_MICDATA; + rig->caps->ptt_type = RIG_PTT_RIG_MICDATA; } else if (!strcmp(val, "DTR")) { rs->pttport.type.ptt = RIG_PTT_SERIAL_DTR; + rig->caps->ptt_type = RIG_PTT_SERIAL_DTR; } else if (!strcmp(val, "RTS")) { rs->pttport.type.ptt = RIG_PTT_SERIAL_RTS; + rig->caps->ptt_type = RIG_PTT_SERIAL_RTS; } else if (!strcmp(val, "Parallel")) { rs->pttport.type.ptt = RIG_PTT_PARALLEL; + rig->caps->ptt_type = RIG_PTT_PARALLEL; } else if (!strcmp(val, "CM108")) { rs->pttport.type.ptt = RIG_PTT_CM108; + rig->caps->ptt_type = RIG_PTT_CM108; } else if (!strcmp(val, "GPIO")) { @@ -542,6 +548,7 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) else if (!strcmp(val, "GPION")) { rs->pttport.type.ptt = RIG_PTT_GPION; + rig->caps->ptt_type = RIG_PTT_GPION; } else if (!strcmp(val, "None")) { commit 8478367223f611a4fbc2e677a577664c5611db9c Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 10:23:14 2023 -0600 Improve rigctld printout when TCP session is aborted diff --git a/src/network.c b/src/network.c index a68329149..a576d90bf 100644 --- a/src/network.c +++ b/src/network.c @@ -1025,6 +1025,7 @@ void *multicast_receiver(void *arg) #ifdef __MINGW32__ // Windows cannot bind to multicast group addresses for some unknown reason dest_addr.sin_addr.s_addr = htonl(INADDR_ANY); + rig_debug(RIG_DEBUG_ERR, "%s(%d): INADDR_ANY=%x,%x\n", htonl(INADDR_ANY), INADDR_ANY); #else dest_addr.sin_addr.s_addr = inet_addr(args->multicast_addr); #endif diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index 23d14cfe3..9c6b215b0 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -720,9 +720,18 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, { if ((retcode = scanfc(fin, "%c", &cmd)) < 1) { + if (last_cmd==0) + { + rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d, last_cmd=[empty]\n", + __func__, + retcode); + } + else + { rig_debug(RIG_DEBUG_WARN, "%s: nothing to scan#1? retcode=%d, last_cmd=%c\n", __func__, retcode, last_cmd); + } return (RIGCTL_PARSE_ERROR); } diff --git a/tests/rigctld.c b/tests/rigctld.c index 2bce5b814..e82f18cff 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -867,6 +867,26 @@ int main(int argc, char *argv[]) freeaddrinfo(saved_result); /* No longer needed */ exit(2); } + int optval = 1; +#ifdef __MINGW32__ + if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, (PCHAR)&optval, sizeof(optval)) < 0) +#else + if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) +#endif + { + rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP address reuse: %s\n", __func__, + strerror(errno)); + } + + // Windows does not have SO_REUSEPORT. However, SO_REUSEADDR works in a similar way. +#if defined(SO_REUSEPORT) + if (setsockopt(sock_listen, SOL_SOCKET, SO_REUSEPORT, &optval, sizeof(optval)) < 0) + { + rig_debug(RIG_DEBUG_ERR, "%s: error enabling UDP port reuse: %s\n", __func__, + strerror(errno)); + } +#endif + #if 0 if (setsockopt(sock_listen, commit f57b7cba71e48dfb3aef258f5e492d2cf06db711 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 07:42:38 2023 -0600 Revert commit 1c379e793a066c30d35fed99e5fb1a77f7a882f8 Removing LF from here caused "l ?" to not have CR where "L ?" does. I don't see the problem with a CR to end the printout. Not sure why this was removed before...bad documentation on my part. diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index c47a87fe6..23d14cfe3 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -3352,7 +3352,7 @@ declare_proto_rig(get_level) fprintf(fout, "%s%c", s, resp_sep); } - //fputc('\n', fout); + fputc('\n', fout); RETURNFUNC2(RIG_OK); } level = rig_parse_level(arg1); commit 723b835fdde16c774deaa51ba2be39e47436d0e5 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 14 06:48:41 2023 -0600 Remove bogus set_level in ts590.c for ALC,SWR,COMP diff --git a/rigs/kenwood/ts590.c b/rigs/kenwood/ts590.c index 1b80a3831..9a4c1dc48 100644 --- a/rigs/kenwood/ts590.c +++ b/rigs/kenwood/ts590.c @@ -564,28 +564,6 @@ static int ts590_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) SNPRINTF(levelbuf, sizeof(levelbuf), "RA%02d", (val.i == 12) ? 1 : 0); break; - case RIG_LEVEL_METER: - switch (val.i) - { - case RIG_METER_SWR: - kenwood_val = 1; - break; - - case RIG_METER_COMP: - kenwood_val = 2; - break; - - case RIG_METER_ALC: - kenwood_val = 3; - break; - - default: - RETURNFUNC(-RIG_EINVAL); - } - - SNPRINTF(levelbuf, sizeof(levelbuf), "RM%d", kenwood_val); - break; - case RIG_LEVEL_CWPITCH: if (val.i > 1000 || val.i < 300) { @@ -1594,7 +1572,7 @@ const struct rig_caps ts590_caps = RIG_MODEL(RIG_MODEL_TS590S), .model_name = "TS-590S", .mfg_name = "Kenwood", - .version = BACKEND_VER ".9", + .version = BACKEND_VER ".10", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1792,7 +1770,7 @@ const struct rig_caps fx4_caps = RIG_MODEL(RIG_MODEL_FX4), .model_name = "FX4/C/CR/L", .mfg_name = "BG2FX", - .version = BACKEND_VER ".8", + .version = BACKEND_VER ".9", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1986,7 +1964,7 @@ const struct rig_caps ts590sg_caps = RIG_MODEL(RIG_MODEL_TS590SG), .model_name = "TS-590SG", .mfg_name = "Kenwood", - .version = BACKEND_VER ".6", + .version = BACKEND_VER ".7", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, commit d868f1a545a753f1b8b1c47b30ae0383b3ff4483 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Nov 13 23:07:57 2023 -0600 Fix FLRig get_bwA/B for rigs that do not have it https://github.com/Hamlib/Hamlib/issues/1427 diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index a5688ecde..eb1db8b91 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -590,6 +590,8 @@ static int flrig_transaction(RIG *rig, char *cmd, char *cmd_arg, char *value, // we get an unknown response if function does not exist if (strstr(xml, "unknown")) { set_transaction_inactive(rig); RETURNFUNC(RIG_ENAVAIL); } + if (strstr(xml, "get_bw") && strstr(xml, "NONE")) { set_transaction_inactive(rig); RETURNFUNC(RIG_ENAVAIL); } + if (value) { xml_parse(xml, value, value_len); @@ -896,7 +898,8 @@ static int flrig_open(RIG *rig) if (retval == RIG_ENAVAIL) // must not have it { priv->has_get_bwA = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA is not available=%s\n", __func__, + priv->has_get_bwB = 0; // if we don't have A then surely we don't have B either + rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwA/B is not available=%s\n", __func__, value); } else @@ -911,6 +914,7 @@ static int flrig_open(RIG *rig) if (retval == RIG_ENAVAIL) // must not have it { priv->has_set_bwA = 0; + priv->has_set_bwB = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwA is not available=%s\n", __func__, value); } @@ -920,34 +924,37 @@ static int flrig_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwA is available=%s\n", __func__, value); } - /* see if get_bwB is available */ - retval = flrig_transaction(rig, "rig.get_bwB", NULL, value, sizeof(value)); - - if (retval == RIG_ENAVAIL) // must not have it + if (priv->has_get_bwA) { - priv->has_get_bwB = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is not available=%s\n", __func__, - value); - } - else - { - priv->has_get_bwB = 1; - rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is available=%s\n", __func__, value); - } + /* see if get_bwB is available FLRig can return empty value too */ + retval = flrig_transaction(rig, "rig.get_bwB", NULL, value, sizeof(value)); - /* see if set_bwA is available */ - retval = flrig_transaction(rig, "rig.set_bwB", NULL, value, sizeof(value)); + if (retval == RIG_ENAVAIL || strlen(value) == 0) // must not have it + { + priv->has_get_bwB = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is not available=%s\n", __func__, + value); + } + else + { + priv->has_get_bwB = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is available=%s\n", __func__, value); + } - if (retval == RIG_ENAVAIL) // must not have it - { - priv->has_set_bwB = 0; - rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is not available=%s\n", __func__, - value); - } - else - { - priv->has_set_bwB = 1; - rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is available=%s\n", __func__, value); + /* see if set_bwA is available */ + retval = flrig_transaction(rig, "rig.set_bwB", NULL, value, sizeof(value)); + + if (retval == RIG_ENAVAIL) // must not have it + { + priv->has_set_bwB = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is not available=%s\n", __func__, + value); + } + else + { + priv->has_set_bwB = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is available=%s\n", __func__, value); + } } retval = flrig_transaction(rig, "rig.get_AB", NULL, value, sizeof(value)); @@ -1743,8 +1750,14 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* so we may not be 100% accurate if op is twiddling knobs */ cmdp = "rig.get_bwA"; retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); + if (retval == RIG_OK && strstr(value,"NONE")) + { + priv->has_get_bwA = priv->has_get_bwB = 0; + *width = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: does not have rig.get_bwA/B\n", __func__); + } - if (retval != RIG_OK) + if (retval != RIG_OK || strstr(value,"NONE")) { RETURNFUNC(retval); } @@ -1754,6 +1767,12 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) { cmdp = "rig.get_bwB"; retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); + if (retval == RIG_OK && strlen(value)==0) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s: does not have rig.get_bwB\n", __func__); + priv->has_get_bwB = 0; + *width = 0; + } if (retval != RIG_OK) { commit 394cb4cbcf53971ac5f5e2ede0b0c488be989528 Merge: b1b567d64 176c49240 Author: Michael Black <mdb...@ya...> Date: Mon Nov 13 17:48:52 2023 -0600 Merge pull request #1426 from GeoBaltz/990_meter 990 meter commit b1b567d64a7d65584377926fa0818fde3b6abf18 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Nov 13 13:58:06 2023 -0600 Fix FLRig get_bwA/B for rigs that do not have get_bwA/b https://github.com/Hamlib/Hamlib/issues/1427 diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index e5a14e32e..a5688ecde 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -118,6 +118,9 @@ struct flrig_priv_data value_t parms[RIG_SETTING_MAX]; struct ext_list *ext_parms; int get_SWR; + int has_get_modeB; /* True if this function is available */ + int has_get_bwB; /* True if this function is available */ + int has_set_bwB; /* True if this function is available */ }; /* level's and parm's tokens */ @@ -140,7 +143,7 @@ const struct rig_caps flrig_caps = RIG_MODEL(RIG_MODEL_FLRIG), .model_name = "FLRig", .mfg_name = "FLRig", - .version = "20231110.0", + .version = "20231113.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -863,6 +866,21 @@ static int flrig_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeA is available\n", __func__); } + /* see if get_modeB is available */ + retval = flrig_transaction(rig, "rig.get_modeB", NULL, value, sizeof(value)); + + if (retval == RIG_ENAVAIL) // must not have it + { + priv->has_get_modeB = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeB is not available=%s\n", __func__, + value); + } + else + { + priv->has_get_modeB = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: getmodeB is available\n", __func__); + } + freq_t freq; retval = flrig_get_freq(rig, RIG_VFO_CURR, &freq); @@ -902,6 +920,36 @@ static int flrig_open(RIG *rig) rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwA is available=%s\n", __func__, value); } + /* see if get_bwB is available */ + retval = flrig_transaction(rig, "rig.get_bwB", NULL, value, sizeof(value)); + + if (retval == RIG_ENAVAIL) // must not have it + { + priv->has_get_bwB = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is not available=%s\n", __func__, + value); + } + else + { + priv->has_get_bwB = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: get_bwB is available=%s\n", __func__, value); + } + + /* see if set_bwA is available */ + retval = flrig_transaction(rig, "rig.set_bwB", NULL, value, sizeof(value)); + + if (retval == RIG_ENAVAIL) // must not have it + { + priv->has_set_bwB = 0; + rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is not available=%s\n", __func__, + value); + } + else + { + priv->has_set_bwB = 1; + rig_debug(RIG_DEBUG_VERBOSE, "%s: set_bwB is available=%s\n", __func__, value); + } + retval = flrig_transaction(rig, "rig.get_AB", NULL, value, sizeof(value)); if (retval != RIG_OK) { RETURNFUNC(retval); } @@ -1599,6 +1647,8 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s\n", __func__, rig_strvfo(vfo)); + *width = 0; + if (check_vfo(vfo) == FALSE) { rig_debug(RIG_DEBUG_ERR, "%s: unsupported VFO %s\n", @@ -1655,7 +1705,7 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* so we may not be 100% accurate if op is twiddling knobs */ cmdp = "rig.get_modeA"; - if (vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; } + if (priv->has_get_modeB && vfo == RIG_VFO_B) { cmdp = "rig.get_modeB"; } } retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); @@ -1692,15 +1742,25 @@ static int flrig_get_mode(RIG *rig, vfo_t vfo, rmode_t *mode, pbwidth_t *width) /* vfo B may not be getting polled though in FLRig */ /* so we may not be 100% accurate if op is twiddling knobs */ cmdp = "rig.get_bwA"; + retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); - if (vfo == RIG_VFO_B) { cmdp = "rig.get_bwB"; } - } + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } - retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); - if (retval != RIG_OK) - { - RETURNFUNC(retval); + if (priv->has_get_bwB && vfo == RIG_VFO_B) + { + cmdp = "rig.get_bwB"; + retval = flrig_transaction(rig, cmdp, NULL, value, sizeof(value)); + + if (retval != RIG_OK) + { + RETURNFUNC(retval); + } + + } } rig_debug(RIG_DEBUG_TRACE, "%s: mode=%s width='%s'\n", __func__, @@ -2114,12 +2174,14 @@ static int flrig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) RETURNFUNC(RIG_OK); } -typedef struct { +typedef struct +{ float mtr; float swr; } swrpair; -static swrpair swrtbl[] = { +static swrpair swrtbl[] = +{ {0.0, 1.0}, {10.5, 1.5}, {23.0, 2.0}, @@ -2129,21 +2191,29 @@ static swrpair swrtbl[] = { }; // Function to interpolate SWR from MTR -float interpolateSWR(float mtr) { +float interpolateSWR(float mtr) +{ int i; - for (i = 0; i < sizeof(swrtbl)/sizeof(swrpair) - 1; i++) { - if (mtr == swrtbl[i].mtr) { + + for (i = 0; i < sizeof(swrtbl) / sizeof(swrpair) - 1; i++) + { + if (mtr == swrtbl[i].mtr) + { // Exact match return swrtbl[i].swr; } - if (mtr < swrtbl[i + 1].mtr) { + + if (mtr < swrtbl[i + 1].mtr) + { // Perform linear interpolation - float slope = (swrtbl[i +... [truncated message content] |