From 4c09c2362e6d3bb8b367a5fcde920dd19d4ac198 Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Wed, 28 Apr 2021 06:44:10 -0500 Subject: [PATCH] Fix rig_get_info to return "None" for VFO if needed instead of empty string Should make parsing easier ensuring all are token pairs https://github.com/Hamlib/Hamlib/issues/682 --- src/rig.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rig.c b/src/rig.c index d84129650..aece5b8be 100644 --- a/src/rig.c +++ b/src/rig.c @@ -6212,6 +6212,7 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len) vfo_t vfoA,vfoB; freq_t freqA,freqB; rmode_t modeA,modeB; + char *modeAstr, *modeBstr; pbwidth_t widthA,widthB; split_t split; int satmode; @@ -6236,11 +6237,15 @@ int HAMLIB_API rig_get_rig_info(RIG *rig, char *response, int max_response_len) rig_get_cache(rig, vfoB, &freqB, &cache_ms_freq, &modeB, &cache_ms_mode, &widthB, &cache_ms_width); } + modeAstr = (char*)rig_strrmode(modeA); + modeBstr = (char*)rig_strrmode(modeB); + if (modeAstr[0]==0) modeAstr="None"; + if (modeBstr[0]==0) modeBstr="None"; rxa = 1; txa = split == 0; rxb = !rxa; txb = split == 1; - snprintf(response,max_response_len,"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d", rig_strvfo(vfoA), freqA, rig_strrmode(modeA), (int)widthA, rxa, txa, rig_strvfo(vfoB), freqB, rig_strrmode(modeB), (int)widthB, rxb, txb, split, satmode); + snprintf(response,max_response_len,"VFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nVFO=%s Freq=%.0f Mode=%s Width=%d RX=%d TX=%d\nSplit=%d SatMode=%d", rig_strvfo(vfoA), freqA, modeAstr, (int)widthA, rxa, txa, rig_strvfo(vfoB), freqB, modeBstr, (int)widthB, rxb, txb, split, satmode); RETURNFUNC(RIG_OK); }