/* populate Hamlib serial rate combo box */
- wxString serialRates[] = {"auto", "300", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200"};
- fprintf(stderr, "populating serial rates...\n");
+ wxString serialRates[] = {"default", "300", "1200", "2400", "4800", "9600", "19200", "38400", "57600", "115200"};
for(int i=0; i<WXSIZEOF(serialRates); i++) {
m_cbSerialRate->Append(serialRates[i]);
}
wxGetApp().m_strHamlibSerialPort = m_cbSerialPort->GetValue();
wxString s = m_cbSerialRate->GetValue();
- if (s == "auto") {
+ if (s == "default") {
wxGetApp().m_intHamlibSerialRate = 0;
} else {
m_cbSerialRate->GetValue().ToLong(&tmp);
wxGetApp().m_intHamlibSerialRate = tmp;
}
- fprintf(stderr, "serial rate: %ld\n", tmp);
+ fprintf(stderr, "serial rate: %d\n", wxGetApp().m_intHamlibSerialRate);
pConfig->Write(wxT("/Hamlib/UseForPTT"), wxGetApp().m_boolHamlibUseForPTT);
pConfig->Write(wxT("/Hamlib/RigName"), wxGetApp().m_intHamlibRig);
if (wxGetApp().m_boolHamlibUseForPTT) {
Hamlib *hamlib = wxGetApp().m_hamlib;
+ wxString hamlibError;
if (wxGetApp().m_boolHamlibUseForPTT && hamlib != NULL) {
- hamlib->ptt(g_tx);
+ if (hamlib->ptt(g_tx, hamlibError) == false) {
+ wxMessageBox(wxString("Hamlib PTT Error: ") + hamlibError, wxT("Error"), wxOK | wxICON_ERROR, this);
+ }
}
}
int serial_rate = wxGetApp().m_intHamlibSerialRate;
bool status = wxGetApp().m_hamlib->connect(rig, port.mb_str(wxConvUTF8), serial_rate);
if (status == false)
- wxMessageBox("Couldn't connect to Radio with hamlib", wxT("About"), wxOK | wxICON_ERROR, this);
+ wxMessageBox("Couldn't connect to Radio with hamlib", wxT("Error"), wxOK | wxICON_ERROR, this);
return status;
}
if (wxGetApp().m_boolHamlibUseForPTT) {
Hamlib *hamlib = wxGetApp().m_hamlib;
+ wxString hamlibError;
if (wxGetApp().m_boolHamlibUseForPTT && hamlib != NULL) {
- hamlib->ptt(false);
+ if (hamlib->ptt(false, hamlibError) == false) {
+ wxMessageBox(wxString("Hamlib PTT Error: ") + hamlibError, wxT("Error"), wxOK | wxICON_ERROR, this);
+ }
hamlib->close();
}
}
// always end with PTT in rx state
SerialPTTRx();
-
- closeComPort();
+ closeComPort();
}
}
strncpy(m_rig->state.rigport.pathname, serial_port, FILPATHLEN - 1);
if (serial_rate) {
m_rig->state.rigport.parm.serial.rate = serial_rate;
- fprintf(stderr, "hamlib: setting serial rate: %d\n", serial_rate);
}
+ fprintf(stderr, "hamlib: setting serial rate: %d\n", m_rig->state.rigport.parm.serial.rate);
/*
token_t token = rig_token_lookup(m_rig, "rig_pathname");
return false;
}
-bool Hamlib::ptt(bool press) {
+bool Hamlib::ptt(bool press, wxString &hamlibError) {
fprintf(stderr,"Hamlib::ptt: %d\n", press);
+ hamlibError = "";
if(!m_rig)
return false;
+
/* TODO(Joel): make ON_DATA and ON configurable. */
+
ptt_t on = press ? RIG_PTT_ON : RIG_PTT_OFF;
+
/* TODO(Joel): what should the VFO option be? */
- int status = rig_set_ptt(m_rig, RIG_VFO_CURR, on) == RIG_OK;
- fprintf(stderr,"Hamlib::ptt: rig_set_ptt returned: %d\n", status);
- return status;
+
+ int retcode = rig_set_ptt(m_rig, RIG_VFO_CURR, on);
+ fprintf(stderr,"Hamlib::ptt: rig_set_ptt returned: %d\n", retcode);
+ if (retcode != RIG_OK ) {
+ fprintf(stderr, "rig_set_ptt: error = %s \n", rigerror(retcode));
+ hamlibError = rigerror(retcode);
+ }
+
+ return retcode == RIG_OK;
}
void Hamlib::close(void) {
~Hamlib();
void populateComboBox(wxComboBox *cb);
bool connect(unsigned int rig_index, const char *serial_port, const int serial_rate);
- bool ptt(bool press);
+ bool ptt(bool press, wxString &hamlibError);
void close(void);
typedef std::vector<const struct rig_caps *> riglist_t;