[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 53476dd14df76edbff601
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: Nate B. <n0...@us...> - 2021-06-01 15:10:25
|
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 53476dd14df76edbff6013cd36c1cad0927e5ac0 (commit)
via a63d00903551e047dce5caa644fb515b54d7e632 (commit)
via c5378b9f70ca6df0b0090fab6219a3234ac04be2 (commit)
via aa161f15980c2e3dba71126b830ee9cb4c395bf6 (commit)
via 9755454ff817bbe72da4311cc78a1e5ed6191844 (commit)
via 97e36926d33e31b70f6de3fb03faf5ea6add0522 (commit)
via d9d562874db7166c79be798461bfc1630e2d89cd (commit)
via c4e6ed39e640087e57648d7b7743faf94baf1848 (commit)
via 3a67356bc1c3b4bc5d5f3697c1a7cb7242555b79 (commit)
via fabec4a94cd277787d4692ba805c42bddcd61b22 (commit)
via 263c16984ad0a15b0b51c4095611fffac47beac6 (commit)
via 503897c41cde9cd7100d08ce6c34624387c04299 (commit)
from 92ed52b5f75dfaaa31d092e10737cf8ae8eaac41 (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 53476dd14df76edbff6013cd36c1cad0927e5ac0
Author: Mike Black W9MDB <mdb...@ya...>
Date: Tue Jun 1 07:19:00 2021 -0500
Remove some more debug
diff --git a/rigs/kenwood/kenwood.c b/rigs/kenwood/kenwood.c
index 2fc0c3d2..be37b197 100644
--- a/rigs/kenwood/kenwood.c
+++ b/rigs/kenwood/kenwood.c
@@ -573,7 +573,6 @@ transaction_quit:
}
rs->hold_decode = 0;
- rig_debug(RIG_DEBUG_TRACE, "%s: returning retval=%d\n", __func__, retval);
RETURNFUNC(retval);
}
diff --git a/src/iofunc.c b/src/iofunc.c
index b42318c1..90cb9dc9 100644
--- a/src/iofunc.c
+++ b/src/iofunc.c
@@ -433,7 +433,7 @@ int HAMLIB_API write_block(hamlib_port_t *p, const char *txbuffer, size_t count)
{
int ret;
- rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
+ //rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
#ifdef WANT_NON_ACTIVE_POST_WRITE_DELAY
commit a63d00903551e047dce5caa644fb515b54d7e632
Author: Mike Black W9MDB <mdb...@ya...>
Date: Tue Jun 1 07:17:11 2021 -0500
Remove some more debug
diff --git a/src/rig.c b/src/rig.c
index 358920e6..91e93979 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -2065,7 +2065,6 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
rig_strvfo(vfo));
}
- TRACE;
retcode = caps->get_freq(rig, vfo, freq);
cache_show(rig, __func__, __LINE__);
diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c
index 97ded7e8..e571326a 100644
--- a/tests/rigctl_parse.c
+++ b/tests/rigctl_parse.c
@@ -749,7 +749,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
break;
}
- rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd==0x%02x\n", __func__, cmd);
+ //rig_debug(RIG_DEBUG_VERBOSE, "%s: cmd==0x%02x\n", __func__, cmd);
if (cmd == 0x0a || cmd == 0x0d)
{
@@ -1679,7 +1679,6 @@ readline_repeat:
p2 ? p2 : "",
p3 ? p3 : "");
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt=%d\n", __func__, *vfo_opt);
if (retcode == -RIG_EIO)
{
@@ -1735,7 +1734,6 @@ readline_repeat:
fflush(fout);
- rig_debug(RIG_DEBUG_TRACE, "%s: retcode=%d\n", __func__, retcode);
#ifdef HAVE_LIBREADLINE
if (input_line != NULL && (result = strtok(NULL, " "))) goto readline_repeat;
#endif
commit c5378b9f70ca6df0b0090fab6219a3234ac04be2
Author: Mike Black W9MDB <mdb...@ya...>
Date: Tue Jun 1 07:10:44 2021 -0500
Remove some more debug
diff --git a/src/rig.c b/src/rig.c
index 1893d075..358920e6 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -2027,8 +2027,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
int cache_ms_freq, cache_ms_mode, cache_ms_width;
rig_get_cache(rig, vfo, freq, &cache_ms_freq, &mode, &cache_ms_mode, &width,
&cache_ms_width);
- rig_debug(RIG_DEBUG_TRACE, "%s: cache check1 age=%dms\n", __func__,
- cache_ms_freq);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: cache check1 age=%dms\n", __func__, cache_ms_freq);
cache_show(rig, __func__, __LINE__);
diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c
index ecba8732..97ded7e8 100644
--- a/tests/rigctl_parse.c
+++ b/tests/rigctl_parse.c
@@ -787,7 +787,6 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
my_rig->state.vfo_opt = *vfo_opt;
- rig_debug(RIG_DEBUG_TRACE, "%s: vfo_opt=%d\n", __func__, *vfo_opt);
if (cmd == 'Q' || cmd == 'q')
{
commit aa161f15980c2e3dba71126b830ee9cb4c395bf6
Author: Mike Black W9MDB <mdb...@ya...>
Date: Tue Jun 1 07:03:24 2021 -0500
Comment out some debug from rigctl_parse.c
diff --git a/tests/rigctl_parse.c b/tests/rigctl_parse.c
index 1972aa56..ecba8732 100644
--- a/tests/rigctl_parse.c
+++ b/tests/rigctl_parse.c
@@ -879,18 +879,18 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
}
- rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug1\n", __func__);
if ((cmd_entry->flags & ARG_IN_LINE)
&& (cmd_entry->flags & ARG_IN1)
&& cmd_entry->arg1)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug2\n", __func__);
if (interactive)
{
char *nl;
- rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug2a\n", __func__);
if (fgets(arg1, MAXARGSZ, fin) == NULL)
@@ -900,7 +900,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
if (arg1[0] == 0xa)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug2b\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug2b\n", __func__);
if (prompt)
{
@@ -949,13 +949,13 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else if ((cmd_entry->flags & ARG_IN1) && cmd_entry->arg1)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug3\n", __func__);
if (interactive)
{
arg1[0] = fgetc(fin);
arg1[1] = 0;
- rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug4 arg1=%c\n", __func__, arg1[0]);
if (prompt && arg1[0] == 0x0a)
{
@@ -989,22 +989,22 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
}
- rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug5\n", __func__);
if (p1
&& p1[0] != '?'
&& (cmd_entry->flags & ARG_IN2)
&& cmd_entry->arg2)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug6\n", __func__);
if (interactive)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug7\n", __func__);
if (prompt)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug8\n", __func__);
fprintf_flush(fout, "%s: ", cmd_entry->arg2);
}
@@ -1018,7 +1018,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug9\n", __func__);
retcode = next_word(arg2, argc, argv, 0);
if (EOF == retcode)
@@ -1036,22 +1036,22 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
}
- rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug10\n", __func__);
if (p1
&& p1[0] != '?'
&& (cmd_entry->flags & ARG_IN3)
&& cmd_entry->arg3)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug11\n", __func__);
if (interactive)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug12\n", __func__);
if (prompt)
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug13\n", __func__);
fprintf_flush(fout, "%s: ", cmd_entry->arg3);
}
@@ -1065,7 +1065,7 @@ int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc,
}
else
{
- rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__);
+ //rig_debug(RIG_DEBUG_TRACE, "%s: debug14\n", __func__);
retcode = next_word(arg3, argc, argv, 0);
if (EOF == retcode)
commit 9755454ff817bbe72da4311cc78a1e5ed6191844
Author: Mike Black W9MDB <mdb...@ya...>
Date: Mon May 31 17:42:07 2021 -0500
Fix Icom UDP server check
diff --git a/src/rig.c b/src/rig.c
index 574a012c..1893d075 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -720,7 +720,7 @@ int HAMLIB_API rig_open(RIG *rig)
rs->rigport.pathname);
rs->rigport.type.rig = RIG_PORT_NETWORK;
- if (rig->caps->rig_model & RIG_ICOM)
+ if ((rig->caps->rig_model & RIG_ICOM) == RIG_ICOM)
{
rig_debug(RIG_DEBUG_TRACE, "%s(%d): Icom rig UDP network enabled\n", __FILE__,
__LINE__);
commit 97e36926d33e31b70f6de3fb03faf5ea6add0522
Author: Mike Black W9MDB <mdb...@ya...>
Date: Mon May 31 09:05:41 2021 -0500
Enable UDP network for Icom rigs
diff --git a/src/rig.c b/src/rig.c
index 559946a1..574a012c 100644
--- a/src/rig.c
+++ b/src/rig.c
@@ -90,7 +90,7 @@ const char *hamlib_license = "LGPL";
//! @cond Doxygen_Suppress
const char hamlib_version[21] = "Hamlib " PACKAGE_VERSION;
const char *hamlib_version2 = "Hamlib " PACKAGE_VERSION " " HAMLIBDATETIME;
-HAMLIB_EXPORT_VAR (int) cookie_use;
+HAMLIB_EXPORT_VAR(int) cookie_use;
//! @endcond
struct rig_caps caps_test;
@@ -719,6 +719,13 @@ int HAMLIB_API rig_open(RIG *rig)
rig_debug(RIG_DEBUG_TRACE, "%s: using network address %s\n", __func__,
rs->rigport.pathname);
rs->rigport.type.rig = RIG_PORT_NETWORK;
+
+ if (rig->caps->rig_model & RIG_ICOM)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s(%d): Icom rig UDP network enabled\n", __FILE__,
+ __LINE__);
+ rs->rigport.type.rig = RIG_PORT_UDP_NETWORK;
+ }
}
if (rs->comm_state)
@@ -1102,13 +1109,19 @@ int HAMLIB_API rig_close(RIG *rig)
extern int multicast_server_run;
multicast_server_run = 0;
extern pthread_t multicast_server_threadId;
- int err = pthread_join(multicast_server_threadId, NULL);
- if (err)
+ if (multicast_server_threadId != 0)
{
- rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__,
- strerror(errno));
- // just ignore it
+ int err = pthread_join(multicast_server_threadId, NULL);
+
+ if (err)
+ {
+ rig_debug(RIG_DEBUG_ERR, "%s(%d): pthread_join error %s\n", __FILE__, __LINE__,
+ strerror(errno));
+ // just ignore it
+ }
+
+ multicast_server_threadId = 0;
}
if (!rig || !rig->caps)
@@ -6526,6 +6539,7 @@ const char *HAMLIB_API rig_copyright()
* while((cookie=rig_cookie(NULL, RIG_COOKIE_GET)) == NULL) hl_usleep(10*1000);
* set_freq A;set mode A;set freq B;set modeB;
* rig_cookie(cookie,RIG_COOKIE_RELEASE);
+ * if wait!=0 rig_cookie with RIG_COOKIE_GET will wait for the cookie to become available
*/
int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
int cookie_len)
@@ -6539,6 +6553,7 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
static double time_last_used;
double time_curr;
struct timespec tp;
+ static pthread_mutex_t cookie_lock = PTHREAD_MUTEX_INITIALIZER;
if (cookie_len < 27)
{
@@ -6597,21 +6612,31 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
break;
case RIG_COOKIE_GET:
+
// the way we expire cookies is if somebody else asks for one and the last renewal is > 1 second ago
// a polite client will have released the cookie
// we are just allow for a crashed client that fails to release:q
+
clock_gettime(CLOCK_REALTIME, &tp);
time_curr = tp.tv_sec + tp.tv_nsec / 1e9;
+#ifdef HAVE_PTHREAD
+ pthread_mutex_lock(&cookie_lock);
+#endif
+
if (cookie_save[0] != 0 && (strcmp(cookie_save, cookie) == 0)
&& (time_curr - time_last_used < 1)) // then we will deny the request
{
printf("Cookie %s in use\n", cookie_save);
rig_debug(RIG_DEBUG_ERR, "%s(%d): %s cookie is in use\n", __FILE__, __LINE__,
cookie_save);
+#ifdef HAVE_PTHREAD
+ pthread_mutex_unlock(&cookie_lock);
+#endif
return -RIG_BUSBUSY;
}
+
if (cookie_save[0] != 0)
{
rig_debug(RIG_DEBUG_ERR,
@@ -6626,14 +6651,36 @@ int HAMLIB_API rig_cookie(RIG *rig, enum cookie_e cookie_cmd, char *cookie,
time_last_used = time_curr;
rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): %s new cookie request granted\n",
__FILE__, __LINE__, cookie_save);
+#ifdef HAVE_PTHREAD
+ pthread_mutex_unlock(&cookie_lock);
+#endif
return RIG_OK;
break;
-
}
rig_debug(RIG_DEBUG_ERR, "%s(%d): unknown condition!!\n'", __FILE__, __LINE__);
return -RIG_EPROTO;
}
+HAMLIB_EXPORT(void) sync_callback(int lock)
+{
+#ifdef HAVE_PTHREAD
+ static pthread_mutex_t client_lock = PTHREAD_MUTEX_INITIALIZER;
+
+ if (lock)
+ {
+ pthread_mutex_lock(&client_lock);
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: client lock engaged\n", __func__);
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: client lock disengaged\n", __func__);
+ pthread_mutex_unlock(&client_lock);
+ }
+
+#endif
+}
+
/*! @} */
+
commit d9d562874db7166c79be798461bfc1630e2d89cd
Author: Mike Black W9MDB <mdb...@ya...>
Date: Mon May 31 08:36:45 2021 -0500
Fix compilation warning in icom.c
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index 1375f9af..88b8faee 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -7944,7 +7944,7 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *
int max_division = (int) from_bcd(frame_data + 2, 1 * 2);
int spectrum_data_length_in_frame;
- unsigned char *spectrum_data_start_in_frame;
+ const unsigned char *spectrum_data_start_in_frame;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
commit c4e6ed39e640087e57648d7b7743faf94baf1848
Merge: fabec4a9 3a67356b
Author: Michael Black <mdb...@ya...>
Date: Mon May 31 08:31:42 2021 -0500
Merge pull request #715 from mikaelnousiainen/fix-icom-transceive-and-spectrum-data-conflicts
Attempt to handle asynchronous rig output data in Icom backend
commit 3a67356bc1c3b4bc5d5f3697c1a7cb7242555b79
Author: Mikael Nousiainen <mik...@ik...>
Date: Mon May 31 16:22:22 2021 +0300
Add some comments and improved debugging on SIGIO async data handling
diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c
index 967535c2..65997f09 100644
--- a/rigs/icom/frame.c
+++ b/rigs/icom/frame.c
@@ -346,6 +346,7 @@ read_another_frame:
RETURNFUNC(-RIG_EPROTO);
}
+ // TODO: Does ctrlid (detected by icom_is_async_frame) vary (seeing some code above using 0x80 for non-full-duplex)?
if (icom_is_async_frame(rig, frm_len, buf))
{
int elapsed_ms;
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index 8f09cc21..1375f9af 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -8061,9 +8061,6 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *
int icom_is_async_frame(RIG *rig, int frame_len, const unsigned char *frame)
{
- struct rig_state *rs = &rig->state;
- struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
-
if (frame_len < ACKFRMLEN)
{
return 0;
@@ -8167,7 +8164,7 @@ int icom_decode_event(RIG *rig)
if (frm_len < 1)
{
- RETURNFUNC(0);
+ RETURNFUNC(RIG_OK);
}
retval = icom_frame_fix_preamble(frm_len, buf);
diff --git a/src/event.c b/src/event.c
index 79b3d4e7..e0e9cbf1 100644
--- a/src/event.c
+++ b/src/event.c
@@ -56,9 +56,9 @@
#include <signal.h>
#include <errno.h>
-
#include <hamlib/rig.h>
#include "event.h"
+#include "misc.h"
#if defined(WIN32) && !defined(HAVE_TERMIOS_H)
# include "win32termios.h"
@@ -300,6 +300,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
struct timeval tv;
int retval;
+ ENTERFUNC;
+
/*
* so far, only file oriented ports have event reporting support
*/
@@ -309,6 +311,22 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
return -1;
}
+ /*
+ * TODO: FIXME: We may end up calling decode_event right before or after the hold_decode lock is released
+ * by backend transaction routine. With the Icom backend this will end up waiting for the next CI-V frame
+ * to be read and this will interfere with reading of the next response to any command.
+ * => It is difficult to find a way to avoid this routine picking up regular responses.
+ */
+
+ /*
+ * Do not disturb, the backend is currently receiving data
+ */
+ if (rig->state.hold_decode)
+ {
+ rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__);
+ RETURNFUNC(-1);
+ }
+
/* FIXME: siginfo is not portable, however use it where available */
#if 0&&defined(HAVE_SIGINFO_T)
siginfo_t *si = (siginfo_t *)data;
@@ -334,10 +352,10 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
if (retval < 0)
{
rig_debug(RIG_DEBUG_ERR,
- "%s: select: %s\n",
+ "%s: select() failed: %s\n",
__func__,
strerror(errno));
- return -1;
+ RETURNFUNC(-1);
}
#endif
@@ -347,7 +365,8 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
*/
if (rig->state.hold_decode)
{
- return -1;
+ rig_debug(RIG_DEBUG_TRACE, "%s: hold decode, backend is receiving data\n", __func__);
+ RETURNFUNC(-1);
}
if (rig->caps->decode_event)
@@ -355,7 +374,7 @@ static int search_rig_and_decode(RIG *rig, rig_ptr_t data)
rig->caps->decode_event(rig);
}
- return 1; /* process each opened rig */
+ RETURNFUNC(1); /* process each opened rig */
}
diff --git a/tests/rigctld.c b/tests/rigctld.c
index 10518521..50845a95 100644
--- a/tests/rigctld.c
+++ b/tests/rigctld.c
@@ -910,11 +910,19 @@ int main(int argc, char *argv[])
timeout.tv_usec = 0;
retcode = select(sock_listen + 1, &set, NULL, NULL, &timeout);
- if (-1 == retcode)
+ if (retcode == -1)
{
- rig_debug(RIG_DEBUG_ERR, "%s: select\n", __func__);
+ int errno_stored = errno;
+ rig_debug(RIG_DEBUG_ERR, "%s: select() failed: %s\n", __func__, strerror(errno_stored));
+
+ // TODO: FIXME: Why does this select() return EINTR after any command when set_trn RIG is enabled?
+ if (errno == EINTR)
+ {
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: ignoring interrupted system call\n", __func__);
+ retcode = 0;
+ }
}
- else if (!retcode)
+ else if (retcode == 0)
{
if (ctrl_c)
{
@@ -1039,11 +1047,13 @@ void *handle_socket(void *arg)
int ext_resp = 0;
char resp_sep = '\n';
+ ENTERFUNC;
+
fsockin = get_fsockin(handle_data_arg);
if (!fsockin)
{
- rig_debug(RIG_DEBUG_ERR, "fdopen(0x%d) in: %s\n", handle_data_arg->sock,
+ rig_debug(RIG_DEBUG_ERR, "%s: fdopen(0x%d) in: %s\n", __func__, handle_data_arg->sock,
strerror(errno));
goto handle_exit;
}
@@ -1052,7 +1062,7 @@ void *handle_socket(void *arg)
if (!fsockout)
{
- rig_debug(RIG_DEBUG_ERR, "fdopen out: %s\n", strerror(errno));
+ rig_debug(RIG_DEBUG_ERR, "%s: fdopen out: %s\n", __func__, strerror(errno));
fclose(fsockin);
goto handle_exit;
commit fabec4a94cd277787d4692ba805c42bddcd61b22
Author: Mike Black W9MDB <mdb...@ya...>
Date: Sun May 30 06:48:12 2021 -0500
Improve rig_open error msg in rigctl.c and rigctld.c
diff --git a/tests/rigctl.c b/tests/rigctl.c
index fcb77a37..2a9437b0 100644
--- a/tests/rigctl.c
+++ b/tests/rigctl.c
@@ -552,7 +552,7 @@ int main(int argc, char *argv[])
if (retcode != RIG_OK)
{
- fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
+ fprintf(stderr, "rig_open: error = %s %s %s \n", rigerror(retcode), rig_file, strerror(errno));
if (!ignore_rig_open_error) { exit(2); }
}
diff --git a/tests/rigctld.c b/tests/rigctld.c
index 10518521..b497a77e 100644
--- a/tests/rigctld.c
+++ b/tests/rigctld.c
@@ -666,7 +666,7 @@ int main(int argc, char *argv[])
if (retcode != RIG_OK)
{
- fprintf(stderr, "rig_open: error = %s \n", rigerror(retcode));
+ fprintf(stderr, "rig_open: error = %s %s %s \n", rigerror(retcode), rig_file, strerror(errno));
exit(2);
}
commit 263c16984ad0a15b0b51c4095611fffac47beac6
Author: Mikael Nousiainen <mik...@ik...>
Date: Sun May 30 01:36:49 2021 +0300
Attempt to handle asynchronously pushed Icom CI-V frames (transceive and spectrum data) as these frame will get interleaved with command responses
diff --git a/rigs/icom/frame.c b/rigs/icom/frame.c
index 3030b503..967535c2 100644
--- a/rigs/icom/frame.c
+++ b/rigs/icom/frame.c
@@ -23,9 +23,7 @@
#include "config.h"
#endif
-#include <stdlib.h>
#include <string.h> /* String function definitions */
-#include <unistd.h> /* UNIX standard function definitions */
#include "hamlib/rig.h"
#include "serial.h"
@@ -90,6 +88,26 @@ int make_cmd_frame(char frame[], char re_id, char ctrl_id, char cmd, int subcmd,
RETURNFUNC(i);
}
+int icom_frame_fix_preamble(int frame_len, unsigned char *frame)
+{
+ if (frame[0] == PR)
+ {
+ // Sometimes the second preamble byte is missing -> TODO: Find out why!
+ if (frame[1] != PR)
+ {
+ memmove(frame + 1, frame, frame_len);
+ frame_len++;
+ }
+ }
+ else
+ {
+ rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n", __func__);
+ RETURNFUNC(-RIG_EPROTO);
+ }
+
+ return frame_len;
+}
+
/*
* icom_one_transaction
*
@@ -109,11 +127,12 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
struct icom_priv_data *priv;
const struct icom_priv_caps *priv_caps;
struct rig_state *rs;
+ struct timeval start_time, current_time, elapsed_time;
// this buf needs to be large enough for 0xfe strings for power up
// at 115,200 this is now at least 150
unsigned char buf[200];
unsigned char sendbuf[MAXFRAMELEN];
- int frm_len, retval;
+ int frm_len, frm_data_len, retval;
int ctrl_id;
ENTERFUNC;
@@ -168,12 +187,14 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
if (retval < 0)
{
+ Unhold_Decode(rig);
/* Other error, return it */
RETURNFUNC(retval);
}
if (retval < 1)
{
+ Unhold_Decode(rig);
RETURNFUNC(-RIG_EPROTO);
}
@@ -223,6 +244,9 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
RETURNFUNC(RIG_OK);
}
+ gettimeofday(&start_time, NULL);
+
+read_another_frame:
/*
* wait for ACK ...
* FIXME: handle padding/collisions
@@ -245,10 +269,9 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
#endif
- Unhold_Decode(rig);
-
if (frm_len < 0)
{
+ Unhold_Decode(rig);
/* RIG_TIMEOUT: timeout getting response, return timeout */
/* other error: return it */
RETURNFUNC(frm_len);
@@ -256,12 +279,23 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
if (frm_len < 1)
{
+ Unhold_Decode(rig);
RETURNFUNC(-RIG_EPROTO);
}
+ retval = icom_frame_fix_preamble(frm_len, buf);
+ if (retval < 0)
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(retval);
+ }
+
+ frm_len = retval;
+
switch (buf[frm_len - 1])
{
case COL:
+ Unhold_Decode(rig);
/* Collision */
RETURNFUNC(-RIG_BUSBUSY);
@@ -270,30 +304,70 @@ int icom_one_transaction(RIG *rig, int cmd, int subcmd,
break;
case NAK:
+ Unhold_Decode(rig);
RETURNFUNC(-RIG_ERJCTED);
default:
+ Unhold_Decode(rig);
/* Timeout after reading at least one character */
/* Problem on ci-v bus? */
RETURNFUNC(-RIG_EPROTO);
}
- if (frm_len < ACKFRMLEN) { RETURNFUNC(-RIG_EPROTO); }
+ if (frm_len < ACKFRMLEN)
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(-RIG_EPROTO);
+ }
// if we send a bad command we will get back a NAK packet
// e.g. fe fe e0 50 fa fd
- if (frm_len == 6 && NAK == buf[frm_len - 2]) { RETURNFUNC(-RIG_ERJCTED); }
+ if (frm_len == 6 && NAK == buf[frm_len - 2])
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(-RIG_ERJCTED);
+ }
rig_debug(RIG_DEBUG_TRACE, "%s: frm_len=%d, frm_len-1=%02x, frm_len-2=%02x\n",
__func__, frm_len, buf[frm_len - 1], buf[frm_len - 2]);
// has to be one of these two now or frame is corrupt
- if (FI != buf[frm_len - 1] && ACK != buf[frm_len - 1]) { RETURNFUNC(-RIG_BUSBUSY); }
+ if (FI != buf[frm_len - 1] && ACK != buf[frm_len - 1])
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(-RIG_BUSBUSY);
+ }
+
+ frm_data_len = frm_len - (ACKFRMLEN - 1);
+
+ if (frm_data_len <= 0)
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(-RIG_EPROTO);
+ }
+
+ if (icom_is_async_frame(rig, frm_len, buf))
+ {
+ int elapsed_ms;
+ icom_process_async_frame(rig, frm_len, buf);
+
+ gettimeofday(¤t_time, NULL);
+ timersub(¤t_time, &start_time, &elapsed_time);
- *data_len = frm_len - (ACKFRMLEN - 1);
+ elapsed_ms = (int) (elapsed_time.tv_sec * 1000 + elapsed_time.tv_usec / 1000);
- if (*data_len <= 0) { RETURNFUNC(-RIG_EPROTO); }
+ if (elapsed_ms > rs->rigport.timeout)
+ {
+ Unhold_Decode(rig);
+ RETURNFUNC(-RIG_ETIMEOUT);
+ }
+
+ goto read_another_frame;
+ }
+
+ Unhold_Decode(rig);
+ *data_len = frm_data_len;
memcpy(data, buf + 4, *data_len);
/*
diff --git a/rigs/icom/frame.h b/rigs/icom/frame.h
index b5d84621..0ffc7e0e 100644
--- a/rigs/icom/frame.h
+++ b/rigs/icom/frame.h
@@ -28,6 +28,7 @@
* helper functions
*/
int make_cmd_frame(char frame[], char re_id, char ctrl_id, char cmd, int subcmd, const unsigned char *data, int data_len);
+int icom_frame_fix_preamble(int frame_len, unsigned char *frame);
int icom_transaction (RIG *rig, int cmd, int subcmd, const unsigned char *payload, int payload_len, unsigned char *data, int *data_len);
int read_icom_frame(hamlib_port_t *p, unsigned char rxbuffer[], int rxbuffer_len);
diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c
index b81609d3..8f09cc21 100644
--- a/rigs/icom/icom.c
+++ b/rigs/icom/icom.c
@@ -7933,7 +7933,7 @@ int icom_mW2power(RIG *rig, float *power, unsigned int mwpower, freq_t freq,
RETURNFUNC(RIG_OK);
}
-static int icom_parse_spectrum_frame(RIG *rig, int length, unsigned char *frame_data)
+static int icom_parse_spectrum_frame(RIG *rig, int length, const unsigned char *frame_data)
{
struct rig_caps *caps = rig->caps;
struct icom_priv_caps *priv_caps = (struct icom_priv_caps *) caps->priv;
@@ -8059,6 +8059,88 @@ static int icom_parse_spectrum_frame(RIG *rig, int length, unsigned char *frame_
RETURNFUNC(RIG_OK);
}
+int icom_is_async_frame(RIG *rig, int frame_len, const unsigned char *frame)
+{
+ struct rig_state *rs = &rig->state;
+ struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
+
+ if (frame_len < ACKFRMLEN)
+ {
+ return 0;
+ }
+
+ /* Spectrum scope data is not CI-V transceive data, but handled the same way as it is pushed by the rig */
+ return frame[2] == BCASTID || (frame[2] == CTRLID && frame[4] == C_CTL_SCP && frame[5] == S_SCP_DAT);
+}
+
+int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame)
+{
+ struct rig_state *rs = &rig->state;
+ struct icom_priv_data *priv = (struct icom_priv_data *) rs->priv;
+ rmode_t mode;
+ pbwidth_t width;
+
+ rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
+
+ /*
+ * the first 2 bytes must be 0xfe
+ * the 3rd one 0x00 since this is transceive mode
+ * the 4rd one the emitter
+ * then the command number
+ * the rest is data
+ * and don't forget one byte at the end for the EOM
+ */
+ switch (frame[4])
+ {
+ case C_SND_FREQ:
+ /*
+ * TODO: the freq length might be less than 4 or 5 bytes
+ * on older rigs!
+ */
+ if (rig->callbacks.freq_event)
+ {
+ freq_t freq;
+ freq = from_bcd(frame + 5, (priv->civ_731_mode ? 4 : 5) * 2);
+ RETURNFUNC(rig->callbacks.freq_event(rig, RIG_VFO_CURR, freq,
+ rig->callbacks.freq_arg));
+ }
+ else
+ {
+ RETURNFUNC(-RIG_ENAVAIL);
+ }
+
+ break;
+
+ case C_SND_MODE:
+ if (rig->callbacks.mode_event)
+ {
+ icom2rig_mode(rig, frame[5], frame[6], &mode, &width);
+ RETURNFUNC(rig->callbacks.mode_event(rig, RIG_VFO_CURR,
+ mode, width, rig->callbacks.mode_arg));
+ }
+ else
+ {
+ RETURNFUNC(-RIG_ENAVAIL);
+ }
+
+ break;
+
+ case C_CTL_SCP:
+ if (frame[5] == S_SCP_DAT)
+ {
+ icom_parse_spectrum_frame(rig, frame_len - (6 + 1), frame + 6);
+ }
+ break;
+
+ default:
+ rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n",
+ __func__, frame[4]);
+ RETURNFUNC(-RIG_ENIMPL);
+ }
+
+ RETURNFUNC(RIG_OK);
+}
+
/*
* icom_decode is called by sa_sigio, when some asynchronous
* data has been received from the rig
@@ -8068,9 +8150,7 @@ int icom_decode_event(RIG *rig)
struct icom_priv_data *priv;
struct rig_state *rs;
unsigned char buf[MAXFRAMELEN];
- int frm_len;
- rmode_t mode;
- pbwidth_t width;
+ int retval, frm_len;
rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__);
@@ -8090,21 +8170,14 @@ int icom_decode_event(RIG *rig)
RETURNFUNC(0);
}
- if (buf[0] == PR)
+ retval = icom_frame_fix_preamble(frm_len, buf);
+ if (retval < 0)
{
- // Sometimes the second preamble byte is missing -> TODO: Find out why!
- if (buf[1] != PR)
- {
- memmove(buf + 1, buf, frm_len);
- frm_len++;
- }
- }
- else
- {
- rig_debug(RIG_DEBUG_WARN, "%s: invalid Icom CI-V frame, no preamble found\n", __func__);
- RETURNFUNC(-RIG_EPROTO);
+ RETURNFUNC(retval);
}
+ frm_len = retval;
+
switch (buf[frm_len - 1])
{
case COL:
@@ -8122,72 +8195,13 @@ int icom_decode_event(RIG *rig)
RETURNFUNC(-RIG_EPROTO);
}
- /* Spectrum scope data is not CI-V transceive data, but handled the same way as it is pushed by the rig */
- if (buf[3] != BCASTID && buf[3] != priv->re_civ_addr && buf[4] != C_CTL_SCP)
+ if (!icom_is_async_frame(rig, frm_len, buf))
{
rig_debug(RIG_DEBUG_WARN, "%s: CI-V %#x called for %#x!\n", __func__,
- priv->re_civ_addr, buf[3]);
- }
-
- /*
- * the first 2 bytes must be 0xfe
- * the 3rd one the emitter
- * the 4rd one 0x00 since this is transceive mode
- * then the command number
- * the rest is data
- * and don't forget one byte at the end for the EOM
- */
- switch (buf[4])
- {
- case C_SND_FREQ:
-
- /*
- * TODO: the freq length might be less than 4 or 5 bytes
- * on older rigs!
- */
- if (rig->callbacks.freq_event)
- {
- freq_t freq;
- freq = from_bcd(buf + 5, (priv->civ_731_mode ? 4 : 5) * 2);
- RETURNFUNC(rig->callbacks.freq_event(rig, RIG_VFO_CURR, freq,
- rig->callbacks.freq_arg));
- }
- else
- {
- RETURNFUNC(-RIG_ENAVAIL);
- }
-
- break;
-
- case C_SND_MODE:
- if (rig->callbacks.mode_event)
- {
- icom2rig_mode(rig, buf[5], buf[6], &mode, &width);
- RETURNFUNC(rig->callbacks.mode_event(rig, RIG_VFO_CURR,
- mode, width,
- rig->callbacks.mode_arg));
- }
- else
- {
- RETURNFUNC(-RIG_ENAVAIL);
- }
-
- break;
-
- case C_CTL_SCP:
- if (buf[5] == S_SCP_DAT)
- {
- icom_parse_spectrum_frame(rig, frm_len - (6 + 1), buf + 6);
- }
- break;
-
- default:
- rig_debug(RIG_DEBUG_VERBOSE, "%s: transceive cmd unsupported %#2.2x\n",
- __func__, buf[4]);
- RETURNFUNC(-RIG_ENIMPL);
+ priv->re_civ_addr, buf[2]);
}
- RETURNFUNC(RIG_OK);
+ RETURNFUNC(icom_process_async_frame(rig, frm_len, buf));
}
int icom_set_raw(RIG *rig, int cmd, int subcmd, int subcmdbuflen,
diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h
index d9a2974b..29697889 100644
--- a/rigs/icom/icom.h
+++ b/rigs/icom/icom.h
@@ -387,6 +387,8 @@ int icom_set_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf,
int icom_get_custom_parm_time(RIG *rig, int parmbuflen, unsigned char *parmbuf,
int *seconds);
int icom_get_freq_range(RIG *rig);
+int icom_is_async_frame(RIG *rig, int frame_len, const unsigned char *frame);
+int icom_process_async_frame(RIG *rig, int frame_len, const unsigned char *frame);
extern const struct confparams icom_cfg_params[];
extern const struct confparams icom_ext_levels[];
diff --git a/src/misc.c b/src/misc.c
index 1cc7d65f..5e851016 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1904,7 +1904,7 @@ int HAMLIB_API parse_hoststr(char *hoststr, char host[256], char port[6])
return -1;
}
-#undef RIG_FLUSH_REMOVE
+#define RIG_FLUSH_REMOVE
int HAMLIB_API rig_flush(hamlib_port_t *port)
{
#ifndef RIG_FLUSH_REMOVE
commit 503897c41cde9cd7100d08ce6c34624387c04299
Author: Mike Black W9MDB <mdb...@ya...>
Date: Thu May 27 23:40:33 2021 -0500
Fix debug msg in netrigctl.c
diff --git a/rigs/dummy/netrigctl.c b/rigs/dummy/netrigctl.c
index e8ceb1b5..7f6cb569 100644
--- a/rigs/dummy/netrigctl.c
+++ b/rigs/dummy/netrigctl.c
@@ -806,7 +806,7 @@ static int netrigctl_close(RIG *rig)
return ret;
}
- rig_debug(RIG_DEBUG_ERR, "%s: done status=%s\n", __func__, rigerror(ret));
+ rig_debug(RIG_DEBUG_ERR, "%s: done\n", __func__);
usleep(10 * 1000);
return RIG_OK;
-----------------------------------------------------------------------
Summary of changes:
rigs/dummy/netrigctl.c | 2 +-
rigs/icom/frame.c | 95 ++++++++++++++++++++++++---
rigs/icom/frame.h | 1 +
rigs/icom/icom.c | 171 ++++++++++++++++++++++++++-----------------------
rigs/icom/icom.h | 2 +
rigs/kenwood/kenwood.c | 1 -
src/event.c | 29 +++++++--
src/iofunc.c | 2 +-
src/misc.c | 2 +-
src/rig.c | 65 ++++++++++++++++---
tests/rigctl.c | 2 +-
tests/rigctl_parse.c | 37 +++++------
tests/rigctld.c | 22 +++++--
13 files changed, 295 insertions(+), 136 deletions(-)
hooks/post-receive
--
Hamlib -- Ham radio control libraries
|