From d6b54f491e13b2797e9c222003f892453e154f87 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 22 May 2021 12:38:40 -0500 Subject: [PATCH 1/6] export network_multicast_server for DLL linkage https://github.com/Hamlib/Hamlib/issues/710 --- src/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network.h b/src/network.h index 111b0b36e..306f58566 100644 --- a/src/network.h +++ b/src/network.h @@ -29,7 +29,7 @@ __BEGIN_DECLS /* Hamlib internal use, see rig.c */ int network_open(hamlib_port_t *p, int default_port); -int network_multicast_server(RIG *rig, const char *multicast_addr, int default_port); +HAMLIB_EXPORT(int) network_multicast_server(RIG *rig, const char *multicast_addr, int default_port); int network_close(hamlib_port_t *rp); void network_flush(hamlib_port_t *rp); From 505698237521877fc1d03ae28b88235ad6f32b0c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sat, 22 May 2021 16:55:18 -0500 Subject: [PATCH 2/6] Add LastCommand struct to multicast packet proposal Need to define rig/amp/tuner control command formats -- do not intend on using limited rigctld format https://github.com/Hamlib/Hamlib/issues/695 --- README.multicast | 13 ++++++++++--- bindings/csharp/multicast/multicast.cs | 6 +++++- bindings/csharp/multicast/test.json | 6 +++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.multicast b/README.multicast index a37d51528..aad7de55b 100644 --- a/README.multicast +++ b/README.multicast @@ -64,7 +64,11 @@ Example JSON "LowFreq": 14000000, "HighFreq": 14250000 }, - + LastCommand { + "ID": "MyApp 123", + "Command": "set_freq VFOA 14074000". + "Status": "OK" + }, "PTT" : false, "Split": true, "SatMode": false, @@ -77,7 +81,6 @@ Example JSON "Seq": 1, "__comment_crc__": "32-bit CRC of entire JSON record replacing the CRC value with 0x00000000", "ErrorMsg": "OK", - "LastCommand": "Last command executed", "CRC": "0x00000000" } @@ -119,6 +122,11 @@ namespace HamlibMultiCast public double LowFreq; public double HighFreq; } + LastCommand { + public string ID; // an application name plus sequence number recommended + public string Command; + public string Status; + } public string ID; public List VFOs { get; set; } public bool PTT; @@ -129,7 +137,6 @@ namespace HamlibMultiCast public string Version; public string Status; public UInt32 Seq; - public string LastCommand; public string CRC; public SpectrumClass Spectrum { get; set; } public string ErrorMsg; diff --git a/bindings/csharp/multicast/multicast.cs b/bindings/csharp/multicast/multicast.cs index 98c8d5ffe..8d6baa6b0 100644 --- a/bindings/csharp/multicast/multicast.cs +++ b/bindings/csharp/multicast/multicast.cs @@ -32,6 +32,11 @@ namespace HamlibMultiCast public double LowFreq; public double HighFreq; } + public class LastCommand { + public string ID; + public string Command; + public string Status; + } public string ID; public List VFOs { get; set; } public bool Split; @@ -40,7 +45,6 @@ namespace HamlibMultiCast public string App; public string Version; public UInt32 Seq; - public string LastCommand; public string CRC; public SpectrumClass Spectrum { get; set; } } diff --git a/bindings/csharp/multicast/test.json b/bindings/csharp/multicast/test.json index 1f2480499..6f4365671 100644 --- a/bindings/csharp/multicast/test.json +++ b/bindings/csharp/multicast/test.json @@ -38,6 +38,11 @@ "LowFreq": 14000000, "HighFreq": 14250000 }, + "LastCommand": { + "ID": "MyApp 123", + "Command": "set_freq VFOA 14074000", + "Status": "OK" + }, "Split": true, "SatMode": false, @@ -47,7 +52,6 @@ "Version": "20210520", "__comment_seq__": "Seq is 1-up sequence number 32-bit -- wraps around to 1 from 2^32-1", "Seq": 1, - "LastCommand": "set_freq VFOA 14074000", "__comment_crc__": "32-bit CRC of entire JSON record replacing the CRC value with 0x00000000", "CRC": "0x00000000" } From 3e4ff69b96b853f9aa86799e7c8b3d2435c78b2a Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 23 May 2021 07:40:08 -0500 Subject: [PATCH 3/6] Add multicast_item_e and change multicast_server API https://github.com/Hamlib/Hamlib/issues/695 --- include/hamlib/rig.h | 10 ++++++++++ src/network.c | 15 ++++++++++++++- src/network.h | 2 +- tests/rigctld.c | 3 ++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 61dc582ae..844c91f92 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -996,6 +996,16 @@ enum cookie_e { RIG_COOKIE_RENEW, }; +/** + * \brief Multicast data items + * 3 different data item can be included in the multicast JSON + */ +enum multicast_item_e { + RIG_MULTICAST_POLL, // hamlib will be polling the rig for all rig items + RIG_MULTICAST_TRANSCEIVE, // transceive will be turned on and processed + RIG_MULTICAST_SPECTRUM // spectrum data will be included +}; + //! @cond Doxygen_Suppress #define RIG_PARM_FLOAT_LIST (RIG_PARM_BACKLIGHT|RIG_PARM_BAT|RIG_PARM_KEYLIGHT) #define RIG_PARM_READONLY_LIST (RIG_PARM_BAT) diff --git a/src/network.c b/src/network.c index 2e4cc72ef..f094d6e54 100644 --- a/src/network.c +++ b/src/network.c @@ -406,7 +406,7 @@ int network_close(hamlib_port_t *rp) * \param default_port Default network socket port * \return RIG_OK or < 0 if error */ -int network_multicast_server(RIG *rig, const char *multicast_addr, int default_port) +int network_multicast_server(RIG *rig, const char *multicast_addr, int default_port, enum multicast_item_e items) { int status; @@ -417,6 +417,19 @@ int network_multicast_server(RIG *rig, const char *multicast_addr, int default_p if (status != RIG_OK) { RETURNFUNC(status); } + if (items && RIG_MULTICAST_TRANSCEIVE) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_TRANSCEIVE enabled\n", __FILE__, __LINE__); + } + if (items && RIG_MULTICAST_SPECTRUM) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d) MULTICAST_SPECTRUM enabled\n", __FILE__, __LINE__); + } + else + { + rig_debug(RIG_DEBUG_ERR, "%s(%d) unknown MULTICAST item requested=0x%x\n", __FILE__, __LINE__, items); + } + RETURNFUNC(RIG_OK); } diff --git a/src/network.h b/src/network.h index 306f58566..901e8f857 100644 --- a/src/network.h +++ b/src/network.h @@ -29,7 +29,7 @@ __BEGIN_DECLS /* Hamlib internal use, see rig.c */ int network_open(hamlib_port_t *p, int default_port); -HAMLIB_EXPORT(int) network_multicast_server(RIG *rig, const char *multicast_addr, int default_port); +HAMLIB_EXPORT(int) network_multicast_server(RIG *rig, const char *multicast_addr, int default_port, enum multicast_item_e items); int network_close(hamlib_port_t *rp); void network_flush(hamlib_port_t *rp); diff --git a/tests/rigctld.c b/tests/rigctld.c index d116a4e7d..105185217 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -746,7 +746,8 @@ int main(int argc, char *argv[]) saved_result = result; - retcode = network_multicast_server(my_rig, multicast_addr, 4532); + enum multicast_item_e items = RIG_MULTICAST_POLL|RIG_MULTICAST_TRANSCEIVE|RIG_MULTICAST_SPECTRUM; + retcode = network_multicast_server(my_rig, multicast_addr, 4532, items); if (retcode != RIG_OK) { From 238265f2ac8fcc9c3f68cb881f10df388a342b1b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 24 May 2021 07:31:02 -0500 Subject: [PATCH 4/6] Initialize CM108 pathname, rigport, and pttport in rig_init too https://github.com/Hamlib/Hamlib/issues/673 --- src/rig.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rig.c b/src/rig.c index 9918b93a3..a6366498e 100644 --- a/src/rig.c +++ b/src/rig.c @@ -861,6 +861,10 @@ int HAMLIB_API rig_open(RIG *rig) case RIG_PTT_CM108: rs->pttport.fd = cm108_open(&rs->pttport); + strncpy(rs->rigport.pathname, DEFAULT_CM108_PORT, HAMLIB_FILPATHLEN); + rs->rigport.parm.cm108.ptt_bitnum = DEFAULT_CM108_PTT_BITNUM; + rs->pttport.parm.cm108.ptt_bitnum = DEFAULT_CM108_PTT_BITNUM; + if (rs->pttport.fd < 0) { rig_debug(RIG_DEBUG_ERR, From 2acbd2217384f81ceaec2b6a9d9f92cf7448b0cb Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 24 May 2021 10:51:08 -0500 Subject: [PATCH 5/6] Fix multi-command rigctl capability for readline capable build https://github.com/Hamlib/Hamlib/issues/711 --- tests/rigctl_parse.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index da3ff16d2..a81c3d482 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -671,7 +671,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, RETURNFUNC(RIGCTL_PARSE_ERROR); } - if (cmd != 0xa) + if (cmd != 0xa && cmd !=0xd) { rig_debug(RIG_DEBUG_TRACE, "%s: cmd=%c(%02x)\n", __func__, isprint(cmd) ? cmd : ' ', cmd); @@ -1143,7 +1143,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, * argument is given, it will be parsed out later. */ result = strtok(input_line, " "); - +readline_repeat: /* parsed_input stores pointers into input_line where the token strings * start. */ @@ -1737,6 +1737,9 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc, fflush(fout); rig_debug(RIG_DEBUG_TRACE, "%s: retcode=%d\n", __func__, retcode); +#ifdef HAVE_LIBREADLINE + if ((result = strtok(NULL, " "))) goto readline_repeat; +#endif if (sync_cb) { sync_cb(0); } /* unlock if necessary */ From 39951dc28802448c89511ebfb09fb35d3384bf0b Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Tue, 25 May 2021 08:09:01 -0500 Subject: [PATCH 6/6] Fix segfault when using rig_get_info stacked calls rigctl get_vfo_info VFOA get_vfo_info VFOB --- tests/rigctl_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c index a81c3d482..157eb707b 100644 --- a/tests/rigctl_parse.c +++ b/tests/rigctl_parse.c @@ -1738,7 +1738,7 @@ readline_repeat: rig_debug(RIG_DEBUG_TRACE, "%s: retcode=%d\n", __func__, retcode); #ifdef HAVE_LIBREADLINE - if ((result = strtok(NULL, " "))) goto readline_repeat; + if (input_line != NULL && (result = strtok(NULL, " "))) goto readline_repeat; #endif if (sync_cb) { sync_cb(0); } /* unlock if necessary */