Skip to content

Commit

Permalink
Merge branch 'master' into ms-qsy-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Jul 3, 2023
2 parents abf6ba5 + 578b7cf commit 3abf1e3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 17 deletions.
1 change: 1 addition & 0 deletions USER_MANUAL.html
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ <h2 data-number="17.1" id="v1.8.12-tbd-2023"><span class="header-section-number"
<li>Display ‘Digital’ on button when Analog mode is active. (PR #447)</li>
<li>Set minimum size for Mode box to 250px. (PR #446)</li>
<li>Notify FreeDV Reporter if only capable of RX. (PR #449)</li>
<li>Hamlib: allow frequency and mode changes during TX. (PR #455)</li>
</ul></li>
<li>Build system:
<ul>
Expand Down
1 change: 1 addition & 0 deletions USER_MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Display 'Digital' on button when Analog mode is active. (PR #447)
* Set minimum size for Mode box to 250px. (PR #446)
* Notify FreeDV Reporter if only capable of RX. (PR #449)
* Hamlib: allow frequency and mode changes during TX. (PR #455)
3. Build system:
* Bump Codec2 version to v1.1.1. (PR #437)
4. Miscallenous:
Expand Down
101 changes: 84 additions & 17 deletions src/hamlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,12 +329,86 @@ void Hamlib::disable_mode_detection()

void Hamlib::setMode(bool analog, uint64_t frequencyHz)
{
if (m_rig == nullptr || pttSet_ || readOnly_)
if (m_rig == nullptr || readOnly_)
{
// Ignore if not connected
return;
}

if (pttSet_)
{
// If transmitting, temporarily stop transmitting so we can change the mode.
int result = rig_set_ptt(m_rig, RIG_VFO_CURR, RIG_PTT_OFF);
if (result != RIG_OK)
{
// If we can't stop transmitting, we shouldn't try to change the mode
// as it'll fail on some radios.
if (g_verbose) fprintf(stderr, "rig_set_ptt: error = %s \n", rigerror(result));

return;
}
}


vfo_t currVfo = getCurrentVfo_();
rmode_t mode = getHamlibMode_(analog, frequencyHz);
setModeHelper_(currVfo, mode);

if (pttSet_)
{
// If transmitting, temporarily stop transmitting so we can change the mode.
int result = rig_set_ptt(m_rig, RIG_VFO_CURR, RIG_PTT_ON);
if (result != RIG_OK)
{
// If we can't stop transmitting, we shouldn't try to change the mode
// as it'll fail on some radios.
if (g_verbose) fprintf(stderr, "rig_set_ptt: error = %s \n", rigerror(result));
}
}
}

void Hamlib::setFrequencyAndMode(uint64_t frequencyHz, bool analog)
{
if (m_rig == nullptr || readOnly_)
{
// Ignore if not connected or if transmitting
return;
}

if (pttSet_)
{
// If transmitting, temporarily stop transmitting so we can change the mode.
int result = rig_set_ptt(m_rig, RIG_VFO_CURR, RIG_PTT_OFF);
if (result != RIG_OK)
{
// If we can't stop transmitting, we shouldn't try to change the mode
// as it'll fail on some radios.
if (g_verbose) fprintf(stderr, "rig_set_ptt: error = %s \n", rigerror(result));

return;
}
}

vfo_t currVfo = getCurrentVfo_();
rmode_t mode = getHamlibMode_(analog, frequencyHz);
setModeHelper_(currVfo, mode);
setFrequencyHelper_(currVfo, frequencyHz);

if (pttSet_)
{
// If transmitting, temporarily stop transmitting so we can change the mode.
int result = rig_set_ptt(m_rig, RIG_VFO_CURR, RIG_PTT_ON);
if (result != RIG_OK)
{
// If we can't stop transmitting, we shouldn't try to change the mode
// as it'll fail on some radios.
if (g_verbose) fprintf(stderr, "rig_set_ptt: error = %s \n", rigerror(result));
}
}
}

rmode_t Hamlib::getHamlibMode_(bool analog, uint64_t frequencyHz)
{
// Widest 60 meter allocation is 5.250-5.450 MHz per https://en.wikipedia.org/wiki/60-meter_band.
bool is60MeterBand = frequencyHz >= 5250000 && frequencyHz <= 5450000;

Expand All @@ -361,24 +435,10 @@ void Hamlib::setMode(bool analog, uint64_t frequencyHz)
{
assert(0);
}

vfo_t currVfo = getCurrentVfo_();
setModeHelper_(currVfo, mode);
}

void Hamlib::setFrequencyAndMode(uint64_t frequencyHz, bool analog)
{
if (m_rig == nullptr || pttSet_ || readOnly_)
{
// Ignore if not connected or if transmitting
return;
}

vfo_t currVfo = getCurrentVfo_();
setMode(analog, frequencyHz);
setFrequencyHelper_(currVfo, frequencyHz);
return mode;
}

void Hamlib::setModeHelper_(vfo_t currVfo, rmode_t mode)
{
bool setOkay = false;
Expand Down Expand Up @@ -596,6 +656,13 @@ void Hamlib::update_mode_status()

void Hamlib::close(void) {
if(m_rig) {
// Stop transmitting.
if (pttSet_)
{
wxString tmp;
ptt(false, tmp);
}

// Turn off status thread if needed.
disable_mode_detection();

Expand Down
1 change: 1 addition & 0 deletions src/hamlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Hamlib {
typedef std::vector<const struct rig_caps *> riglist_t;

private:
rmode_t getHamlibMode_(bool analog, uint64_t frequencyHz);
void update_mode_status();
void statusUpdateThreadEntryFn_();
void update_from_hamlib_();
Expand Down

0 comments on commit 3abf1e3

Please sign in to comment.