mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2026-06-02 06:04:39 -04:00
initial hamlib integration and frequency control
This commit is contained in:
+31
-9
@@ -4,18 +4,23 @@ std::vector<const struct rig_caps *> RigThread::rigCaps;
|
||||
|
||||
RigThread::RigThread() {
|
||||
terminated.store(true);
|
||||
freq = wxGetApp().getFrequency();
|
||||
}
|
||||
|
||||
RigThread::~RigThread() {
|
||||
|
||||
}
|
||||
|
||||
void RigThread::enumerate() {
|
||||
rig_set_debug(RIG_DEBUG_ERR);
|
||||
rig_load_all_backends();
|
||||
RigThread::rigCaps.clear();
|
||||
rig_list_foreach(RigThread::add_hamlib_rig, 0);
|
||||
std::sort(RigThread::rigCaps.begin(), RigThread::rigCaps.end(), rigGreater());
|
||||
RigList &RigThread::enumerate() {
|
||||
if (RigThread::rigCaps.empty()) {
|
||||
rig_set_debug(RIG_DEBUG_ERR);
|
||||
rig_load_all_backends();
|
||||
|
||||
rig_list_foreach(RigThread::add_hamlib_rig, 0);
|
||||
std::sort(RigThread::rigCaps.begin(), RigThread::rigCaps.end(), rigGreater());
|
||||
std::cout << "Loaded " << RigThread::rigCaps.size() << " rig models via hamlib." << std::endl;
|
||||
}
|
||||
return RigThread::rigCaps;
|
||||
}
|
||||
|
||||
int RigThread::add_hamlib_rig(const struct rig_caps *rc, void* f)
|
||||
@@ -39,6 +44,13 @@ void RigThread::run() {
|
||||
strncpy(rig->state.rigport.pathname, rigFile.c_str(), FILPATHLEN - 1);
|
||||
rig->state.rigport.parm.serial.rate = serialRate;
|
||||
retcode = rig_open(rig);
|
||||
|
||||
if (retcode != 0) {
|
||||
std::cout << "Rig failed to init. " << std::endl;
|
||||
terminated.store(true);
|
||||
return;
|
||||
}
|
||||
|
||||
char *info_buf = (char *)rig_get_info(rig);
|
||||
std::cout << "Rig info: " << info_buf << std::endl;
|
||||
|
||||
@@ -49,15 +61,25 @@ void RigThread::run() {
|
||||
if (freq != newFreq) {
|
||||
freq = newFreq;
|
||||
rig_set_freq(rig, RIG_VFO_CURR, freq);
|
||||
std::cout << "Set Rig Freq: %f" << newFreq << std::endl;
|
||||
// std::cout << "Set Rig Freq: %f" << newFreq << std::endl;
|
||||
}
|
||||
|
||||
freqChanged.store(false);
|
||||
} else {
|
||||
status = rig_get_freq(rig, RIG_VFO_CURR, &freq);
|
||||
freq_t checkFreq;
|
||||
|
||||
status = rig_get_freq(rig, RIG_VFO_CURR, &checkFreq);
|
||||
|
||||
if (checkFreq != freq) {
|
||||
freq = checkFreq;
|
||||
wxGetApp().setFrequency((long long)checkFreq);
|
||||
} else if (wxGetApp().getFrequency() != freq) {
|
||||
freq = wxGetApp().getFrequency();
|
||||
rig_set_freq(rig, RIG_VFO_CURR, freq);
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Rig Freq: " << freq << std::endl;
|
||||
// std::cout << "Rig Freq: " << freq << std::endl;
|
||||
}
|
||||
|
||||
rig_close(rig);
|
||||
|
||||
+4
-2
@@ -14,6 +14,8 @@ struct rigGreater
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<const struct rig_caps *> RigList;
|
||||
|
||||
class RigThread : public IOThread {
|
||||
public:
|
||||
RigThread();
|
||||
@@ -25,7 +27,7 @@ public:
|
||||
freq_t getFrequency();
|
||||
void setFrequency(freq_t new_freq);
|
||||
|
||||
static void enumerate();
|
||||
static RigList &enumerate();
|
||||
static int add_hamlib_rig(const struct rig_caps *rc, void* f);
|
||||
|
||||
private:
|
||||
@@ -37,5 +39,5 @@ private:
|
||||
freq_t freq;
|
||||
freq_t newFreq;
|
||||
std::atomic_bool freqChanged;
|
||||
static std::vector<const struct rig_caps *> rigCaps;
|
||||
static RigList rigCaps;
|
||||
};
|
||||
Reference in New Issue
Block a user