[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. ae69772d2a5dd8adad0c8
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: n0nb <n0...@us...> - 2023-12-08 18:56:35
|
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 ae69772d2a5dd8adad0c8de51b6c44db5f060e35 (commit) via f6eed234941f4985b992b57a2a2fd3c84aa1e403 (commit) via cf973c9b0aad24e764c03b8df48cbfbca4040e78 (commit) via 3729f658ecd6b9697233a6f741eb2beebed6f5f6 (commit) via 768ca6105d3b0cf3fa18c5988f1c418c7594a1c6 (commit) via f0e97a9e0e0c9d13479972996836df410beda484 (commit) via 4e1aa90499126198ff10069e7b1a1456c0d55889 (commit) via f4d40e0d79193a9b1925b9bac0ed7e9c9a5d2882 (commit) via e3f1816e8a422729b9ca4750d4690a2017b3c493 (commit) via 37fb4eafdd33cdb88beda3d20e94a6ffcf12d781 (commit) via ed630b28d196bcf723a52199c71b9b9f45f75f08 (commit) via f255f6f8d8412c423a2fffb4864e11200f45491f (commit) via 88c3d9427b5683f1d183cf75bceaefd346500847 (commit) via cc49669b494e736726b496fbec8e85b67904caf7 (commit) via 8940d915220b97b5ed4f25bfc9e606c89df48ac8 (commit) via e40981e198163d0acf7d9ab98bc073ee823b97fc (commit) via a5ad218bba7879b7e57c4b65043b1ead08ad3180 (commit) via 7973db52de5d149e7a416aabd19c093659e92629 (commit) via 001dd01a10397ec63f1ddcce05c9bddd843a9cbd (commit) via 756fad1c723cd77d2aa0e212777b29b7f352ed46 (commit) via 07f57cfc18349100280d26c3466d6b284512b561 (commit) via ed941939359da9f8734dbdf4a21a9b01622a1a6e (commit) via a910b16e8f961506d2408ff62632f8afe797f323 (commit) via 4f019e622e3c3957e94d5f42de8be93cdc55c6f4 (commit) via c0457a0d7b8f894baf4f8f2e446f36922cb9c1a1 (commit) via 09ab2819b3b66936e7a7d73d832660fc59354643 (commit) via 46c16b22a0bbce4acd5d25a6bcdcac69708a588e (commit) via 698cb10ff3a5921454924f0f5e05534ba21b55bd (commit) via 9c01045356a29622857ca7338329903317123a83 (commit) via 30f47cdeba342f80905a1c73a9b9afc3fa59dbc3 (commit) via 50563e2fce8132db121c42393e4256a796622996 (commit) via 6712f32fe3dc1aed1ac1ed4ee4bfe5c238a43f1c (commit) via 8c49a977faef8d8ffec9bfd546dc37752f6aef8f (commit) via 5bb669edbd24e6e05db0c67f8b826bf70c01dd4a (commit) via 9841e500b94f642a0b4511991faccb0143c32475 (commit) via f28d6742112ea0e508b21246cce42e082f4f9579 (commit) via 50c4646c1d237deb806b88724e171f7f6c9dfe48 (commit) via f88399ed3a2828fb967e7d570c13b19e029411f6 (commit) via d0fd27afd6b4d9df99b0e3c3e6afeafacbb88117 (commit) via 5d51e29d4459ff3a9dd87df90adc3ef6cac2de69 (commit) via 15729dfafd16fb1fabca24c03f6f0670ee278aea (commit) from bb87d92f43f2f0599e1e573907daf33a6b50286f (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 ae69772d2a5dd8adad0c8de51b6c44db5f060e35 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Dec 8 11:42:44 2023 -0600 Update NEWS diff --git a/NEWS b/NEWS index 5409bba58..644b7fd1a 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,14 @@ Version 5.x -- future * Change FT1000MP Mark V model names to align with FT1000MP Version 4.6 + * rig_caps is no longer constant -- this may break some 3rd party relying on the "const" declaration. Here's an example of how to handle compatiblity. +#ifdef RIGCAPS_NOT_CONST +static int add_to_list(struct rig_caps* rc, void*) +#else +static int add_to_list(const struct rig_caps* rc, void*) +#endif + + * IC7610 now has IPP, DPP, and TX_INHIBIT functions set/get * Hamlib now starts a multicast server that sends out rig information. Does not receive commands yet. See README.multicast commit f6eed234941f4985b992b57a2a2fd3c84aa1e403 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Dec 8 08:24:29 2023 -0600 Ignore RIG_VFO_NONE in cache.c diff --git a/src/cache.c b/src/cache.c index 48452ac5d..75dea96a3 100644 --- a/src/cache.c +++ b/src/cache.c @@ -326,6 +326,10 @@ int rig_get_cache(RIG *rig, vfo_t vfo, freq_t *freq, int *cache_ms_freq, vfo = RIG_VFO_SUB_A; break; + case RIG_VFO_NONE: + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): ignoring VFO_OTHER\n", __func__, __LINE__); + break; + default: rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown vfo=%s, curr_vfo=%s\n", __func__, __LINE__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); commit cf973c9b0aad24e764c03b8df48cbfbca4040e78 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Dec 8 07:53:21 2023 -0600 Ignorie RIG_VFO_OTHER cache request diff --git a/src/cache.c b/src/cache.c index cf257a3d8..48452ac5d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -215,6 +215,10 @@ int rig_set_cache_freq(RIG *rig, vfo_t vfo, freq_t freq) elapsed_ms(&rig->state.cache.time_freqMem, flag); break; + case RIG_VFO_OTHER: + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): ignoring VFO_OTHER\n", __func__, __LINE__); + break; + default: rig_debug(RIG_DEBUG_WARN, "%s(%d): unknown vfo?, vfo=%s\n", __func__, __LINE__, rig_strvfo(vfo)); commit 3729f658ecd6b9697233a6f741eb2beebed6f5f6 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Dec 4 22:18:14 2023 -0600 Add 60M channel 3 for 5357MhZ for FT8 on channelized 60M rigs diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 6635c2a33..d4c38f860 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -893,6 +893,7 @@ int newcat_60m_exception(RIG *rig, freq_t freq, mode_t mode) { if ((long)freq == freq_60m[i]) { channel = i; } } + if ((long)freq == 5357000) channel = 3; // 60M channel for FT8 if (channel < 0) { diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 29a639eb7..6521bf966 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20231101" +#define NEWCAT_VER "20231204" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 768ca6105d3b0cf3fa18c5988f1c418c7594a1c6 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Dec 4 16:35:23 2023 -0600 Update comment in icom.c diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 7a4228750..1e34d671f 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -2212,7 +2212,7 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, buf[1] = datamode; // filter fixed to filter 1 due to IC7300 bug defaulting to filter 2 on mode changed -- yuck!! // buf[2] = filter // if Icom ever fixed this - // buf[2] = 1; // let's skip the filter selection + // buf[2] = 1; // let's skip the filter selection Tested on 7300 and 9700 retval = icom_transaction(rig, cmd2, subcmd2, buf, 2, ackbuf, &ack_len); commit f0e97a9e0e0c9d13479972996836df410beda484 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Dec 4 16:13:52 2023 -0600 Allow freq=0 for PowerSDR and perhaps others diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 3ef94b1f5..f4fb27349 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -143,7 +143,7 @@ struct rig_caps flrig_caps = RIG_MODEL(RIG_MODEL_FLRIG), .model_name = "FLRig", .mfg_name = "FLRig", - .version = "20231113.0", + .version = "20231204.0", .copyright = "LGPL", .status = RIG_STATUS_STABLE, .rig_type = RIG_TYPE_TRANSCEIVER, @@ -1209,6 +1209,9 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) *freq = atof(value); + +#if 0 // zero is actually valid for PowerSDR + if (*freq == 0) { rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__, @@ -1216,6 +1219,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) RETURNFUNC(-RIG_EPROTO); } else +#endif { rig_debug(RIG_DEBUG_TRACE, "%s: freq=%.0f\n", __func__, *freq); } commit 4e1aa90499126198ff10069e7b1a1456c0d55889 Merge: e3f1816e8 f4d40e0d7 Author: Michael Black <mdb...@ya...> Date: Mon Dec 4 14:42:48 2023 -0600 Merge pull request #1444 from GeoBaltz/fix6 Restore shared library ABI compatibility with previous hamlibs commit f4d40e0d79193a9b1925b9bac0ed7e9c9a5d2882 Author: George Baltz N3GB <Geo...@gm...> Date: Mon Dec 4 10:47:52 2023 -0500 Restore shared library ABI compatibility with previous hamlibs No need for post_ptt_delay to be in hamlib_port - move it to misc rig_state data. Update references to post_ptt_delay Fix a couple of typos Add code to actually set post_ptt_delay Fixes issue #1412 diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 9ad2e32db..f8a5a72ad 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2388,7 +2388,7 @@ typedef struct hamlib_port { int fd_sync_error_read; /*!< file descriptor for reading synchronous data error codes */ #endif short timeout_retry; /*!< number of retries to make in case of read timeout errors, some serial interfaces may require this, 0 to disable */ - int post_ptt_delay; /*!< delay after PTT to allow for relays and such */ +// DO NOT ADD ANYTHING HERE UNTIL 5.0!! } hamlib_port_t; @@ -2787,6 +2787,8 @@ struct rig_state { rig_comm_status_t comm_status; /*!< Detailed rig control status */ char device_id[HAMLIB_RIGNAMSIZ]; int dual_watch; /*!< Boolean DUAL_WATCH status */ + int post_ptt_delay; /*!< delay after PTT to allow for relays and such */ +// New rig_state items go before this line ============================================ }; /** @@ -2799,7 +2801,7 @@ struct rig_state { * It is NOT fine to touch this struct AT ALL!!! */ struct rig_state_deprecated { - /********* ENSURE YOU DO NOT EVERY MODIFY THIS STRUCTURE *********/ + /********* ENSURE YOU DO NOT EVER MODIFY THIS STRUCTURE *********/ /********* It will remain forever to provide DLL backwards compatiblity ******/ /* * overridable fields diff --git a/src/conf.c b/src/conf.c index 612fa46c4..6e5102de4 100644 --- a/src/conf.c +++ b/src/conf.c @@ -268,7 +268,15 @@ static int frontend_set_conf(RIG *rig, token_t token, const char *val) } rs->rigport.post_write_delay = val_i; - rs->rigport_deprecated.timeout = val_i; + rs->rigport_deprecated.post_write_delay = val_i; + break; + + case TOK_POST_PTT_DELAY: + if (1 != sscanf(val, "%ld", &val_i)) + { + return -RIG_EINVAL; + } + rs->post_ptt_delay = val_i; break; case TOK_TIMEOUT: @@ -841,7 +849,7 @@ static int frontend_get_conf2(RIG *rig, token_t token, char *val, int val_len) break; case TOK_POST_PTT_DELAY: - SNPRINTF(val, val_len, "%d", rs->rigport.post_ptt_delay); + SNPRINTF(val, val_len, "%d", rs->post_ptt_delay); break; case TOK_TIMEOUT: diff --git a/src/rig.c b/src/rig.c index 4fc6e6d32..059911bb7 100644 --- a/src/rig.c +++ b/src/rig.c @@ -3562,7 +3562,7 @@ int HAMLIB_API rig_set_ptt(RIG *rig, vfo_t vfo, ptt_t ptt) memcpy(&rig->state.pttport_deprecated, &rig->state.pttport, sizeof(rig->state.pttport_deprecated)); - if (rig->state.rigport.post_ptt_delay > 0) hl_usleep(rig->state.rigport.post_ptt_delay*1000); + if (rig->state.post_ptt_delay > 0) hl_usleep(rig->state.post_ptt_delay*1000); ELAPSED2; RETURNFUNC(retcode); commit e3f1816e8a422729b9ca4750d4690a2017b3c493 Merge: f255f6f8d 37fb4eafd Author: Michael Black <mdb...@ya...> Date: Fri Dec 1 10:41:37 2023 -0600 Merge pull request #1441 from GeoBaltz/fix5 Fix FTDX101MP RFPOWER the right way commit 37fb4eafdd33cdb88beda3d20e94a6ffcf12d781 Author: George Baltz N3GB <Geo...@gm...> Date: Fri Dec 1 11:18:13 2023 -0500 Fix FTDX101MP RFPOWER the right way. diff --git a/rigs/yaesu/ftdx101mp.c b/rigs/yaesu/ftdx101mp.c index 5289c09e9..d459051c0 100644 --- a/rigs/yaesu/ftdx101mp.c +++ b/rigs/yaesu/ftdx101mp.c @@ -104,7 +104,7 @@ struct rig_caps ftdx101mp_caps = [LVL_MICGAIN] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_SQL] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_MONITOR_GAIN] = { .min = { .f = 0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, - [LVL_RFPOWER] = { .min = { .f = .05 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, + [LVL_RFPOWER] = { .min = { .f = .025 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/200.0f } }, [LVL_USB_AF] = { .min = { .f = .0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, [LVL_USB_AF_INPUT] = { .min = { .f = .0 }, .max = { .f = 1.0 }, .step = { .f = 1.0f/100.0f } }, }, commit ed630b28d196bcf723a52199c71b9b9f45f75f08 Author: George Baltz N3GB <Geo...@gm...> Date: Fri Dec 1 11:11:21 2023 -0500 Revert "Fix FTDX101MP RFPOWER to allow 200W" Unnecessary code, breaks other levels. This reverts commit f255f6f8d8412c423a2fffb4864e11200f45491f. diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index e99a89558..6635c2a33 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4046,19 +4046,13 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } if ( is_ftdx3000dm ) /* No separate rig->caps for this rig :-( */ - { - fpf = (int)((val.f * 50.0f) + 0.5f); - } - else if (is_ftdx101mp) - { - fpf = (int)((val.f / level_info->step.f) + 0.5f ) * 2; - if (fpf > 200) fpf = 200; - } - - else - { - fpf = (int)((val.f / level_info->step.f) + 0.5f ); - } + { + fpf = (int)((val.f * 50.0f) + 0.5f); + } + else + { + fpf = (int)((val.f / level_info->step.f) + 0.5f ); + } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PC%03d%c", fpf, cat_term); break; @@ -5640,7 +5634,6 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RFPOWER: case RIG_LEVEL_MONITOR_GAIN: val->f = (float)atoi(retlvl) * level_info->step.f; - if (is_ftdx101mp) val->f /= 2; break; case RIG_LEVEL_BKINDL: diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 3b30adf16..29a639eb7 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20231130" +#define NEWCAT_VER "20231101" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit f255f6f8d8412c423a2fffb4864e11200f45491f Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 30 22:32:42 2023 -0600 Fix FTDX101MP RFPOWER to allow 200W https://github.com/Hamlib/Hamlib/issues/1396 diff --git a/rigs/yaesu/newcat.c b/rigs/yaesu/newcat.c index 6635c2a33..e99a89558 100644 --- a/rigs/yaesu/newcat.c +++ b/rigs/yaesu/newcat.c @@ -4046,13 +4046,19 @@ int newcat_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val) } if ( is_ftdx3000dm ) /* No separate rig->caps for this rig :-( */ - { - fpf = (int)((val.f * 50.0f) + 0.5f); - } - else - { - fpf = (int)((val.f / level_info->step.f) + 0.5f ); - } + { + fpf = (int)((val.f * 50.0f) + 0.5f); + } + else if (is_ftdx101mp) + { + fpf = (int)((val.f / level_info->step.f) + 0.5f ) * 2; + if (fpf > 200) fpf = 200; + } + + else + { + fpf = (int)((val.f / level_info->step.f) + 0.5f ); + } SNPRINTF(priv->cmd_str, sizeof(priv->cmd_str), "PC%03d%c", fpf, cat_term); break; @@ -5634,6 +5640,7 @@ int newcat_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val) case RIG_LEVEL_RFPOWER: case RIG_LEVEL_MONITOR_GAIN: val->f = (float)atoi(retlvl) * level_info->step.f; + if (is_ftdx101mp) val->f /= 2; break; case RIG_LEVEL_BKINDL: diff --git a/rigs/yaesu/newcat.h b/rigs/yaesu/newcat.h index 29a639eb7..3b30adf16 100644 --- a/rigs/yaesu/newcat.h +++ b/rigs/yaesu/newcat.h @@ -50,7 +50,7 @@ typedef char ncboolean; /* shared function version */ -#define NEWCAT_VER "20231101" +#define NEWCAT_VER "20231130" /* Hopefully large enough for future use, 128 chars plus '\0' */ #define NEWCAT_DATA_LEN 129 commit 88c3d9427b5683f1d183cf75bceaefd346500847 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 30 22:15:44 2023 -0600 Fix simftdx101 diff --git a/simulators/simftdx101.c b/simulators/simftdx101.c index 13adf7965..10e34e72f 100644 --- a/simulators/simftdx101.c +++ b/simulators/simftdx101.c @@ -332,13 +332,13 @@ int main(int argc, char *argv[]) } else if (strcmp(buf, "EX010415;") == 0) { - sprintf(buf,"EX010415%03d;", rport_gain); + sprintf(buf,"EX010415%03d;", rport_gain_psk); n = write(fd, buf, strlen(buf)); } else if (strncmp(buf, "EX010415", 8) == 0) { printf("Here#1"); - sscanf(buf,"EX010415%d", &rport_gain); + sscanf(buf,"EX010415%d", &rport_gain_psk); } else if (strlen(buf) > 0) commit cc49669b494e736726b496fbec8e85b67904caf7 Author: Mike Black W9MDB <mdb...@ya...> Date: Thu Nov 30 10:31:56 2023 -0600 Change Icom 0x26 behavior to leave filter# alone Rigs should remember filter based on last filter used for the mode diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index ce8f09006..7a4228750 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -950,6 +950,7 @@ static vfo_t icom_current_vfo(RIG *rig) } rig_debug(RIG_DEBUG_TRACE, "%s: currVFO=%s\n", __func__, rig_strvfo(currVFO)); + if (rig->state.current_vfo != RIG_VFO_NONE) currVFO = rig->state.current_vfo; return currVFO; } @@ -2211,9 +2212,9 @@ static int icom_set_mode_x26(RIG *rig, vfo_t vfo, rmode_t mode, int datamode, buf[1] = datamode; // filter fixed to filter 1 due to IC7300 bug defaulting to filter 2 on mode changed -- yuck!! // buf[2] = filter // if Icom ever fixed this - buf[2] = 1; + // buf[2] = 1; // let's skip the filter selection - retval = icom_transaction(rig, cmd2, subcmd2, buf, 3, ackbuf, &ack_len); + retval = icom_transaction(rig, cmd2, subcmd2, buf, 2, ackbuf, &ack_len); if (retval != RIG_OK) { diff --git a/rigs/icom/icom.h b/rigs/icom/icom.h index cc800675c..95bb0787a 100644 --- a/rigs/icom/icom.h +++ b/rigs/icom/icom.h @@ -35,7 +35,7 @@ #include <sys/time.h> #endif -#define BACKEND_VER "20231116" +#define BACKEND_VER "20231130" #define ICOM_IS_ID31 rig_is_model(rig, RIG_MODEL_ID31) #define ICOM_IS_ID51 rig_is_model(rig, RIG_MODEL_ID51) commit 8940d915220b97b5ed4f25bfc9e606c89df48ac8 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 17:04:56 2023 -0600 Fix CPU usage in simulators when client quits diff --git a/simulators/simelecraft.c b/simulators/simelecraft.c index 7a9e84c47..d047474c7 100644 --- a/simulators/simelecraft.c +++ b/simulators/simelecraft.c @@ -70,6 +70,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simft818.c b/simulators/simft818.c index a2bafe672..dda144558 100644 --- a/simulators/simft818.c +++ b/simulators/simft818.c @@ -63,6 +63,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simft991.c b/simulators/simft991.c index d2f5b1eb2..3ce19996d 100644 --- a/simulators/simft991.c +++ b/simulators/simft991.c @@ -63,6 +63,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simftdx101.c b/simulators/simftdx101.c index f12cbdaac..13adf7965 100644 --- a/simulators/simftdx101.c +++ b/simulators/simftdx101.c @@ -72,6 +72,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simftdx1200.c b/simulators/simftdx1200.c index 2aa814b70..a5c948a78 100644 --- a/simulators/simftdx1200.c +++ b/simulators/simftdx1200.c @@ -65,6 +65,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simftdx3000.c b/simulators/simftdx3000.c index 23a1ae999..361993dd9 100644 --- a/simulators/simftdx3000.c +++ b/simulators/simftdx3000.c @@ -64,6 +64,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simftdx5000.c b/simulators/simftdx5000.c index 25450001d..a2560b4f9 100644 --- a/simulators/simftdx5000.c +++ b/simulators/simftdx5000.c @@ -66,6 +66,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simic7300.c b/simulators/simic7300.c index 92f1bf481..c49d0ea68 100644 --- a/simulators/simic7300.c +++ b/simulators/simic7300.c @@ -72,7 +72,7 @@ again: while (read(fd, &c, 1) > 0) { buf[i++] = c; - //printf("i=%d, c=0x%02x\n",i,c); + printf("i=%d, c=0x%02x\n",i,c); if (c == 0xfd) { @@ -141,6 +141,7 @@ void frameParse(int fd, unsigned char *frame, int len) if (powerstat) { + dump_hex(frame,11); n = write(fd, frame, 11); if (n <= 0) { fprintf(stderr, "%s(%d) write error %s\n", __func__, __LINE__, strerror(errno)); } diff --git a/simulators/simkenwood.c b/simulators/simkenwood.c index fabff7b43..12d1d8ff4 100644 --- a/simulators/simkenwood.c +++ b/simulators/simkenwood.c @@ -60,6 +60,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simpowersdr.c b/simulators/simpowersdr.c index 3dedd8fb7..fac5f2456 100644 --- a/simulators/simpowersdr.c +++ b/simulators/simpowersdr.c @@ -61,6 +61,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simqrplabs.c b/simulators/simqrplabs.c index 39372c75c..c33612307 100644 --- a/simulators/simqrplabs.c +++ b/simulators/simqrplabs.c @@ -40,6 +40,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simrotorez.c b/simulators/simrotorez.c index 51101ae4d..fdd859ece 100644 --- a/simulators/simrotorez.c +++ b/simulators/simrotorez.c @@ -39,6 +39,7 @@ getmyline(int fd, char *buf) printf("\n"); } + if (strlen(buf)==0) hl_usleep(10*1000); return n; } diff --git a/simulators/simtmd700.c b/simulators/simtmd700.c index e82aa49e9..67501b28b 100644 --- a/simulators/simtmd700.c +++ b/simulators/simtmd700.c @@ -60,6 +60,7 @@ getmyline(int fd, char *buf) buf[i++] = c; } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simtrusdx.c b/simulators/simtrusdx.c index 5241e5a7d..211f20d6e 100644 --- a/simulators/simtrusdx.c +++ b/simulators/simtrusdx.c @@ -42,6 +42,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simts450.c b/simulators/simts450.c index 08ab439bb..853db5c85 100644 --- a/simulators/simts450.c +++ b/simulators/simts450.c @@ -42,6 +42,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simts590.c b/simulators/simts590.c index 699d6e266..08e444f11 100644 --- a/simulators/simts590.c +++ b/simulators/simts590.c @@ -48,6 +48,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simts950.c b/simulators/simts950.c index c0296fce6..c9b9ba2ca 100644 --- a/simulators/simts950.c +++ b/simulators/simts950.c @@ -40,6 +40,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simts990.c b/simulators/simts990.c index 24d265e9b..9433aaa8b 100644 --- a/simulators/simts990.c +++ b/simulators/simts990.c @@ -92,6 +92,7 @@ getmyline(int fd, char *buf) close(fd); fd = openPort(""); } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } diff --git a/simulators/simyaesu.c b/simulators/simyaesu.c index 550108f89..2759930ad 100644 --- a/simulators/simyaesu.c +++ b/simulators/simyaesu.c @@ -69,6 +69,7 @@ getmyline(int fd, char *buf) if (c == ';') { return strlen(buf); } } + if (strlen(buf)==0) hl_usleep(10*1000); return strlen(buf); } commit e40981e198163d0acf7d9ab98bc073ee823b97fc Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 16:02:19 2023 -0600 Add simtrusdx.c diff --git a/simulators/simtrusdx.c b/simulators/simtrusdx.c new file mode 100644 index 000000000..5241e5a7d --- /dev/null +++ b/simulators/simtrusdx.c @@ -0,0 +1,358 @@ +// can run this using rigctl/rigctld and socat pty devices +// gcc -o simyaesu simyaesu.c +#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 <fcntl.h> +#include <string.h> +#include <unistd.h> +#include <hamlib/rig.h> +#include "sim.h" + +#define BUFSIZE 256 + +int mysleep = 20; + +float freqA = 14074000; +float freqB = 14074500; +int filternum = 7; +int datamode = 0; +int vfo, vfo_tx, ptt, ptt_data, ptt_mic, ptt_tune; +int tomode = 0; +int keyspd = 25; + +int +getmyline(int fd, char *buf) +{ + char c; + int i = 0; + memset(buf, 0, BUFSIZE); + + while (read(fd, &c, 1) > 0) + { + buf[i++] = c; + + if (c == ';') { return strlen(buf); } + } + + return strlen(buf); +} + +#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 + + + +int main(int argc, char *argv[]) +{ + char buf[256]; + char *pbuf; + int fd = openPort(argv[1]); + int freqa = 14074000, freqb = 140735000; + int modeA = 1, modeB = 2; + + while (1) + { + buf[0] = 0; + + if (getmyline(fd, buf) > 0) { printf("Cmd:%s\n", buf); } + +// else { return 0; } + + if (strcmp(buf, "RM5;") == 0) + { + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + pbuf = "RM5100000;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + + else if (strcmp(buf, "AN0;") == 0) + { + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + pbuf = "AN030;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "IF;") == 0) + { + char ifbuf[256]; + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + pbuf = "IF000503130001000+0000000000030000000;"; + sprintf(ifbuf, "IF%011d0001000+0000000000030000000;", freqa); + //pbuf = "IF00010138698 +00000000002000000 ; + WRITE(fd, ifbuf, strlen(ifbuf)); + } + else if (strcmp(buf, "NB;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "NB0;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "RA;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "RA01;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "RG;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "RG055;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "MG;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "MG050;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "AG;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "AG100;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "FV;") == 0) + { + hl_usleep(mysleep * 1000); + pbuf = "FV1.2;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strncmp(buf, "IS;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "IS+0000;"); + WRITE(fd, buf, strlen(buf)); + printf("%s\n", buf); + } + else if (strncmp(buf, "IS", 2) == 0) + { + } + else if (strncmp(buf, "SM;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "SM0035;"); + WRITE(fd, buf, strlen(buf)); + printf("%s\n", buf); + } + else if (strncmp(buf, "PC;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "PC100;"); + WRITE(fd, buf, strlen(buf)); + printf("%s\n", buf); + } + else if (strcmp(buf, "FW;") == 0) + { + //usleep(mysleep * 1000); + pbuf = "FW240"; + WRITE(fd, pbuf, strlen(pbuf)); + hl_usleep(20 * 1000); + pbuf = "0;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strncmp(buf, "FW", 2) == 0) + { + } + else if (strcmp(buf, "ID;") == 0) + { + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + SNPRINTF(buf, sizeof(buf), "ID%03d;", 20); + WRITE(fd, buf, strlen(buf)); + } + + else if (strcmp(buf, "VS;") == 0) + { + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + pbuf = "VS0;"; + WRITE(fd, pbuf, strlen(pbuf)); + } + else if (strcmp(buf, "EX032;") == 0) + { + static int ant = 0; + ant = (ant + 1) % 3; + printf("%s\n", buf); + hl_usleep(mysleep * 1000); + SNPRINTF(buf, sizeof(buf), "EX032%1d;", ant); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "EX", 2) == 0) + { + } + else if (strcmp(buf, "FA;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FA%011d;", freqa); + WRITE(fd, buf, strlen(buf)); + } + else if (strcmp(buf, "FB;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FB%011d;", freqb); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FA", 2) == 0) + { + sscanf(buf, "FA%d", &freqa); + } + else if (strncmp(buf, "FB", 2) == 0) + { + sscanf(buf, "FB%d", &freqb); + } + else if (strncmp(buf, "AI", 2) == 0) + { + // nothing to do yet + } + + else if (strncmp(buf, "PS;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "PS1;"); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SA;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "SA0;"); + WRITE(fd, buf, strlen(buf)); + } + else if (buf[3] == ';' && strncmp(buf, "SF", 2) == 0) + { + SNPRINTF(buf, sizeof(buf), "SF%c%011.0f%c;", buf[2], + buf[2] == '0' ? freqA : freqB, + buf[2] == '0' ? modeA + '0' : modeB + '0'); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "SF", 2) == 0) + { + mode_t tmpmode = buf[14]; + + if (buf[2] == '0') { modeA = tmpmode - '0'; } + else { modeB = tmpmode - '0'; } + + printf("modeA=%c, modeB=%c\n", modeA, modeB); + + } + else if (strncmp(buf, "MD;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "MD%d;", + modeA); // not worried about modeB yet for simulator + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "MD", 2) == 0) + { + sscanf(buf, "MD%d", &modeA); // not worried about modeB yet for simulator + } + else if (strncmp(buf, "FL;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "FL%03d;", filternum); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FL", 2) == 0) + { + sscanf(buf, "FL%d", &filternum); + } + else if (strcmp(buf, "FR;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FR%d;", vfo); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FR", 2) == 0) + { + sscanf(buf, "FR%d", &vfo); + } + else if (strcmp(buf, "FT;") == 0) + { + SNPRINTF(buf, sizeof(buf), "FT%d;", vfo_tx); + WRITE(fd, buf, strlen(buf)); + } + else if (strncmp(buf, "FT", 2) == 0) + { + sscanf(buf, "FT%d", &vfo_tx); + } + else if (strncmp(buf, "DA;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "DA%d;", datamode); + WRITE(fd, buf, strlen(buf)); + printf("%s\n", buf); + } + else if (strncmp(buf, "DA", 2) == 0) + { + sscanf(buf, "DA%d", &datamode); + printf("%s\n", buf); + } + else if (strncmp(buf, "TO;", 3) == 0) + { + SNPRINTF(buf, sizeof(buf), "TO%d;", tomode); + } + else if (strncmp(buf, "BD;", 3) == 0) + { + } + else if (strncmp(buf, "BU;", 3) == 0) + { + } + else if (strncmp(buf, "TX", 2) == 0) + { + ptt = ptt_mic = ptt_data = ptt_tune = 0; + + switch (buf[2]) + { + case ';': ptt = 1; + + case '0': ptt_mic = 1; + + case '1': ptt_data = 1; + + case '2': ptt_tune = 1; + } + + } + + else if (strlen(buf) > 0) + { + fprintf(stderr, "Unknown command: %s\n", buf); + } + } + + return 0; +} commit a5ad218bba7879b7e57c4b65043b1ead08ad3180 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 15:58:15 2023 -0600 Add simft1000 to Makefile.am diff --git a/simulators/Makefile.am b/simulators/Makefile.am index f383f5ce7..9b0412412 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 simic275 +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 simtrusdx simft1000 simelecraft_SOURCES = simelecraft.c simkenwood_SOURCES = simkenwood.c commit 7973db52de5d149e7a416aabd19c093659e92629 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 14:53:39 2023 -0600 Remove debug from network.c diff --git a/src/network.c b/src/network.c index 048cb98e7..e2272d627 100644 --- a/src/network.c +++ b/src/network.c @@ -1196,9 +1196,7 @@ void *multicast_receiver(void *arg) if (select_result == 0) { // Select timed out - rig_debug(RIG_DEBUG_ERR, "%s: select timeout\n", __FILE__); -// char *p = NULL; -// *p = 0; +// rig_debug(RIG_DEBUG_ERR, "%s: select timeout\n", __FILE__); continue; } commit 001dd01a10397ec63f1ddcce05c9bddd843a9cbd Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 12:53:16 2023 -0600 Fix more compile errors for mingw diff --git a/src/network.c b/src/network.c index 5a79e0df6..048cb98e7 100644 --- a/src/network.c +++ b/src/network.c @@ -1175,21 +1175,19 @@ void *multicast_receiver(void *arg) struct sockaddr_in client_addr; socklen_t client_len = sizeof(client_addr); fd_set rfds, efds; - sigset_t sigfds; - struct timespec timeout; + struct timeval timeout; int select_result; ssize_t result; timeout.tv_sec = 1; - timeout.tv_nsec = 0; + timeout.tv_usec = 0; FD_ZERO(&rfds); FD_SET(socket_fd, &rfds); efds = rfds; - sigfillset(&sigfds); - select_result = pselect(socket_fd + 1, &rfds, NULL, &efds, &timeout, &sigfds); + select_result = select(socket_fd + 1, &rfds, NULL, &efds, &timeout); - if (rs->multicast_receiver_run == 0 && sigismember(&sigfds, SIGINT)) + if (rs->multicast_receiver_run == 0) { rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): pselect signal\n", __func__, __LINE__); break; commit 756fad1c723cd77d2aa0e212777b29b7f352ed46 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 12:47:38 2023 -0600 Fix compile error on mingw with network.c diff --git a/src/network.c b/src/network.c index 66a7a4ec9..5a79e0df6 100644 --- a/src/network.c +++ b/src/network.c @@ -42,7 +42,6 @@ #include <errno.h> /* Error number definitions */ #include <sys/types.h> #include <signal.h> -#include <execinfo.h> #include <pthread.h> #ifdef HAVE_NETINET_IN_H commit 07f57cfc18349100280d26c3466d6b284512b561 Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 12:45:11 2023 -0600 Fix error on ctrl-c of rigctld diff --git a/src/network.c b/src/network.c index 4f155e03e..66a7a4ec9 100644 --- a/src/network.c +++ b/src/network.c @@ -42,6 +42,7 @@ #include <errno.h> /* Error number definitions */ #include <sys/types.h> #include <signal.h> +#include <execinfo.h> #include <pthread.h> #ifdef HAVE_NETINET_IN_H @@ -686,7 +687,10 @@ static int multicast_publisher_read_data(const multicast_publisher_args if (FD_ISSET(fd, &efds)) { rig_debug(RIG_DEBUG_ERR, - "%s(): fd error when reading multicast publisher data\n", __func__); + "%s(): fd error when reading multicast publisher data: %s\n", + __func__, + strerror(errno)); + return -RIG_EIO; } @@ -1087,7 +1091,6 @@ int is_wireless() #endif #endif - void *multicast_receiver(void *arg) { char data[4096]; @@ -1173,38 +1176,50 @@ void *multicast_receiver(void *arg) struct sockaddr_in client_addr; socklen_t client_len = sizeof(client_addr); fd_set rfds, efds; - struct timeval timeout; + sigset_t sigfds; + struct timespec timeout; int select_result; ssize_t result; timeout.tv_sec = 1; - timeout.tv_usec = 0; - + timeout.tv_nsec = 0; FD_ZERO(&rfds); FD_SET(socket_fd, &rfds); efds = rfds; + sigfillset(&sigfds); + + select_result = pselect(socket_fd + 1, &rfds, NULL, &efds, &timeout, &sigfds); + + if (rs->multicast_receiver_run == 0 && sigismember(&sigfds, SIGINT)) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): pselect signal\n", __func__, __LINE__); + break; + } - select_result = select(socket_fd + 1, &rfds, NULL, &efds, &timeout); if (select_result == 0) { // Select timed out + rig_debug(RIG_DEBUG_ERR, "%s: select timeout\n", __FILE__); +// char *p = NULL; +// *p = 0; continue; } - if (select_result < 0) + if (select_result <= 0) { rig_debug(RIG_DEBUG_ERR, - "%s(): select() failed when reading UDP multicast socket data: %s\n", + "%s((%d): select() failed when reading UDP multicast socket data: %s\n", __func__, + __LINE__, strerror(errno)); break; } - if (FD_ISSET(socket_fd, &efds)) + if ((result = FD_ISSET(socket_fd, &efds))) { rig_debug(RIG_DEBUG_ERR, - "%s(): fd error when reading UDP multicast socket data\n", __func__); + "%s(%d): fd error when reading UDP multicast socket data: (%d)=%s\n", __func__, __LINE__, (int)result, strerror(errno)); break; } @@ -1230,6 +1245,7 @@ void *multicast_receiver(void *arg) // TODO: if a new snapshot needs to be sent, call network_publish_rig_poll_data() and the publisher routine will send out a snapshot // TODO: new logic in publisher needs to be written for other types of responses } + rs->multicast_receiver_run = 0; rig_debug(RIG_DEBUG_VERBOSE, "%s(%d): Stopping multicast receiver\n", __FILE__, __LINE__); commit ed941939359da9f8734dbdf4a21a9b01622a1a6e Author: Mike Black W9MDB <mdb...@ya...> Date: Wed Nov 29 11:10:43 2023 -0600 Add #define RIGCAPS_NOT_CONST Allows clients to test for which declarations to use https://github.com/Hamlib/Hamlib/issues/1436 diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 83ef311e6..9ad2e32db 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -24,6 +24,10 @@ #ifndef _RIG_H #define _RIG_H 1 +// as of 2023-11-23 rig_caps is no longer constant +// this #define allows clients to test which declaration to use for backwards compatibility +#define RIGCAPS_NOT_CONST 1 + #define BUILTINFUNC 0 // Our shared secret password commit a910b16e8f961506d2408ff62632f8afe797f323 Merge: 09ab2819b 4f019e622 Author: Mike Black W9MDB <mdb...@ya...> Date: Tue Nov 28 07:06:47 2023 -0600 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit 4f019e622e3c3957e94d5f42de8be93cdc55c6f4 Merge: 46c16b22a c0457a0d7 Author: Michael Black <mdb...@ya...> Date: Tue Nov 28 07:06:33 2023 -0600 Merge pull request #1434 from pdaderko/master Fix for iOptron rotator (tested with AZ Mount Pro), added improvements commit c0457a0d7b8f894baf4f8f2e446f36922cb9c1a1 Author: pdaderko <pda...@ya...> Date: Tue Nov 28 05:07:00 2023 -0500 Fixed functionality (AZ Mount Pro), added improvements Updated code to work with current AZ Mount Pro firmware. Current firmware uses serial at 115200. Original code looked for # delimiter on responses, but not all responses end in #. This caused the software to timeout, which caused slow response time, and in some cases returned a failure (including :MountInfo# used at open). All responses have fixed length replies, so code updated to look at fixed length data rather than delimiter. Added workarounds for a couple firmware bugs. Minor cleanup. diff --git a/rotators/ioptron/rot_ioptron.c b/rotators/ioptron/rot_ioptron.c index ef4abbf15..3336914ce 100644 --- a/rotators/ioptron/rot_ioptron.c +++ b/rotators/ioptron/rot_ioptron.c @@ -38,10 +38,9 @@ * ioptron_transaction * * cmdstr - Command to be sent to the rig. - * data - Buffer for reply string. Can be NULL, indicating that no reply is - * is needed, but answer will still be read. - * data_len - in: Size of buffer. It is the caller's responsibily to provide - * a large enough buffer for all possible replies for a command. + * data - Buffer for reply string. + * resp_len - in: Expected length of response. It is the caller's responsibily to + * provide a buffer at least 1 byte larger than this for null terminator. * * COMMANDS note: as of 12/2018 a mixture of V2 and V3 * | TTTTTTTT(T) .01 arc seconds @@ -62,136 +61,103 @@ */ static int -ioptron_transaction(ROT *rot, const char *cmdstr, - char *data, size_t data_len) +ioptron_transaction(ROT *rot, const char *cmdstr, char *data, size_t resp_len) { struct rot_state *rs; - int retval; - int retry_read = 0; - char replybuf[BUFSZ]; + int retval = 0; + int retry_read; rs = &rot->state; -transaction_write: + for (retry_read = 0; retry_read <= rot->state.rotport.retry; retry_read++) + { + rig_flush(&rs->rotport); - rig_flush(&rs->rotport); + if (cmdstr) + { + retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr)); - if (cmdstr) - { - retval = write_block(&rs->rotport, (unsigned char *) cmdstr, strlen(cmdstr)); + if (retval != RIG_OK) + { + return retval; + } + } - if (retval != RIG_OK) + /** the answer */ + memset(data, 0, resp_len+1); + retval = read_block(&rs->rotport, (unsigned char *) data, resp_len); + /** if expected number of bytes received, return OK status */ + if (retval == resp_len) { - goto transaction_quit; + return RIG_OK; } } - /** Always read the reply to know whether the cmd went OK */ - if (!data) - { - data = replybuf; - } + /** if got here, retry loop failed */ + rig_debug(RIG_DEBUG_ERR, "%s: unexpected response, len %d: '%s'\n", __func__, retval, data); - if (!data_len) - { - data_len = BUFSZ; - } + return -RIG_EPROTO; +} + +/** get mount type code, initializes mount */ +static const char * +ioptron_get_info(ROT *rot) +{ + static char info[32]; + char str[6]; + int retval; - /** the answer */ - memset(data, 0, data_len); - retval = read_string(&rs->rotport, (unsigned char *) data, data_len, ACK, - strlen(ACK), 0, 1); + rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); - if (retval < 0) - { - if (retry_read++ < rot->state.rotport.retry) - { - goto transaction_write; - } + retval = ioptron_transaction(rot, ":MountInfo#", str, 4); - goto transaction_quit; - } + rig_debug(RIG_DEBUG_TRACE, "retval, RIG_OK str %d %d %str\n", retval, RIG_OK, + str); - /** check for acknowledge */ - if (retval < 1) - { - rig_debug(RIG_DEBUG_ERR, "%s: unexpected response, len %d: '%s'\n", __func__, - retval, data); - return -RIG_EPROTO; - } + SNPRINTF(info, sizeof(info), "MountInfo %s", str); - retval = RIG_OK; -transaction_quit: - return retval; + return info; } /** * Opens the Port and sets all needed parameters for operation * as of 12/2018 initiates mount with V3 :MountInfo# */ -static int ioptron_open(ROT *rot) -{ - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - - return ioptron_transaction(rot, ":Mountinfo#", NULL, 0); -} - -/** sets mount position, requires 4 steps - * set azmiuth - * set altitude - * goto set - * stop tracking - mount starts tracking after goto - */ static int -ioptron_set_position(ROT *rot, azimuth_t az, elevation_t el) +ioptron_open(ROT *rot) { - char cmdstr[32]; - char retbuf[10]; + const char *info; int retval; - float faz, fel; - - rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); - - /* units .01 arc sec */ - faz = az * 360000; - fel = el * 360000; - /* set azmiuth, returns '1" if OK */ - SNPRINTF(cmdstr, sizeof(cmdstr), ":Sz%09.0f#", faz); - retval = ioptron_transaction(rot, cmdstr, retbuf, sizeof(retbuf)); - - if (retval != RIG_OK || retbuf[0] != ACK1) - { - return -RIG_EPROTO; - } - - /* set altitude, returns '1" if OK */ - SNPRINTF(cmdstr, sizeof(cmdstr), ":Sa+%08.0f#", fel); - retval = ioptron_transaction(rot, cmdstr, retbuf, sizeof(retbuf)); + char retbuf[10]; + + rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); - if (retval != RIG_OK || retbuf[0] != ACK1) + info = ioptron_get_info(rot); + /* ioptron_get_info returns "MountInfo xxxx", check model number from string */ + /* string of 4 numeric digits is likely model number */ + if ((strlen(&info[10]) != 4) || (strspn(&info[10], "1234567890") != 4)) { - return -RIG_EPROTO; + return -RIG_ETIMEOUT; } - /* move to set target, V2 command, returns '1" if OK */ - SNPRINTF(cmdstr, sizeof(cmdstr), ":MS#"); // - retval = ioptron_transaction(rot, cmdstr, retbuf, sizeof(retbuf)); + /** stops tracking, returns "1" if OK */ + retval = ioptron_transaction(rot, ":ST0#", retbuf, 1); if (retval != RIG_OK || retbuf[0] != ACK1) { return -RIG_EPROTO; } - /* stop tracking, V2 command, returns '1" if OK */ - SNPRINTF(cmdstr, sizeof(cmdstr), ":ST0#"); - retval = ioptron_transaction(rot, cmdstr, retbuf, sizeof(retbuf)); + /** set alt limit to -1 since firmware bug sometimes doesn't allow alt of 0 when limit is 0 */ + /** returns "1" if OK */ + retval = ioptron_transaction(rot, ":SAL-01#", retbuf, 1); if (retval != RIG_OK || retbuf[0] != ACK1) { return -RIG_EPROTO; } - - return retval; + + return RIG_OK; } /** gets current position */ @@ -205,9 +171,9 @@ ioptron_get_position(ROT *rot, azimuth_t *az, elevation_t *el) rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); /** Get Az-Alt */ - retval = ioptron_transaction(rot, ":GAC#", posbuf, sizeof(posbuf)); + retval = ioptron_transaction(rot, ":GAC#", posbuf, 19); - if (retval != RIG_OK || strlen(posbuf) < 18) + if (retval != RIG_OK || strlen(posbuf) < 19) { return retval < 0 ? retval : -RIG_EPROTO; } @@ -218,6 +184,8 @@ ioptron_get_position(ROT *rot, azimuth_t *az, elevation_t *el) } /** convert from .01 arc sec to degrees */ + /** note that firmware only reports alt between -90 and +90 */ + /** e.g. both 80 and 100 degrees are read as 80 degrees */ *el = ((elevation_t)w / 360000.); if (sscanf(posbuf + 9, "%9f", &w) != 1) @@ -243,7 +211,7 @@ ioptron_stop(ROT *rot) rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); /** stop slew, returns "1" if OK */ - retval = ioptron_transaction(rot, ":Q#", retbuf, 10); + retval = ioptron_transaction(rot, ":Q#", retbuf, 1); if (retval != RIG_OK || retbuf[0] != ACK1) { @@ -251,38 +219,120 @@ ioptron_stop(ROT *rot) } /** stops tracking returns "1" if OK */ - retval = ioptron_transaction(rot, ":ST0#", retbuf, 10); + retval = ioptron_transaction(rot, ":ST0#", retbuf, 1); if (retval != RIG_OK || retbuf[0] != ACK1) { return -RIG_EPROTO; } - return retval; + return RIG_OK; } -/** get mount type code, initializes mount */ -static const char * -ioptron_get_info(ROT *rot) +/** sets mount position, requires 4 steps + * set azmiuth + * set altitude + * goto set + * stop tracking - mount starts tracking after goto + */ +static int +ioptron_set_position(ROT *rot, azimuth_t az, elevation_t el) { - static char info[32]; - char str[6]; + char cmdstr[32]; + char retbuf[10]; int retval; + double faz, fel; + azimuth_t curr_az; + elevation_t curr_el; - rig_debug(RIG_DEBUG_TRACE, "%s called\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s called: %f %f\n", __func__, az, el); + + /* units .01 arc sec */ + faz = az * 360000; + fel = el * 360000; - retval = ioptron_transaction(rot, ":MountInfo#", str, sizeof(str)); + /** Firmware bug: (at least for AZ Mount Pro as of FW 20200305) + * azimuth has problems going to 0 + * going to 0 from <=180 causes it to overshoot 0 and never stop + * going to 0 from >180 causes it to make a hard stop at 0 and a following + * command to <= 180 will make it rotate forever until manually stopped, + * and require resetting the mount for azimuth to work correctly again + * similar behavior is seen the other direction (>180 to 360 goes past 360, + * <=180 to 360 makes a hard stop with the possibility of loss of + * azimuth control) + * Workaround: + * get current position, if 0 is requested, go to 0.01 arcseconds away from + * 0 from the same direction (e.g. go to 0.01 arcseconds if currently <= 180, + * 129599999 arcseconds if currently > 180) + */ + if (faz == 0) + { + /* make sure stopped */ + retval = ioptron_stop(rot); + if (retval != RIG_OK) + { + return -RIG_EPROTO; + } + + /* get current position */ + retval = ioptron_get_position(rot, &curr_az, &curr_el); + if (retval != RIG_OK) + { + return -RIG_EPROTO; + } - rig_debug(RIG_DEBUG_TRACE, "retval, RIG_OK str %d %d %str\n", retval, RIG_OK, - str); + if (curr_az <= 180) + { + faz = 1; + } + else + { + faz = 129599999; /* needs double precision float */ + } + } + + /* set azmiuth, returns '1" if OK */ + SNPRINTF(cmdstr, sizeof(cmdstr), ":Sz%09.0f#", faz); + retval = ioptron_transaction(rot, cmdstr, retbuf, 1); - SNPRINTF(info, sizeof(info), "MountInfo %s", str); + if (retval != RIG_OK || retbuf[0] != ACK1) + { + return -RIG_EPROTO; + } - return info; + /* set altitude, returns '1" if OK */ + SNPRINTF(cmdstr, sizeof(cmdstr), ":Sa+%08.0f#", fel); + retval = ioptron_transaction(rot, cmdstr, retbuf, 1); + + if (retval != RIG_OK || retbuf[0] != ACK1) + { + return -RIG_EPROTO; + } + + /* move to set target, V2 command, returns '1" if OK */ + SNPRINTF(cmdstr, sizeof(cmdstr), ":MS#"); // + retval = ioptron_transaction(rot, cmdstr, retbuf, 1); + + if (retval != RIG_OK || retbuf[0] != ACK1) + { + return -RIG_EPROTO; + } + + /* stop tracking, V2 command, returns '1" if OK */ + SNPRINTF(cmdstr, sizeof(cmdstr), ":ST0#"); + retval = ioptron_transaction(rot, cmdstr, retbuf, 1); + + if (retval != RIG_OK || retbuf[0] != ACK1) + { + return -RIG_EPROTO; + } + + return retval; } + /** ************************************************************************* * * ioptron mount capabilities. @@ -304,7 +354,7 @@ const struct rot_caps ioptron_rot_caps = .rot_type = ROT_TYPE_AZEL, .port_type = RIG_PORT_SERIAL, .serial_rate_min = 9600, - .serial_rate_max = 9600, + .serial_rate_max = 115200, .serial_data_bits = 8, .serial_stop_bits = 1, .serial_parity = RIG_PARITY_NONE, commit 09ab2819b3b66936e7a7d73d832660fc59354643 Author: Mike Black W9MDB <mdb...@ya...> Date: Mon Nov 27 11:39:09 2023 -0600 Add better error info to serial error diff --git a/src/serial.c b/src/serial.c index 7c46b0b0e..2d14b5852 100644 --- a/src/serial.c +++ b/src/serial.c @@ -227,7 +227,7 @@ int HAMLIB_API serial_open(hamlib_port_t *rp) if (fd == -1) // some serial ports fail to open 1st time for some unknown reason { - rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d\n", __func__, __LINE__, i); + rig_debug(RIG_DEBUG_WARN, "%s(%d): open failed#%d %s\n", __func__, __LINE__, i, strerror(errno)); hl_usleep(500 * 1000); fd = OPEN(rp->pathname, O_RDWR | O_NOCTTY | O_NDELAY); } commit 46c16b22a0bbce4acd5d25a6bcdcac69708a588e Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Nov 26 12:41:26 2023 -0600 Fix compile warning diff --git a/src/network.c b/src/network.c index 0ccf60990..4f155e03e 100644 --- a/src/network.c +++ b/src/network.c @@ -1046,7 +1046,7 @@ 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); + strncpy(pwrq.ifr_name, ifname, IFNAMSIZ-1); if (ioctl(sock, SIOCGIWNAME, &pwrq) != -1) { commit 698cb10ff3a5921454924f0f5e05534ba21b55bd Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Nov 25 22:33:07 2023 -0600 Re-enable extra get_freq so see if it fixes timeout problem on IC-7100 diff --git a/src/rig.c b/src/rig.c index 9dec89c4e..4fc6e6d32 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2389,7 +2389,7 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) RETURNFUNC(-RIG_ENAVAIL); } -#if 0 // this seems redundant as we ask for freq a few lines below +#if 1 // this seems redundant as we ask for freq a few lines below HAMLIB_TRACE; retcode = caps->get_freq(rig, vfo, freq); commit 9c01045356a29622857ca7338329903317123a83 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Nov 25 15:05:42 2023 -0600 Fix HOMEPATH for Windows hamlib_settings file diff --git a/src/settings.c b/src/settings.c index e51803741..28940ba17 100644 --- a/src/settings.c +++ b/src/settings.c @@ -1030,7 +1030,12 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen) const char *xdgpath = getenv("XDG_CONFIG_HOME"); char *home = getenv("HOME"); - if (home == NULL) home = "?HOME"; + if (home == NULL) { + home = getenv("HOMEPATH"); + } + if (home == NULL) { + home = "?HOME"; + } snprintf(path, pathlen, "%s/.config", home); if (xdgpath) commit 30f47cdeba342f80905a1c73a9b9afc3fa59dbc3 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Nov 25 09:29:01 2023 -0600 Update Icom simulators for better behavior at rigctl shutdown diff --git a/simulators/simic275.c b/simulators/simic275.c index 388ddd2f7..6f4b3ccc0 100644 --- a/simulators/simic275.c +++ b/simulators/simic275.c @@ -103,7 +103,7 @@ again: } } - printf("Error??? c=x%02x\n", c); + printf("Error %s\n", strerror(errno)); return 0; } @@ -113,6 +113,12 @@ void frameParse(int fd, unsigned char *frame, int len) double freq; int n = 0; + if (len == 0) + { + printf("%s: len==0\n", __func__); + return; + } + dumphex(frame, len); if (frame[0] != 0xfe && frame[1] != 0xfe) diff --git a/simulators/simic7000.c b/simulators/simic7000.c index 388ddd2f7..6f4b3ccc0 100644 --- a/simulators/simic7000.c +++ b/simulators/simic7000.c @@ -103,7 +103,7 @@ again: } } - printf("Error??? c=x%02x\n", c); + printf("Error %s\n", strerror(errno)); return 0; } @@ -113,6 +113,12 @@ void frameParse(int fd, unsigned char *frame, int len) double freq; int n = 0; + if (len == 0) + { + printf("%s: len==0\n", __func__); + return; + } + dumphex(frame, len); if (frame[0] != 0xfe && frame[1] != 0xfe) dif... [truncated message content] |