Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress unnecessary rig_init in hamlib. #173

Merged
merged 1 commit into from
Sep 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/hamlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static int build_list(const struct rig_caps *rig, rig_ptr_t);

Hamlib::Hamlib() :
m_rig(NULL),
m_rig_model(0),
m_modeBox(NULL),
m_freqBox(NULL),
m_currFreq(0),
Expand Down Expand Up @@ -117,8 +118,12 @@ bool Hamlib::connect(unsigned int rig_index, const char *serial_port, const int

/* Initialise, configure and open. */

m_rig = rig_init(m_rigList[rig_index]->rig_model);

if (m_rig == nullptr || m_rigList[rig_index]->rig_model != m_rig_model)
{
m_rig = rig_init(m_rigList[rig_index]->rig_model);
}
m_rig_model = m_rigList[rig_index]->rig_model;

if (!m_rig) {
if (g_verbose) fprintf(stderr, "rig_init() failed, returning\n");
return false;
Expand Down
1 change: 1 addition & 0 deletions src/hamlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Hamlib {

void update_mode_status();

rig_model_t m_rig_model;
RIG *m_rig;
/* Sorted list of rigs. */
riglist_t m_rigList;
Expand Down