[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 7e7e2cb1acb27cdbe67b8
Library to control radio transceivers and receivers
Brought to you by:
n0nb
From: Michael B. <mdb...@us...> - 2021-04-18 16:42:43
|
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 7e7e2cb1acb27cdbe67b8f258d10144f0b99e754 (commit) via aefe8c44b7c5ce11b7e3772d0209d36e26c926fb (commit) via cfa42f23651206785ba47f511e87bdc8065d5bfc (commit) via 1e26a10365e5125d540aa4c034026dd83d3b0a66 (commit) via b74bf05541ee6931c7690d19a04f8a821bfa1b73 (commit) via 44a4b52bb961f5f80e3fdcee5d3877d665a85731 (commit) via 5d367f0920ef8c9a994564ec00038560f26afe86 (commit) via 0a5d9d9768b85fcae784bc0708aeb01bd6794205 (commit) from 0f692f514de5a1ec31220f3586aaf2b3d5cdcfba (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 7e7e2cb1acb27cdbe67b8f258d10144f0b99e754 Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Apr 18 11:42:08 2021 -0500 Add hamlib version so simicom.c diff --git a/tests/simicom.c b/tests/simicom.c index 3616df55..4662bb41 100644 --- a/tests/simicom.c +++ b/tests/simicom.c @@ -206,6 +206,7 @@ int main(int argc, char **argv) unsigned char buf[256]; int fd = openPort(argv[1]); + printf("%s: %s\n", argv[0], rig_version()); #if defined(WIN32) || defined(_WIN32) if (argc != 2) { commit aefe8c44b7c5ce11b7e3772d0209d36e26c926fb Author: Mike Black W9MDB <mdb...@ya...> Date: Sun Apr 18 11:35:35 2021 -0500 In rig.c if rig does not set get_split_vfo then return cached values https://github.com/Hamlib/Hamlib/issues/654 https://github.com/Hamlib/Hamlib/issues/665 diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index ef5e4519..23a9c451 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -1588,6 +1588,8 @@ int icom_set_dsp_flt(RIG *rig, rmode_t mode, pbwidth_t width) unsigned char fw_sub_cmd = RIG_MODEL_IC7200 == rig->caps->rig_model ? 0x02 : S_MEM_FILT_WDTH; + ENTERFUNC; + if (RIG_PASSBAND_NOCHANGE == width) { RETURNFUNC(RIG_OK); @@ -1686,7 +1688,7 @@ int icom_set_mode_with_data(RIG *rig, vfo_t vfo, rmode_t mode, || rig->caps->rig_model == RIG_MODEL_IC9700 || rig->caps->rig_model == RIG_MODEL_IC705; - rig_debug(RIG_DEBUG_VERBOSE, "%s called\n", __func__); + ENTERFUNC; switch (mode) { diff --git a/src/rig.c b/src/rig.c index d683d1c6..f7ad1a3c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -2490,6 +2490,10 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) ENTERFUNC; rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s\n", __func__, rig_strvfo(vfo)); + if (vfo == RIG_VFO_B || vfo == RIG_VFO_SUB) + { + rig_debug(RIG_DEBUG_VERBOSE, "%s ********************** called vfo=%s\n", __func__, rig_strvfo(vfo)); + } if (CHECK_RIG_ARG(rig)) { @@ -4343,6 +4347,7 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig, if (!split || !tx_vfo) { + rig_debug(RIG_DEBUG_ERR, "%s: split or tx_vfo is null, split=%p, tx_vfo=%p\n", __func__, split, tx_vfo); RETURNFUNC(-RIG_EINVAL); } @@ -4350,7 +4355,11 @@ int HAMLIB_API rig_get_split_vfo(RIG *rig, if (caps->get_split_vfo == NULL) { - RETURNFUNC(-RIG_ENAVAIL); + // if we can't get the vfo we will return whatever we have cached + *split = rig->state.cache.split; + *tx_vfo = rig->state.cache.split_vfo; + rig_debug(RIG_DEBUG_VERBOSE, "%s: no get_split_vfo so returning split=%d, tx_vfo=%s\n", __func__, *split, rig_strvfo(*tx_vfo)); + RETURNFUNC(RIG_OK); } cache_ms = elapsed_ms(&rig->state.cache.time_split, HAMLIB_ELAPSED_GET); commit cfa42f23651206785ba47f511e87bdc8065d5bfc Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 17 22:48:14 2021 -0500 Beginning of Icom simulator -- does not work on Windows yet diff --git a/tests/simicom.c b/tests/simicom.c new file mode 100644 index 00000000..3616df55 --- /dev/null +++ b/tests/simicom.c @@ -0,0 +1,232 @@ +// simicom will show the pts port to use for rigctl on Unix +// using virtual serial ports on Windows is to be developed yet +// gcc -g -Wall -o simicom simicom.c -lhamlib +// On mingw in the hamlib src directory +// gcc -static -I../include -g -Wall -o simicom simicom.c -L../../build/src/.libs -lhamlib -lwsock32 -lws2_32 +#define _XOPEN_SOURCE 600 +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/time.h> +#include <hamlib/rig.h> +#include "../src/misc.h" + +#define BUFSIZE 256 + +int civ_731_mode = 0; +vfo_t vfo_curr = RIG_VFO_A; +int split = 0; + +float freqA = 14074000; +float freqB = 14074500; +mode_t modeA = RIG_MODE_CW; +mode_t modeB = RIG_MODE_CW; +pbwidth_t widthA = 200; +pbwidth_t widthB = 300; + +void dumphex(unsigned char *buf, int n) +{ + for (int i = 0; i < n; ++i) { printf("%02x ", buf[i]); } + + printf("\n"); +} + +int +frameGet(int fd, unsigned char *buf) +{ + int i = 0; + memset(buf, 0, BUFSIZE); + unsigned char c; + + while (read(fd, &c, 1) > 0) + { + buf[i++] = c; + //printf("i=%d, c=0x%02x\n",i,c); + + if (c == 0xfd) + { + dumphex(buf, i); + return i; + } + } + + printf("Error???\n"); + + return 0; +} + +void frameParse(int fd, unsigned char *frame, int len) +{ + double freq; + + dumphex(frame, len); + + if (frame[0] != 0xfe && frame[1] != 0xfe) + { + printf("expected fe fe, got "); + dumphex(frame, len); + return; + } + + switch (frame[4]) + { + case 0x03: + + //from_bcd(frameackbuf[2], (civ_731_mode ? 4 : 5) * 2); + if (vfo_curr == RIG_VFO_A || vfo_curr == RIG_VFO_MAIN) + { + printf("get_freqA\n"); + to_bcd(&frame[5], (long long)freqA, (civ_731_mode ? 4 : 5) * 2); + } + else + { + printf("get_freqB\n"); + to_bcd(&frame[5], (long long)freqB, (civ_731_mode ? 4 : 5) * 2); + } + + frame[10] = 0xfd; + write(fd, frame, 11); + break; + + case 0x05: + freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); + printf("set_freq to %.0f\n", freq); + + if (vfo_curr == RIG_VFO_A || vfo_curr == RIG_VFO_MAIN) { freqA = freq; } + else { freqB = freq; } +// case 0x06: + + + case 0x07: + + if (frame[5] == 0xd0) { vfo_curr = RIG_VFO_MAIN; } + else if (frame[5] == 0xd1) { vfo_curr = RIG_VFO_SUB; } + + printf("set_vfo to %s\n", rig_strvfo(vfo_curr)); + + frame[4] = 0xfb; + frame[5] = 0xfd; + write(fd, frame, 6); + break; + + case 0x0f: + if (frame[5] == 0) { split = 0; } + else { split = 1; } + + printf("set split %d\n", 1); + frame[4] = 0xfb; + frame[5] = 0xfd; + write(fd, frame, 6); + break; + + case 0x25: + if (frame[6] == 0xfd) + { + if (frame[5] == 0x00) + { + to_bcd(&frame[6], (long long)freqA, (civ_731_mode ? 4 : 5) * 2); + printf("get_freqA=%.0f\n", freqA); + } + else + { + to_bcd(&frame[6], (long long)freqB, (civ_731_mode ? 4 : 5) * 2); + printf("get_freqB=%.0f\n", freqB); + } + + frame[11] = 0xfd; + write(fd, frame, 12); + } + else + { + freq = from_bcd(&frame[5], (civ_731_mode ? 4 : 5) * 2); + printf("set_freq to %.0f\n", freq); + + if (frame[5] == 0x00) { freqA = freq; } + else { freqB = freq; } + + frame[4] = 0xfb; + frame[5] = 0xfd; + } + + break; + + default: printf("cmd 0x%02x unknown\n", frame[4]); + } + + // don't care about the rig type yet + +} + +#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 + +void rigStatus() +{ + printf("VFOA: mode=%s width=%ld freq=%.0f\n", rig_strrmode(modeA), widthA, freqA); + printf("VFOB: mode=%s width=%ld freq=%.0f\n", rig_strrmode(modeB), widthB, freqB); +} + +int main(int argc, char **argv) +{ + unsigned char buf[256]; + int fd = openPort(argv[1]); + +#if defined(WIN32) || defined(_WIN32) + if (argc != 2) + { + printf("Missing comport argument\n"); + printf("%s [comport]\n", argv[0]); + exit(1); + } +#endif + while (1) + { + int len = frameGet(fd, buf); + + if (len <= 0) + { + close(fd); + fd = openPort(argv[1]); + } + + frameParse(fd, buf, len); + rigStatus(); + } + + return 0; +} commit 1e26a10365e5125d540aa4c034026dd83d3b0a66 Merge: b74bf055 44a4b52b Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 17 22:47:36 2021 -0500 Merge branch 'master' of https://github.com/Hamlib/Hamlib commit b74bf05541ee6931c7690d19a04f8a821bfa1b73 Author: Mike Black W9MDB <mdb...@ya...> Date: Sat Apr 17 22:47:14 2021 -0500 astyle misc.c and add CRC function for future use diff --git a/src/misc.c b/src/misc.c index d1353041..792b0a84 100644 --- a/src/misc.c +++ b/src/misc.c @@ -380,7 +380,7 @@ int HAMLIB_API sprintf_freq(char *str, int nlen, freq_t freq) decplaces = 1; } - return sprintf(str, "%.*f %s", decplaces , f, hz); + return sprintf(str, "%.*f %s", decplaces, f, hz); } @@ -1638,7 +1638,8 @@ int HAMLIB_API rig_set_cache_timeout_ms(RIG *rig, hamlib_cache_t selection, // So we map these to Main/Sub as required vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo) { - rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, vfo_curr=%s\n", __func__, rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); + rig_debug(RIG_DEBUG_TRACE, "%s: vfo=%s, vfo_curr=%s\n", __func__, + rig_strvfo(vfo), rig_strvfo(rig->state.current_vfo)); if (vfo == RIG_VFO_CURR) { @@ -1672,7 +1673,8 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo) } int satmode = rig->state.cache.satmode; - if (vfo == RIG_VFO_TX) vfo = RIG_VFO_A; + + if (vfo == RIG_VFO_TX) { vfo = RIG_VFO_A; } if (split) { vfo = RIG_VFO_B; } @@ -1690,7 +1692,10 @@ vfo_t HAMLIB_API vfo_fixup(RIG *rig, vfo_t vfo) } else if (vfo == RIG_VFO_B) - rig_debug(RIG_DEBUG_TRACE, "%s: final vfo=%s\n", __func__, rig_strvfo(vfo)); + { + rig_debug(RIG_DEBUG_TRACE, "%s: final vfo=%s\n", __func__, rig_strvfo(vfo)); + } + return vfo; } @@ -2217,6 +2222,29 @@ void errmsg(int err, char *s, const char *func, const char *file, int line) rigerror(err)); } +uint32_t CRC32_function(uint8_t *buf, uint32_t len) +{ + + uint32_t val, crc; + uint8_t i; + + crc = 0xFFFFFFFF; + + while (len--) + { + val = (crc^*buf++) & 0xFF; + + for (i = 0; i < 8; i++) + { + val = val & 1 ? (val >> 1) ^ 0xEDB88320 : val >> 1; + } + + crc = val ^ crc >> 8; + } + + return crc ^ 0xFFFFFFFF; +} + //! @endcond diff --git a/src/misc.h b/src/misc.h index a3c74f9d..cd285661 100644 --- a/src/misc.h +++ b/src/misc.h @@ -110,6 +110,8 @@ extern HAMLIB_EXPORT(vfo_t) vfo_fixup(RIG *rig, vfo_t vfo); extern HAMLIB_EXPORT(int) parse_hoststr(char *host, char hoststr[256], char port[6]); +extern HAMLIB_EXPORT(uint32_t) CRC32_function(uint8_t *buf, uint32_t len); + #ifdef PRId64 /** \brief printf(3) format to be used for long long (64bits) type */ # define PRIll PRId64 commit 44a4b52bb961f5f80e3fdcee5d3877d665a85731 Merge: 0a5d9d97 5d367f09 Author: Michael Black <mdb...@ya...> Date: Sat Apr 17 15:07:02 2021 -0500 Merge pull request #668 from fillods/prm80_vhf_fix prm80: fix RX frequencies on VHF commit 5d367f0920ef8c9a994564ec00038560f26afe86 Author: Stephane Fillod <fi...@us...> Date: Sat Apr 17 21:31:51 2021 +0200 prm80: fix RX frequencies on VHF The RX IF shift on VHF is the opposite than on UHF. Tested-by: Claus <cla...@we...> diff --git a/rigs/prm80/prm80.c b/rigs/prm80/prm80.c index 4f13dcd7..10e6628e 100644 --- a/rigs/prm80/prm80.c +++ b/rigs/prm80/prm80.c @@ -337,6 +337,40 @@ int prm80_reset(RIG *rig, reset_t reset) return RIG_OK; } +/* + * Convert freq in Hz to the RX PLL value representation with PRM08 firmware + */ +static unsigned rx_freq_to_pll_value(freq_t rx_freq) +{ + // UHF vs VHF + if (rx_freq > MHz(300)) + { + return (unsigned)((rx_freq - RX_IF_OFFSET) / FREQ_DIV); + } + else + { + return (unsigned)((rx_freq + RX_IF_OFFSET) / FREQ_DIV); + } +} + +static freq_t pll_value_to_rx_freq(unsigned pll_value) +{ + freq_t rx_freq; + + rx_freq = (freq_t)pll_value * FREQ_DIV; + + // UHF vs VHF + if (rx_freq > MHz(300)) + { + rx_freq += RX_IF_OFFSET; + } + else + { + rx_freq -= RX_IF_OFFSET; + } + + return rx_freq; +} /* * Set RX and TX freq @@ -353,7 +387,7 @@ int prm80_set_rx_tx_freq(RIG *rig, freq_t rx_freq, freq_t tx_freq) // for RX, compute the PLL word without the IF sprintf(rx_freq_buf, "%04X", - (unsigned)((rx_freq - RX_IF_OFFSET) / FREQ_DIV)); + rx_freq_to_pll_value(rx_freq)); sprintf(tx_freq_buf, "%04X", (unsigned)(tx_freq / FREQ_DIV)); @@ -762,8 +796,7 @@ int prm80_get_channel(RIG *rig, vfo_t vfo, channel_t *chan, int read_only) chan->funcs |= (lock_byte & 0x05) ? RIG_FUNC_LOCK : 0; chan->funcs |= (lock_byte & 0x08) ? RIG_FUNC_MUTE : 0; - chan->freq = ((hhtoi(statebuf + 12) << 8) + hhtoi(statebuf + 14)) * FREQ_DIV + - RX_IF_OFFSET; + chan->freq = pll_value_to_rx_freq((hhtoi(statebuf + 12) << 8) + hhtoi(statebuf + 14)); chan->tx_freq = ((hhtoi(statebuf + 16) << 8) + hhtoi(statebuf + 18)) * FREQ_DIV; if (chan->rptr_shift != RIG_RPT_SHIFT_NONE) @@ -830,7 +863,7 @@ int prm80_set_channel(RIG *rig, vfo_t vfo, const channel_t *chan) } // Set the RX frequency as PLL word. - sprintf(buf, "%04X", (unsigned)((chan->freq - RX_IF_OFFSET) / FREQ_DIV)); + sprintf(buf, "%04X", rx_freq_to_pll_value(chan->freq)); // "PLL value to load : $" ret = read_dollar_prompt_and_send(&rs->rigport, NULL, NULL, buf); diff --git a/rigs/prm80/prm80.h b/rigs/prm80/prm80.h index c2c33f04..9e73ad2e 100644 --- a/rigs/prm80/prm80.h +++ b/rigs/prm80/prm80.h @@ -24,7 +24,7 @@ #include <hamlib/rig.h> -#define BACKEND_VER "20210315" +#define BACKEND_VER "20210416" #define PRM80_MEM_CAP { \ .freq = 1, \ commit 0a5d9d9768b85fcae784bc0708aeb01bd6794205 Author: Mike Black W9MDB <mdb...@ya...> Date: Fri Apr 16 23:22:33 2021 -0500 See if make -j 4 works for github workflow diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 2da9c1ab..3109a560 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -18,7 +18,7 @@ jobs: - name: configure run: ./configure - name: make - run: make + run: make -j 4 - name: make check run: make check - name: make distcheck ----------------------------------------------------------------------- Summary of changes: .github/workflows/c-cpp.yml | 2 +- rigs/icom/icom.c | 4 +- rigs/prm80/prm80.c | 41 +++++++- rigs/prm80/prm80.h | 2 +- src/misc.c | 36 ++++++- src/misc.h | 2 + src/rig.c | 11 ++- tests/simicom.c | 233 ++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 319 insertions(+), 12 deletions(-) create mode 100644 tests/simicom.c hooks/post-receive -- Hamlib -- Ham radio control libraries |