void RigThread::run() { int retcode, status; std::cout << "Rig thread starting." << std::endl; rig = rig_init(rigModel); 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; while (!terminated.load()) { std::this_thread::sleep_for(std::chrono::milliseconds(150)); if (freqChanged.load()) { status = rig_get_freq(rig, RIG_VFO_CURR, &freq); if (freq != newFreq) { freq = newFreq; rig_set_freq(rig, RIG_VFO_CURR, freq); // std::cout << "Set Rig Freq: %f" << newFreq << std::endl; } freqChanged.store(false); } else { 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; } rig_close(rig); rig_cleanup(rig); std::cout << "Rig thread exiting." << std::endl; };
void __fastcall TTestRigMain::FreqSliderChange( TObject */*Sender*/ ) { if ( !noSetFreq ) { int pos = FreqSlider->Position; freq_t freq = 28000000; freq += pos * 100; int ferr = rig_set_freq( my_rig, RIG_VFO_CURR, freq ); if ( ferr != RIG_OK ) { char buff[ 1024 ]; sprintf( buff, "rig_setFreq: error = %s", rigerror( ferr ) ); Label2->Caption = buff; } } }
int initialize_rig() { RIG *my_rig; /* handle to rig (nstance) */ int retcode; config_setting_t *rig_control_settings; rig_control_settings = config_lookup(&cfg, "repeater.rig_control"); int rig_id, baud_rate, data_bits, stop_bits, enabled; const char *serial_port, *frequency; config_setting_lookup_int(rig_control_settings, "rig_id", &rig_id); config_setting_lookup_int(rig_control_settings, "baud_rate", &baud_rate); config_setting_lookup_int(rig_control_settings, "data_bits", &data_bits); config_setting_lookup_int(rig_control_settings, "stop_bits", &stop_bits); config_setting_lookup_bool(rig_control_settings, "enabled", &enabled); config_setting_lookup_string(rig_control_settings, "frequency", &frequency); config_setting_lookup_string(rig_control_settings, "serial_port", &serial_port); if (!enabled) return -1; printf("frequency: %s\n", frequency); rig_set_debug(RIG_DEBUG_WARN); my_rig = rig_init(rig_id); if (!my_rig) { fprintf(stderr,"Unknown rig num: %d\n", rig_id); fprintf(stderr,"Please check riglist.h\n"); exit(1); /* whoops! something went wrong (mem alloc?) */ } strncpy(my_rig->state.rigport.pathname, "/dev/ttyS0", FILPATHLEN - 1); my_rig->state.rigport.parm.serial.rate = baud_rate; my_rig->state.rigport.parm.serial.data_bits = data_bits; my_rig->state.rigport.parm.serial.stop_bits = stop_bits; retcode = rig_open(my_rig); if (retcode != RIG_OK) { printf("rig_open: error = %s\n", rigerror(retcode)); exit(2); } return rig_set_freq(my_rig, RIG_VFO_CURR, atoi(frequency)); }
bool rigControl::setFrequency(double frequency) { int retcode; if(catParams.enableXMLRPC) { xmlIntfPtr->setFrequency(frequency); } else { if(!rigControlEnabled) return false; retcode = rig_set_vfo(my_rig, RIG_VFO_CURR); if (retcode != RIG_OK ) {errorMessage(retcode,"setVFO"); return false; } retcode = rig_set_freq(my_rig, RIG_VFO_CURR, frequency); if (retcode != RIG_OK ) {errorMessage(retcode,"setFrequency"); return false; } } return true; }
void Hamlib::setFrequency(Session::ref session, Request::ref request, Reply::ref reply) { Config *config = m_server->getConfig(); if (config->getUnregistered().find("hamlib.device") == config->getUnregistered().end()) { LOG_ERROR(logger, "Set '[hamlib] device' in config file."); } std::string device = config->getUnregistered().find("hamlib.device")->second; RIG *my_rig; freq_t freq; int retcode; std::string f = request->getContent(); if (sscanf(f.c_str(), "%lf", &freq) != 1) { LOG_WARN(logger, "Unable to read freq " << f) fprintf(stderr, "ERROR: Unable to read freq.\n"); } std::cout << boost::lexical_cast<std::string>((double) freq) << "\n"; rig_set_debug(RIG_DEBUG_NONE); // rig_set_debug(RIG_DEBUG_TRACE); rig_model_t myrig_model = RIG_MODEL_IC706MKIIG; my_rig = rig_init(myrig_model); my_rig->state.rigport.type.rig = RIG_PORT_SERIAL; my_rig->state.rigport.parm.serial.rate = 19200; my_rig->state.rigport.parm.serial.data_bits = 8; my_rig->state.rigport.parm.serial.stop_bits = 1; my_rig->state.rigport.parm.serial.parity = RIG_PARITY_NONE; my_rig->state.rigport.parm.serial.handshake = RIG_HANDSHAKE_NONE; strncpy(my_rig->state.rigport.pathname, device.c_str(), FILPATHLEN - 1); if ((retcode = rig_open(my_rig)) != RIG_OK) { fprintf(stderr, "rig_open: error = %s\n", rigerror(retcode)); LOG_ERROR(logger, "rig_open: error " << rigerror(retcode)); } if ((retcode = rig_set_freq(my_rig, RIG_VFO_CURR, freq) != RIG_OK)) { LOG_ERROR(logger, "rig_set_freq: error " << rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_close(my_rig); rig_cleanup(my_rig); }
int main(int argc, char *argv[]) { RIG *my_rig; /* handle to rig (nstance) */ freq_t freq; /* frequency */ rmode_t rmode; /* radio mode of operation */ pbwidth_t width; vfo_t vfo; /* vfo selection */ int strength; /* S-Meter level */ int rit = 0; /* RIT status */ int xit = 0; /* XIT status */ int retcode; /* generic return code from functions */ rig_model_t myrig_model; printf("testrig: Hello, I am your main() !\n"); /* Turn off backend debugging ouput */ rig_set_debug_level(RIG_DEBUG_NONE); /* * allocate memory, setup & open port */ if (argc < 2) { hamlib_port_t myport; /* may be overriden by backend probe */ myport.type.rig = RIG_PORT_SERIAL; myport.parm.serial.rate = 9600; myport.parm.serial.data_bits = 8; myport.parm.serial.stop_bits = 1; myport.parm.serial.parity = RIG_PARITY_NONE; myport.parm.serial.handshake = RIG_HANDSHAKE_NONE; strncpy(myport.pathname, SERIAL_PORT, FILPATHLEN - 1); rig_load_all_backends(); myrig_model = rig_probe(&myport); } else { myrig_model = atoi(argv[1]); } my_rig = rig_init(myrig_model); if (!my_rig) { fprintf(stderr, "Unknown rig num: %d\n", myrig_model); fprintf(stderr, "Please check riglist.h\n"); exit(1); /* whoops! something went wrong (mem alloc?) */ } strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1); retcode = rig_open(my_rig); if (retcode != RIG_OK) { printf("rig_open: error = %s\n", rigerror(retcode)); exit(2); } printf("Port %s opened ok\n", SERIAL_PORT); /* * Below are examples of set/get routines. * Must add checking of functionality map prior to command execution -- FS * */ /* * Example of setting rig paameters * and some error checking on the return code. */ retcode = rig_set_vfo(my_rig, RIG_VFO_B); if (retcode != RIG_OK) { printf("rig_set_vfo: error = %s \n", rigerror(retcode)); } /* * Lets try some frequencies and modes. Return code is not checked. * Examples of checking return code are further down. * */ /* 10m FM Narrow */ printf("\nSetting 10m FM Narrow...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 29620000); /* 10m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_FM, rig_passband_narrow(my_rig, RIG_MODE_FM)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* so you can see it -- FS */ /* 15m USB */ printf("Setting 15m USB...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 21235175); /* 15m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_USB, rig_passband_normal(my_rig, RIG_MODE_USB)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 40m LSB */ printf("Setting 40m LSB...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 7250100); /* 40m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 80m AM Narrow */ printf("Setting 80m AM Narrow...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 3885000); /* 80m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM, rig_passband_narrow(my_rig, RIG_MODE_AM)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.6f MHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 160m CW Normal */ printf("Setting 160m CW...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 1875000); /* 160m */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n", freq / 1000, rig_strrmode(rmode), width); sleep(1); /* 160m CW Narrow -- The band is noisy tonight -- FS*/ printf("Setting 160m CW Narrow...\n"); retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_CW, rig_passband_narrow(my_rig, RIG_MODE_CW)); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %li Hz\n\n", freq / 1000, rig_strrmode(rmode), width); sleep(1); /* AM Broadcast band */ printf("Setting Medium Wave AM...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 770000); /* KAAM */ retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_AM, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); printf(" Freq: %.3f kHz, Mode: %s, Passband: %.3f kHz\n\n", freq / 1000, rig_strrmode(rmode), width / 1000.0); sleep(1); /* 20m USB on VFO_A */ printf("Setting 20m on VFO A with two functions...\n"); retcode = rig_set_vfo(my_rig, RIG_VFO_A); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 14250375); /* cq de vk3fcs */ if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_vfo(my_rig, &vfo); printf(" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000, rig_strvfo(vfo)); sleep(1); /* 20m USB on VFO_A , with only 1 call */ printf("Setting 20m on VFO A with one function...\n"); retcode = rig_set_freq(my_rig, RIG_VFO_A, 14295125); /* cq de vk3fcs */ if (retcode != RIG_OK) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_get_freq(my_rig, RIG_VFO_CURR, &freq); rig_get_vfo(my_rig, &vfo); printf(" Freq: %.6f MHz, VFO: %s\n\n", freq / 1000000, rig_strvfo(vfo)); sleep(1); #if 0 retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 145100000); /* 2m */ sleep(2); retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 435125000); /* 70cm */ sleep(2); #endif printf("Setting rig Mode to LSB.\n"); retcode = rig_set_mode(my_rig, RIG_VFO_CURR, RIG_MODE_LSB, RIG_PASSBAND_NORMAL); if (retcode != RIG_OK) { printf("rig_set_mode: error = %s \n", rigerror(retcode)); } sleep(1); printf("Setting rig PTT ON.\n"); retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_ON); /* stand back ! */ if (retcode != RIG_OK) { printf("rig_set_ptt: error = %s \n", rigerror(retcode)); } sleep(1); printf("Setting rig PTT OFF.\n"); retcode = rig_set_ptt(my_rig, RIG_VFO_A, RIG_PTT_OFF); /* phew ! */ if (retcode != RIG_OK) { printf("rig_set_ptt: error = %s \n", rigerror(retcode)); } sleep(1); /* * Simple examples of getting rig information -- FS * */ printf("\nGet various raw rig values:\n"); retcode = rig_get_vfo(my_rig, &vfo); /* try to get vfo info */ if (retcode == RIG_OK) { printf("rig_get_vfo: vfo = %i \n", vfo); } else { printf("rig_get_vfo: error = %s \n", rigerror(retcode)); } retcode = rig_get_freq(my_rig, RIG_VFO_CURR, &freq); if (retcode == RIG_OK) { printf("rig_get_freq: freq = %"PRIfreq"\n", freq); } else { printf("rig_get_freq: error = %s \n", rigerror(retcode)); } retcode = rig_get_mode(my_rig, RIG_VFO_CURR, &rmode, &width); if (retcode == RIG_OK) { printf("rig_get_mode: mode = %"PRIll"\n", rmode); } else { printf("rig_get_mode: error = %s \n", rigerror(retcode)); } retcode = rig_get_strength(my_rig, RIG_VFO_CURR, &strength); if (retcode == RIG_OK) { printf("rig_get_strength: strength = %i \n", strength); } else { printf("rig_get_strength: error = %s \n", rigerror(retcode)); } if (rig_has_set_func(my_rig, RIG_FUNC_RIT)) { retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, 1); printf("rig_set_func: Setting RIT ON\n"); } if (rig_has_get_func(my_rig, RIG_FUNC_RIT)) { retcode = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_RIT, &rit); printf("rig_get_func: RIT: %d\n", rit); } if (rig_has_set_func(my_rig, RIG_FUNC_XIT)) { retcode = rig_set_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, 1); printf("rig_set_func: Setting XIT ON\n"); } if (rig_has_get_func(my_rig, RIG_FUNC_XIT)) { retcode = rig_get_func(my_rig, RIG_VFO_CURR, RIG_FUNC_XIT, &xit); printf("rig_get_func: XIT: %d\n", xit); } rig_close(my_rig); /* close port */ rig_cleanup(my_rig); /* if you care about memory */ printf("port %s closed ok \n", SERIAL_PORT); return 0; }
/* * Restores chan into current VFO state by emulating rig_set_channel */ static int generic_restore_channel(RIG *rig, const channel_t *chan) { int i; struct ext_list *p; setting_t setting; const channel_cap_t *mem_cap = NULL; if (chan->vfo == RIG_VFO_MEM) { const chan_t *chan_cap; chan_cap = rig_lookup_mem_caps(rig, chan->channel_num); if (chan_cap) mem_cap = &chan_cap->mem_caps; } /* If vfo!=RIG_VFO_MEM or incomplete backend, try all properties */ if (mem_cap == NULL || rig_mem_caps_empty(mem_cap)) { mem_cap = &mem_cap_all; } rig_set_vfo(rig, chan->vfo); if (mem_cap->freq) rig_set_freq(rig, RIG_VFO_CURR, chan->freq); if (mem_cap->mode || mem_cap->width) rig_set_mode(rig, RIG_VFO_CURR, chan->mode, chan->width); rig_set_split_vfo(rig, RIG_VFO_CURR, chan->split, chan->tx_vfo); if (chan->split != RIG_SPLIT_OFF) { if (mem_cap->tx_freq) rig_set_split_freq(rig, RIG_VFO_CURR, chan->tx_freq); if (mem_cap->tx_mode || mem_cap->tx_width) rig_set_split_mode(rig, RIG_VFO_CURR, chan->tx_mode, chan->tx_width); } if (mem_cap->rptr_shift) rig_set_rptr_shift(rig, RIG_VFO_CURR, chan->rptr_shift); if (mem_cap->rptr_offs) rig_set_rptr_offs(rig, RIG_VFO_CURR, chan->rptr_offs); for (i=0; i<RIG_SETTING_MAX; i++) { setting = rig_idx2setting(i); if (setting & mem_cap->levels) rig_set_level(rig, RIG_VFO_CURR, setting, chan->levels[i]); } if (mem_cap->ant) rig_set_ant(rig, RIG_VFO_CURR, chan->ant); if (mem_cap->tuning_step) rig_set_ts(rig, RIG_VFO_CURR, chan->tuning_step); if (mem_cap->rit) rig_set_rit(rig, RIG_VFO_CURR, chan->rit); if (mem_cap->xit) rig_set_xit(rig, RIG_VFO_CURR, chan->xit); for (i=0; i<RIG_SETTING_MAX; i++) { setting = rig_idx2setting(i); if (setting & mem_cap->funcs) rig_set_func(rig, RIG_VFO_CURR, setting, chan->funcs & rig_idx2setting(i)); } if (mem_cap->ctcss_tone) rig_set_ctcss_tone(rig, RIG_VFO_CURR, chan->ctcss_tone); if (mem_cap->ctcss_sql) rig_set_ctcss_sql(rig, RIG_VFO_CURR, chan->ctcss_sql); if (mem_cap->dcs_code) rig_set_dcs_code(rig, RIG_VFO_CURR, chan->dcs_code); if (mem_cap->dcs_sql) rig_set_dcs_sql(rig, RIG_VFO_CURR, chan->dcs_sql); /* * TODO: (missing calls) * - channel_desc * - bank_num * - scan_group * - flags */ for (p = chan->ext_levels; p && !RIG_IS_EXT_END(*p); p++) rig_set_ext_level(rig, RIG_VFO_CURR, p->token, p->val); return RIG_OK; }
int main (int argc, char *argv[]) { RIG *my_rig; /* handle to rig (nstance) */ int retcode; /* generic return code from functions */ int i, count = 0; if (argc != 2) { fprintf(stderr,"%s <rig_num>\n", argv[0]); exit(1); } printf("testrig:hello, I am your main() !\n"); /* * allocate memory, setup & open port */ my_rig = rig_init(atoi(argv[1])); if (!my_rig) { fprintf(stderr,"Unknown rig num: %d\n",atoi(argv[1])); fprintf(stderr,"Please check riglist.h\n"); exit(1); /* whoops! something went wrong (mem alloc?) */ } strncpy(my_rig->state.rigport.pathname, SERIAL_PORT, FILPATHLEN - 1); if (rig_open(my_rig)) exit(2); printf("Port %s opened ok\n", SERIAL_PORT); /* * Below are examples of set/get routines. * Must add checking of functionality map prior to command execution -- FS * */ retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 439700000); if (retcode != RIG_OK ) { printf("rig_set_freq: error = %s \n", rigerror(retcode)); } rig_set_freq_callback(my_rig, myfreq_event, (rig_ptr_t)&count); retcode = rig_set_trn(my_rig, RIG_TRN_RIG); if (retcode != RIG_OK ) { printf("rig_set_trn: error = %s \n", rigerror(retcode)); } for (i=0;i<12;i++) { printf("Loop count: %d\n", i); sleep(10); /* or anything smarter */ } printf("Frequency changed %d times\n", count); rig_close(my_rig); /* close port */ rig_cleanup(my_rig); /* if you care about memory */ printf("port %s closed ok \n",SERIAL_PORT); return 0; }
static void *hamlib_loop(void *args) { struct timespec sleep; gdouble freq = 0.0; rmode_t mode = RIG_MODE_USB; gint ret; gchar *str; sleep.tv_sec = 0; sleep.tv_nsec = 100000000L; /* 100ms */ for (;;) { nanosleep(&sleep, NULL); // need_freq = (hamlib_waterfall || hamlib_qsodata || hamlib_qsy); // need_mode = need_freq; /* see if we are being canceled */ if (hamlib_exit) break; if (need_freq) { freq_t f; G_LOCK(hamlib_mutex); ret = rig_get_freq(rig, RIG_VFO_CURR, &f); G_UNLOCK(hamlib_mutex); if (ret != RIG_OK) { str = g_strdup_printf(_("rig_get_freq failed: %s"), rigerror(ret)); statusbar_set("mainstatusbar", str); g_free(str); continue; } freq = (gdouble) f; } /* see if we are being canceled */ if (hamlib_exit) break; if (need_mode) { pbwidth_t width; G_LOCK(hamlib_mutex); ret = rig_get_mode(rig, RIG_VFO_CURR, &mode, &width); G_UNLOCK(hamlib_mutex); if (ret != RIG_OK) { str = g_strdup_printf(_("rig_get_mode failed: %s"), rigerror(ret)); statusbar_set("mainstatusbar", str); g_free(str); continue; } } if (hamlib_qsy) { gfloat f = conf_get_float("hamlib/cfreq"); hamlib_qsy = FALSE; G_LOCK(hamlib_mutex); ret = rig_set_freq(rig, RIG_VFO_CURR, ((gdouble) freq) + trx_get_freq() - f); G_UNLOCK(hamlib_mutex); if (ret != RIG_OK) { str = g_strdup_printf(_("rig_set_freq failed: %s"), rigerror(ret)); statusbar_set("mainstatusbar", str); g_free(str); continue; } waterfall_set_frequency(waterfall, f); } if (hamlib_waterfall) { waterfall_set_carrier_frequency(waterfall, freq); if (mode == RIG_MODE_LSB) waterfall_set_lsb(waterfall, TRUE); else waterfall_set_lsb(waterfall, FALSE); } if (hamlib_qsodata) { gchar *str, *fmt; if (mode == RIG_MODE_LSB) freq -= trx_get_freq(); else freq += trx_get_freq(); switch (hamlib_res) { case 2: fmt = "%.6f"; break; case 1: fmt = "%.3f"; break; case 0: default: fmt = "%.0f"; break; } str = g_strdup_printf(fmt, freq / 1000000.0); gdk_threads_enter(); qsodata_set_band_mode(QSODATA_BAND_ENTRY); qsodata_set_freq(str); gdk_threads_leave(); g_free(str); } /* see if we are being canceled */ if (hamlib_exit) break; } if (hamlib_waterfall) { waterfall_set_carrier_frequency(waterfall, 0.0); waterfall_set_lsb(waterfall, FALSE); } if (hamlib_qsodata) { gdk_threads_enter(); qsodata_set_band_mode(QSODATA_BAND_COMBO); qsodata_set_freq(""); gdk_threads_leave(); } /* this will exit the hamlib thread */ return NULL; }
void RigThread::run() { int retcode, status; termStatus = 0; std::cout << "Rig thread starting." << std::endl; rig = rig_init(rigModel); 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; IOThread::terminate(); return; } char *info_buf = (char *)rig_get_info(rig); if (info_buf) { std::cout << "Rig info: " << info_buf << std::endl; } else { std::cout << "Rig info was NULL." << std::endl; } while (!stopping) { std::this_thread::sleep_for(std::chrono::milliseconds(150)); auto activeDemod = wxGetApp().getDemodMgr().getActiveDemodulator(); auto lastDemod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); if (freqChanged.load() && (controlMode.load() || setOneShot.load())) { status = rig_get_freq(rig, RIG_VFO_CURR, &freq); if (status == 0 && !stopping) { if (freq != newFreq && setOneShot.load()) { freq = newFreq; rig_set_freq(rig, RIG_VFO_CURR, freq); // std::cout << "Set Rig Freq: %f" << newFreq << std::endl; } freqChanged.store(false); setOneShot.store(false); } else { termStatus = 0; break; } } else { freq_t checkFreq; status = rig_get_freq(rig, RIG_VFO_CURR, &checkFreq); if (status == 0 && !stopping) { if (checkFreq != freq && followMode.load()) { freq = checkFreq; if (followModem.load()) { if (lastDemod) { lastDemod->setFrequency(freq); lastDemod->updateLabel(freq); lastDemod->setFollow(true); } } else { wxGetApp().setFrequency((long long)checkFreq); } } else if (wxGetApp().getFrequency() != freq && controlMode.load() && !centerLock.load() && !followModem.load()) { freq = wxGetApp().getFrequency(); rig_set_freq(rig, RIG_VFO_CURR, freq); } else if (followModem.load()) { if (lastDemod) { if (lastDemod->getFrequency() != freq) { lastDemod->setFrequency(freq); lastDemod->updateLabel(freq); lastDemod->setFollow(true); } } } } else { termStatus = 0; break; } } if (!centerLock.load() && followModem.load() && wxGetApp().getFrequency() != freq && (lastDemod && lastDemod != activeDemod)) { wxGetApp().setFrequency((long long)freq); } // std::cout << "Rig Freq: " << freq << std::endl; } rig_close(rig); rig_cleanup(rig); std::cout << "Rig thread exiting status " << termStatus << "." << std::endl; };