From b17d681fc28f48e6bda9103f78552c348c87ab56 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Mon, 8 Nov 2021 10:28:28 -0600 Subject: [PATCH] More portable debug method -- should work on any compiler --- simulators/simyaesu.c | 10 ++++++++++ src/misc.c | 6 +++--- src/misc.h | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index 1e24d0fef..0417247cb 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -147,6 +147,16 @@ int main(int argc, char *argv[]) if (n <= 0) { perror("ID"); } } + else if (strcmp(buf, "AI;") == 0) + { + printf("%s\n", buf); + usleep(50 * 1000); + snprintf(buf, sizeof(buf), "AI0;"); + n = write(fd, buf, strlen(buf)); + printf("n=%d\n", n); + + if (n <= 0) { perror("ID"); } + } #if 0 else if (strncmp(buf, "AI", 2) == 0) diff --git a/src/misc.c b/src/misc.c index 98c5be4a3..972e6f4e8 100644 --- a/src/misc.c +++ b/src/misc.c @@ -1739,7 +1739,7 @@ static int linenum = 0; vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *func, int line) { funcname = (char*)func; - linenum = line; + linenum = (int)line; return vfo_fixup(rig,vfo,split); } @@ -1748,8 +1748,8 @@ vfo_t HAMLIB_API vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *fun // So we map these to Main/Sub as required vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo, split_t split) { - rig_debug(RIG_DEBUG_TRACE, "%s(from %s:%d): vfo=%s, vfo_curr=%s\n", __func__, funcname, linenum, - rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s:(from %s:%d) vfo=%s, vfo_curr=%s, split=%d\n", __func__, funcname, linenum, + rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo), split); if (vfo == RIG_VFO_CURR) { diff --git a/src/misc.h b/src/misc.h index 145d4493b..74b76e5f9 100644 --- a/src/misc.h +++ b/src/misc.h @@ -107,8 +107,8 @@ extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t usec); extern HAMLIB_EXPORT(double) elapsed_ms(struct timespec *start, int start_flag); extern HAMLIB_EXPORT(vfo_t) vfo_fixup(RIG *rig, vfo_t vfo, split_t split); -extern HAMLIB_EXPORT(vfo_t) vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *func, int line); -#define vfo_fixup(r,v,s) vfo_fixup2a(r,v,s,__builtin_FUNCTION(),__LINE__) +extern HAMLIB_EXPORT(vfo_t) vfo_fixup2a(RIG *rig, vfo_t vfo, split_t split, const char *func, const int line); +#define vfo_fixup(r,v,s) vfo_fixup2a(r,v,s,__func__,__LINE__) extern HAMLIB_EXPORT(int) parse_hoststr(char *hoststr, char host[256], char port[6]);