[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. e28e3c224bbb3cf1234e2
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Nate B. <n0...@us...> - 2021-05-19 21:57:13
|
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 e28e3c224bbb3cf1234e2795f2c0ba2d4ea86a6e (commit) via a6f2180874c6a8b46191210074b9ddee808e206d (commit) via 8e3e93da0fc2fb9857507cbe01743c05e8f733ae (commit) via cc1f277e5f03ae9a70e1a0a62a32999b6543bfe3 (commit) via 12ce326350ee32164d7c4b881dd22b1011d9110f (commit) via 94fa261e9d298bdcf4a8357f83d8ad43be4fa050 (commit) from 03352f298f8a7e3ca882668840f8fb11f1fd49f7 (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 e28e3c224bbb3cf1234e2795f2c0ba2d4ea86a6e Merge: 8e3e93da a6f21808 Author: Nate Bargmann <n0...@n0...> Date: Wed May 19 16:56:08 2021 -0500 Merge pull request #707 from N0NB/doxygen_work Update Doxygen comments. commit a6f2180874c6a8b46191210074b9ddee808e206d Author: Nate Bargmann <n0...@n0...> Date: Wed May 19 16:50:51 2021 -0500 Update Doxygen comments. diff --git a/src/debug.c b/src/debug.c index 1aacbb56..7c9f5384 100644 --- a/src/debug.c +++ b/src/debug.c @@ -20,13 +20,14 @@ */ /** - * \addtogroup rig_internal + * \addtogroup rig * @{ */ /** * \file debug.c - * \brief control hamlib debugging functions + * + * \brief Control Hamlib debugging functions. */ #ifdef HAVE_CONFIG_H @@ -52,9 +53,17 @@ #include <hamlib/rig_dll.h> #include "misc.h" -//! @cond Doxygen_Suppress +/*! @} */ + + +/** + * \addtogroup rig_internal + * @{ + */ + + +/** \brief Sets the number of hexadecimal pairs to print per line. */ #define DUMP_HEX_WIDTH 16 -//! @endcond static int rig_debug_level = RIG_DEBUG_TRACE; @@ -66,9 +75,17 @@ static rig_ptr_t rig_vprintf_arg; extern HAMLIB_EXPORT(void) dump_hex(const unsigned char ptr[], size_t size); /** - * \param ptr Pointer to memory area - * \param size Number of chars to words to dump * \brief Do a hex dump of the unsigned char array. + * + * \param ptr Pointer to a character array. + * \param size Number of chars to words to dump. + * + * Prints the hex dump to `stderr` via rig_debug(): + * + * ``` + * 0000 4b 30 30 31 34 35 30 30 30 30 30 30 30 35 30 32 K001450000000502 + * 0010 30 30 0d 0a 00.. + * ``` */ void dump_hex(const unsigned char ptr[], size_t size) { @@ -115,10 +132,24 @@ void dump_hex(const unsigned char ptr[], size_t size) } } +/*! @} */ + /** - * \param debug_level - * \brief Change the current debug level + * \addtogroup rig + * @{ + */ + +/** + * \brief Change the current debug level. + * + * \param debug_level Equivalent to the `-v` option of the utilities. + * + * Allows for dynamically changing the debugging output without reinitializing + * the library. + * + * Useful for programs that want to enable and disable debugging + * output without restarting. */ void HAMLIB_API rig_set_debug(enum rig_debug_level_e debug_level) { @@ -127,17 +158,28 @@ void HAMLIB_API rig_set_debug(enum rig_debug_level_e debug_level) /** - * \param debug_level - * \brief Useful for dump_hex, etc. + * \brief Test if a given debug level is active. + * + * \param debug_level The level to test. + * + * May be used to determine if an action such as opening a dialog should + * happen only if a desired debug level is active. + * + * Also useful for dump_hex(), etc. */ int HAMLIB_API rig_need_debug(enum rig_debug_level_e debug_level) { return (debug_level <= rig_debug_level); } + /** - * \param flag - * \brief Enbable/disable time stamp on debug output + * \brief Enable or disable the time stamp on debugging output. + * + * \param flag `TRUE` or `FALSE`. + * + * Sets or unsets the flag which controls whether debugging output includes a + * time stamp. */ void HAMLIB_API rig_set_debug_time_stamp(int flag) { @@ -162,10 +204,15 @@ char *date_strget(char *buf, int buflen) } //! @endcond + /** - * \param debug_level - * \param fmt - * \brief Default is debugging messages are done through stderr + * \brief Print debugging messages through `stderr` by default. + * + * \param debug_level Debug level from none to most output. + * \param fmt Formatted character string to print. + * + * The formatted character string is passed to the `frprintf`(3) C library + * call and follows its format specification. */ #undef rig_debug void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level, @@ -243,37 +290,36 @@ void HAMLIB_API rig_debug(enum rig_debug_level_e debug_level, /** - * \brief set callback to handle debug messages - * \param cb The callback to install - * \param arg A Pointer to some private data to pass later on to the callback + * \brief Set callback to handle debugging messages. * - * Install a callback for \a rig_debug messages. -\code -int -rig_message_cb(enum rig_debug_level_e debug_level, - rig_ptr_t user_data, - const char *fmt, - va_list ap) -{ - char buf[1024]; - - sprintf (buf, "Message(%s) ", (char*)user_data); - syslog (LOG_USER, buf); - vsprintf (buf, fmt, ap); - syslog (LOG_USER, buf); - - return RIG_OK; -} - - . . . - - char *cookie = "Foo"; - rig_set_debug_callback (rig_message_cb, (rig_ptr_t)cookie); -\endcode + * \param cb The callback function to install. + * \param arg A Pointer to some private data to pass later on to the callback. + * + * Install a callback for rig_debug() messages. + * \code + * int + * rig_message_cb(enum rig_debug_level_e debug_level, + * rig_ptr_t user_data, + * const char *fmt, + * va_list ap) + * { + * char buf[1024]; + * + * sprintf (buf, "Message(%s) ", (char*)user_data); + * syslog (LOG_USER, buf); + * vsprintf (buf, fmt, ap); + * syslog (LOG_USER, buf); * - * \return RIG_OK if the operation has been successful, otherwise - * a negative value if an error occurred (in which case, cause - * is set appropriately). + * return RIG_OK; + * } + * + * . . . + * + * char *cookie = "Foo"; + * rig_set_debug_callback (rig_message_cb, (rig_ptr_t)cookie); + * \endcode + * + * \return A pointer to the previous callback that was set, if any. * * \sa rig_debug() */ @@ -289,8 +335,11 @@ vprintf_cb_t HAMLIB_API rig_set_debug_callback(vprintf_cb_t cb, rig_ptr_t arg) /** - * \brief change stderr to some different output - * \param stream The stream to set output to + * \brief Change the output stream from `stderr` a different stream. + * + * \param stream The stream to direct debugging output. + * + * \sa `FILE`(3) */ FILE *HAMLIB_API rig_set_debug_file(FILE *stream) { commit 8e3e93da0fc2fb9857507cbe01743c05e8f733ae Merge: cc1f277e 03352f29 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 19 15:24:24 2021 -0500 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit cc1f277e5f03ae9a70e1a0a62a32999b6543bfe3 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 19 13:17:46 2021 -0500 Beginning of multicast capability https://github.com/Hamlib/Hamlib/issues/695 diff --git a/src/network.c b/src/network.c index bd458412..2e4cc72e 100644 --- a/src/network.c +++ b/src/network.c @@ -121,26 +121,8 @@ static void handle_error(enum rig_debug_level_e lvl, const char *msg) #endif } -/** - * \brief Open network port using rig.state data - * - * Open Open network port using rig.state data. - * NB: The signal PIPE will be ignored for the whole application. - * - * \param rp Port data structure (must spec port id eg hostname:port) - * \param default_port Default network socket port - * \return RIG_OK or < 0 if error - */ -int network_open(hamlib_port_t *rp, int default_port) +int network_init() { - int fd; /* File descriptor for the port */ - int status; - struct addrinfo hints, *res, *saved_res; - struct in6_addr serveraddr; - char hoststr[256], portstr[6] = ""; - - ENTERFUNC; - #ifdef __MINGW32__ WSADATA wsadata; int ret; @@ -163,6 +145,32 @@ int network_open(hamlib_port_t *rp, int default_port) } #endif + return RIG_OK; +} + +/** + * \brief Open network port using rig.state data + * + * Open Open network port using rig.state data. + * NB: The signal PIPE will be ignored for the whole application. + * + * \param rp Port data structure (must spec port id eg hostname:port) + * \param default_port Default network socket port + * \return RIG_OK or < 0 if error + */ +int network_open(hamlib_port_t *rp, int default_port) +{ + int fd; /* File descriptor for the port */ + int status; + struct addrinfo hints, *res, *saved_res; + struct in6_addr serveraddr; + char hoststr[256], portstr[6] = ""; + + ENTERFUNC; + + status = network_init(); + + if (status != RIG_OK) { RETURNFUNC(status); } if (!rp) { @@ -388,4 +396,28 @@ int network_close(hamlib_port_t *rp) } //! @endcond +/** + * \brief Open multicast server using rig.state data + * + * Open Open multicast server using rig.state data. + * NB: The signal PIPE will be ignored for the whole application. + * + * \param rp Port data structure (must spec port id eg hostname:port -- hostname defaults to 224.0.1.1) + * \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 status; + + ENTERFUNC; + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):network_multicast_server under development\n", __FILE__, __LINE__); + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):ADDR=%s, port=%d\n", __FILE__, __LINE__, multicast_addr, default_port); + status = network_init(); + + if (status != RIG_OK) { RETURNFUNC(status); } + + RETURNFUNC(RIG_OK); +} + /** @} */ diff --git a/src/network.h b/src/network.h index 1411d72a..111b0b36 100644 --- a/src/network.h +++ b/src/network.h @@ -29,6 +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); 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 31ec01f6..d116a4e7 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -76,6 +76,7 @@ #include "iofunc.h" #include "serial.h" #include "sprintflst.h" +#include "network.h" #include "rigctl_parse.h" @@ -109,6 +110,7 @@ static struct option long_options[] = {"twiddle_timeout", 1, 0, 'W'}, {"uplink", 1, 0, 'x'}, {"debug-time-stamps", 0, 0, 'Z'}, + {"multicast-addr", 1, 0, 'M'}, {0, 0, 0, 0} }; @@ -142,6 +144,7 @@ static int volatile ctrl_c; const char *portno = "4532"; const char *src_addr = NULL; /* INADDR_ANY */ +const char *multicast_addr = "224.0.1.1"; #define MAXCONFLEN 1024 @@ -542,6 +545,16 @@ int main(int argc, char *argv[]) rig_set_debug_time_stamp(1); break; + case 'M': + if (!optarg) + { + usage(); /* wrong arg count */ + exit(1); + } + + multicast_addr = optarg; + break; + default: usage(); /* unknown option? */ exit(1); @@ -733,6 +746,15 @@ int main(int argc, char *argv[]) saved_result = result; + retcode = network_multicast_server(my_rig, multicast_addr, 4532); + + if (retcode != RIG_OK) + { + rig_debug(RIG_DEBUG_ERR, "%s: network_multicast_server failed: %s\n", __FILE__, + rigerror(retcode)); + // we will consider this non-fatal for now + } + do { sock_listen = socket(result->ai_family, @@ -1222,6 +1244,7 @@ void usage(void) " -W, --twiddle_rit suppress VFOB getfreq so RIT can be twiddled\n" " -x, --uplink set uplink get_freq ignore, 1=Sub, 2=Main\n" " -Z, --debug-time-stamps enable time stamps for debug messages\n" + " -M, --multicast-addr=addr set multicast addr, default 224.0.1.1\n" " -h, --help display this help and exit\n" " -V, --version output version information and exit\n\n", portno); commit 12ce326350ee32164d7c4b881dd22b1011d9110f Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 19 13:00:37 2021 -0500 Fix JSON example in README.multicast to be good JSON https://github.com/Hamlib/Hamlib/issues/695 diff --git a/README.multicast b/README.multicast index 6d31933e..a3d22677 100644 --- a/README.multicast +++ b/README.multicast @@ -56,14 +56,14 @@ Example JSON "MinStrength": -100, "MaxStrength": 0, - // If Type=CENTER, the following fields will be present: + "__comment_spectrum_center__": "If Type=CENTER, the following fields will be present:" "CenterFreq": 14267000, "Span": 25000, - // If SpectrumType=FIXED, the following fields will be present: + "__comment_spectrum_fixed__": "If SpectrumType=FIXED, the following fields will be present:" "LowFreq": 14000000, "HighFreq": 14250000 - } + }, "Split": 0, "SatMode": 0, commit 94fa261e9d298bdcf4a8357f83d8ad43be4fa050 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed May 19 10:29:33 2021 -0500 Update README.multicast proposal https://github.com/Hamlib/Hamlib/issues/695 diff --git a/README.multicast b/README.multicast index d1249604..6d31933e 100644 --- a/README.multicast +++ b/README.multicast @@ -44,16 +44,37 @@ Example JSON "RX": 0, "TX": 0 }], + + "__comment_spectrum__": "Rigs that have spectrum output may include this data", + "Spectrum": { + "Length": 475, + "__comment_spectrum_data__": "2-char hex bytes so data len=2*Length", + "Data": "00AAFF75BD2AAA...", + "Type": "FIXED|CENTER", + "MinLevel": 0, + "MaxLevel": 140, + "MinStrength": -100, + "MaxStrength": 0, + + // If Type=CENTER, the following fields will be present: + "CenterFreq": 14267000, + "Span": 25000, + + // If SpectrumType=FIXED, the following fields will be present: + "LowFreq": 14000000, + "HighFreq": 14250000 + } + "Split": 0, "SatMode": 0, "Rig": "Dummy", "App": "Hamlib", "__comment_version__": "protocol version date YYYYMMDD", - "Version": "20210518", + "Version": "20210519", "__comment_seq__": "Seq is 1-up sequence number 32-bit -- wraps around to 1 from 2^32-1", "Seq": 1, - "__comment_crc__": "32-bit CRC of all data replacing the CRC value with 0x00000000", - "CRC": "0xf49f4708" + "__comment_crc__": "32-bit CRC of entire JSON record replacing the CRC value with 0x00000000", + "CRC": "0x00000000" } Will be able to set freq, mode, width, ptt ----------------------------------------------------------------------- Summary of changes: README.multicast | 27 +++++++++-- src/debug.c | 141 +++++++++++++++++++++++++++++++++++++------------------ src/network.c | 70 +++++++++++++++++++-------- src/network.h | 1 + tests/rigctld.c | 23 +++++++++ 5 files changed, 194 insertions(+), 68 deletions(-) hooks/post-receive -- Hamlib -- Ham radio control libraries |