Hamlib: Add checking prior to retrieving minimum/maximum baud rates. (#1209)

* Hamlib: Add checking prior to retrieving minimum/maximum baud rates.

* Make sure whitespace is removed from rig name during config load.

* Add PR #1209 to changelog.

* Fix possible deadlock in ThreadedTimer.

* Do not trim rig names from library, only when comparing.

* Fix ODR violation in g_tx.
ms-flex-sighup
Mooneer Salem 2026-02-02 14:37:17 -08:00 committed by GitHub
parent 498a6d3637
commit f4a35367d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 69 additions and 26 deletions

View File

@ -883,6 +883,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
* Fix bug causing PTT input to be initially ignored until pushing the PTT button. (PR #1203)
* FlexRadio: Fix command format for UDP port. (PR #1205; thanks @amcdermond!)
* Cache PTT response time to minimize first TX reporting issues. (PR #1207)
* Hamlib: Add checking prior to retrieving minimum/maximum baud rates. (PR #1209)
2. Build system:
* macOS: Fix dylibbundler call for compilation. (PR #1204)
* macOS: Add /Applications shortcut to generated DMG. (PR #1206)

View File

@ -63,6 +63,7 @@ void RigControlConfiguration::load(wxConfigBase* config)
load_(config, hamlibUseAnalogModes);
load_(config, hamlibIcomCIVAddress);
load_(config, hamlibRigName);
load_(config, hamlibPTTType);
load_(config, hamlibSerialRate);
load_(config, hamlibSerialPort);

View File

@ -526,10 +526,17 @@ void EasySetupDialog::ExchangePttDeviceData(int inout)
m_cbRigName->SetSelection(wxGetApp().m_intHamlibRig);
resetIcomCIVStatus_();
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(m_cbRigName->GetCurrentSelection());
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(m_cbRigName->GetCurrentSelection());
updateHamlibSerialRates_(minBaudRate, maxBaudRate);
auto selected = m_cbRigName->GetCurrentSelection();
if (selected >= 0)
{
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(selected);
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(selected);
updateHamlibSerialRates_(minBaudRate, maxBaudRate);
}
else
{
updateHamlibSerialRates_();
}
m_cbSerialPort->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.hamlibSerialPort);
if (wxGetApp().appConfiguration.rigControlConfiguration.hamlibSerialRate == 0) {
@ -653,9 +660,17 @@ void EasySetupDialog::HamlibRigNameChanged(wxCommandEvent&)
{
resetIcomCIVStatus_();
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(m_cbRigName->GetCurrentSelection());
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(m_cbRigName->GetCurrentSelection());
updateHamlibSerialRates_(minBaudRate, maxBaudRate);
auto selected = m_cbRigName->GetCurrentSelection();
if (selected >= 0)
{
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(selected);
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(selected);
updateHamlibSerialRates_(minBaudRate, maxBaudRate);
}
else
{
updateHamlibSerialRates_();
}
}
void EasySetupDialog::resetIcomCIVStatus_()

View File

@ -572,10 +572,17 @@ void ComPortsDlg::ExchangeData(int inout)
m_cbSerialPort->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.hamlibSerialPort);
m_cbPttSerialPort->SetValue(wxGetApp().appConfiguration.rigControlConfiguration.hamlibPttSerialPort);
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(m_cbRigName->GetCurrentSelection());
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(m_cbRigName->GetCurrentSelection());
populateBaudRateList(minBaudRate, maxBaudRate);
auto selected = m_cbRigName->GetCurrentSelection();
if (selected >= 0)
{
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(selected);
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(selected);
populateBaudRateList(minBaudRate, maxBaudRate);
}
else
{
populateBaudRateList();
}
if (wxGetApp().appConfiguration.rigControlConfiguration.hamlibSerialRate == 0) {
m_cbSerialRate->SetSelection(0);
} else {
@ -934,9 +941,17 @@ void ComPortsDlg::HamlibRigNameChanged(wxCommandEvent&)
{
resetIcomCIVStatus();
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(m_cbRigName->GetCurrentSelection());
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(m_cbRigName->GetCurrentSelection());
populateBaudRateList(minBaudRate, maxBaudRate);
auto selected = m_cbRigName->GetCurrentSelection();
if (selected >= 0)
{
auto minBaudRate = HamlibRigController::GetMinimumSerialBaudRate(selected);
auto maxBaudRate = HamlibRigController::GetMaximumSerialBaudRate(selected);
populateBaudRateList(minBaudRate, maxBaudRate);
}
else
{
populateBaudRateList();
}
}
void ComPortsDlg::resetIcomCIVStatus()

View File

@ -40,7 +40,7 @@ using namespace std::chrono_literals;
#include "codec2_alloc.h"
extern std::atomic<int> g_tx;
extern std::atomic<bool> g_tx;
extern bool endingTx;
bool g_eoo_enqueued;

View File

@ -56,7 +56,7 @@ extern "C"
using namespace std::chrono_literals;
std::atomic<int> g_tx;
std::atomic<bool> g_tx;
bool endingTx;
bool exitingApplication;
int spotTimeoutSeconds = 600; // 10 minute default

View File

@ -69,7 +69,7 @@ constexpr int DEFAULT_OUTPUT_SAMPLE_RATE = 16000;
using namespace std::chrono_literals;
std::atomic<int> g_tx;
std::atomic<bool> g_tx;
bool endingTx;
struct CallsignReporting

View File

@ -115,7 +115,7 @@ std::atomic<float> g_txLevelScale;
int g_SquelchActive;
float g_SquelchLevel;
int g_analog;
std::atomic<int> g_tx;
std::atomic<bool> g_tx;
float g_snr;
std::atomic<bool> g_half_duplex;
std::atomic<bool> g_voice_keyer_tx;

View File

@ -31,7 +31,7 @@ extern int g_mode;
extern int g_SquelchActive;
extern float g_SquelchLevel;
extern int g_analog;
extern std::atomic<int> g_tx;
extern std::atomic<bool> g_tx;
extern std::atomic<int> g_State, g_prev_State;
extern FreeDVInterface freedvInterface;
extern std::atomic<bool> g_queueResync;

View File

@ -73,7 +73,7 @@ extern paCallBackData* g_rxUserdata;
extern int g_analog;
extern int g_nSoundCards;
extern std::atomic<bool> g_half_duplex;
extern std::atomic<int> g_tx;
extern std::atomic<bool> g_tx;
extern int g_dump_fifo_state;
extern std::atomic<bool> endingTx;
extern std::atomic<bool> g_playFileToMicIn;

View File

@ -198,7 +198,6 @@ void HamlibRigController::InitializeHamlibLibrary()
{
std::string rigName =
std::string(rig->mfg_name) + std::string(" ") + std::string(rig->model_name);
rigName.erase(rigName.find_last_not_of(" \n\r\t") + 1); // trim whitespace from end
RigNameList_.push_back(rigName);
}
@ -254,10 +253,14 @@ int HamlibRigController::RigNameToIndex(std::string const& rigName)
{
InitializeHamlibLibrary();
std::string trimmedRigName = rigName;
trimmedRigName.erase(trimmedRigName.find_last_not_of(" \n\r\t") + 1);
int index = 0;
for (auto& entry : RigNameList_)
{
if (rigName == entry)
std::string trimmedEntry = entry;
trimmedEntry.erase(trimmedEntry.find_last_not_of(" \n\r\t") + 1);
if (trimmedRigName == trimmedEntry)
{
return index;
}
@ -416,7 +419,7 @@ void HamlibRigController::connectImpl_()
#else
result = rig_get_conf(tmpRig, rig_token_lookup(tmpRig, HAMLIB_TIMEOUT_TOKEN_NAME), currentTimeout);
#endif // defined(HAMLIB_USE_FRIENDLY_ERRORS)
if (result != RIG_OK || (atoi(currentTimeout) >= atoi(MAX_TIMEOUT) && rigName_ != "FLRig" && rigName_ != "Hamlib NET rigctl"))
if (result != RIG_OK || (atoi(currentTimeout) >= atoi(MAX_TIMEOUT) && rigName_.find("FLRig") != 0 && rigName_ != "Hamlib NET rigctl"))
{
rig_set_conf(tmpRig, rig_token_lookup(tmpRig, HAMLIB_TIMEOUT_TOKEN_NAME), MAX_TIMEOUT);
}

View File

@ -16,7 +16,7 @@
extern float g_RxFreqOffsetHz;
extern float g_TxFreqOffsetHz;
extern FreeDVInterface freedvInterface;
extern std::atomic<int> g_tx;
extern std::atomic<bool> g_tx;
void clickTune(float freq) {

View File

@ -120,7 +120,12 @@ void ThreadedTimer::TimerServer::eventLoop_()
// Set next fire time if repeating, otherwise deregister
if (tmpTimer->repeat_)
{
tmpTimer->nextFireTime_ += std::chrono::milliseconds(tmpTimer->timeoutMilliseconds_);
lk.unlock();
{
std::unique_lock<std::mutex> lk2(tmpTimer->timerMutex_);
tmpTimer->nextFireTime_ += std::chrono::milliseconds(tmpTimer->timeoutMilliseconds_);
}
lk.lock();
timerQueue_.push(tmpTimer);
}
else
@ -134,7 +139,7 @@ void ThreadedTimer::TimerServer::eventLoop_()
tmpTimer->fn_(*tmpTimer);
lk.lock();
currentTime = std::chrono::steady_clock::now();
}
}
}
}
#endif // !defined(__APPLE__)
@ -239,7 +244,10 @@ void ThreadedTimer::stop()
#else
if (isRunning_.load(std::memory_order_acquire))
{
// Temporarily unlock here to avoid deadlocks.
lk.unlock();
TheTimerServer_.unregisterTimer(this);
lk.lock();
isRunning_.store(false, std::memory_order_release);
}
#endif // defined(__APPLE__)