mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-20 19:19:02 -04:00
First attempt at interface to Ham Radio Deluxe (HRD).
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3288 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
3d4f935620
commit
08fb25a57c
83
devsetup.cpp
83
devsetup.cpp
@ -126,6 +126,7 @@ void DevSetup::initDlg()
|
||||
this, SLOT(p4Error()));
|
||||
p4.start("rigctl -l");
|
||||
p4.waitForFinished(1000);
|
||||
ui.rigComboBox->addItem(" 9999 Ham Radio Deluxe");
|
||||
|
||||
QPalette pal(ui.myCallEntry->palette());
|
||||
if(m_myCall=="") {
|
||||
@ -244,6 +245,7 @@ void DevSetup::accept()
|
||||
// Check to see whether SoundInThread must be restarted,
|
||||
// and save user parameters.
|
||||
|
||||
qDebug() << "a";
|
||||
if(m_nDevIn!=ui.comboBoxSndIn->currentIndex() or
|
||||
m_paInDevice!=m_inDevList[m_nDevIn]) m_restartSoundIn=true;
|
||||
|
||||
@ -291,9 +293,12 @@ void DevSetup::accept()
|
||||
m_dFreq.append(ui.f15->text());
|
||||
m_dFreq.append(ui.f16->text());
|
||||
|
||||
qDebug() << "b";
|
||||
|
||||
if(m_bRigOpen) {
|
||||
rig->close();
|
||||
delete rig;
|
||||
if(m_rig!=9999) delete rig;
|
||||
qDebug() << "c";
|
||||
m_bRigOpen=false;
|
||||
}
|
||||
|
||||
@ -436,31 +441,34 @@ void DevSetup::on_testCATButton_clicked()
|
||||
if(!m_catEnabled) return;
|
||||
if(m_bRigOpen) {
|
||||
rig->close();
|
||||
delete rig;
|
||||
if(m_rig!=9999) delete rig;
|
||||
m_bRigOpen=false;
|
||||
}
|
||||
|
||||
rig = new Rig();
|
||||
if (!rig->init(m_rig)) {
|
||||
if(m_rig != 9999) {
|
||||
if (!rig->init(m_rig)) {
|
||||
msgBox("Rig init failure");
|
||||
return;
|
||||
}
|
||||
|
||||
rig->setConf("rig_pathname", m_catPort.toAscii().data());
|
||||
char buf[80];
|
||||
sprintf(buf,"%d",m_serialRate);
|
||||
rig->setConf("serial_speed",buf);
|
||||
sprintf(buf,"%d",m_dataBits);
|
||||
rig->setConf("data_bits",buf);
|
||||
sprintf(buf,"%d",m_stopBits);
|
||||
rig->setConf("stop_bits",buf);
|
||||
rig->setConf("serial_handshake",m_handshake.toAscii().data());
|
||||
|
||||
if(m_bDTRoff) {
|
||||
rig->setConf("rts_state","OFF");
|
||||
rig->setConf("dtr_state","OFF");
|
||||
}
|
||||
}
|
||||
|
||||
rig->setConf("rig_pathname", m_catPort.toAscii().data());
|
||||
char buf[80];
|
||||
sprintf(buf,"%d",m_serialRate);
|
||||
rig->setConf("serial_speed",buf);
|
||||
sprintf(buf,"%d",m_dataBits);
|
||||
rig->setConf("data_bits",buf);
|
||||
sprintf(buf,"%d",m_stopBits);
|
||||
rig->setConf("stop_bits",buf);
|
||||
rig->setConf("serial_handshake",m_handshake.toAscii().data());
|
||||
|
||||
if(m_bDTRoff) {
|
||||
rig->setConf("rts_state","OFF");
|
||||
rig->setConf("dtr_state","OFF");
|
||||
}
|
||||
|
||||
ret=rig->open();
|
||||
ret=rig->open(m_rig);
|
||||
if(ret==RIG_OK) {
|
||||
m_bRigOpen=true;
|
||||
} else {
|
||||
@ -530,3 +538,40 @@ void DevSetup::on_pttMethodComboBox_currentIndexChanged(int index)
|
||||
bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2;
|
||||
ui.pttComboBox->setEnabled(b);
|
||||
}
|
||||
|
||||
void DevSetup::on_pbHRD_clicked()
|
||||
{
|
||||
|
||||
bool bConnect=false;
|
||||
bConnect = HRDInterfaceConnect(L"localhost",7809);
|
||||
if(bConnect) {
|
||||
QString t2;
|
||||
|
||||
const wchar_t* context=HRDInterfaceSendMessage(L"Get Context");
|
||||
QString qc="[" + QString::fromWCharArray (context,-1) + "] ";
|
||||
|
||||
const wchar_t* cmnd = (const wchar_t*) (qc+"Get Frequency").utf16();
|
||||
const wchar_t* freqString=HRDInterfaceSendMessage(cmnd);
|
||||
t2=QString::fromWCharArray (freqString,-1);
|
||||
qDebug() << "Freq1:" << t2;
|
||||
|
||||
cmnd = (const wchar_t*) (qc+"Set Frequency-Hz 14070000").utf16();
|
||||
const wchar_t* result=HRDInterfaceSendMessage(cmnd);
|
||||
t2=QString::fromWCharArray (result,-1);
|
||||
qDebug() << "Freq2:" << t2;
|
||||
|
||||
cmnd = (const wchar_t*) (qc+"Get Frequency").utf16();
|
||||
freqString=HRDInterfaceSendMessage(cmnd);
|
||||
t2=QString::fromWCharArray (freqString,-1);
|
||||
qDebug() << "Freq3:" << t2;
|
||||
|
||||
|
||||
HRDInterfaceDisconnect();
|
||||
bConnect = HRDInterfaceIsConnected();
|
||||
HRDInterfaceFreeString(context);
|
||||
HRDInterfaceFreeString(freqString);
|
||||
HRDInterfaceFreeString(cmnd);
|
||||
} else {
|
||||
qDebug() << "Connection to HRD failed.";
|
||||
}
|
||||
}
|
||||
|
10
devsetup.h
10
devsetup.h
@ -93,6 +93,8 @@ private slots:
|
||||
|
||||
void on_pttMethodComboBox_currentIndexChanged(int index);
|
||||
|
||||
void on_pbHRD_clicked();
|
||||
|
||||
private:
|
||||
Rig* rig;
|
||||
void msgBox(QString t);
|
||||
@ -101,4 +103,12 @@ private:
|
||||
|
||||
extern int ptt(int nport, int ntx, int* iptt, int* nopen);
|
||||
|
||||
extern "C" {
|
||||
const bool HRDInterfaceConnect(const wchar_t *host, const ushort);
|
||||
void HRDInterfaceDisconnect();
|
||||
const bool HRDInterfaceIsConnected();
|
||||
const wchar_t* HRDInterfaceSendMessage(const wchar_t *msg);
|
||||
void HRDInterfaceFreeString(const wchar_t *lstring);
|
||||
}
|
||||
|
||||
#endif // DEVSETUP_H
|
||||
|
@ -104,6 +104,13 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbHRD">
|
||||
<property name="text">
|
||||
<string>HRD</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
|
BIN
libHRDInterface001.a
Normal file
BIN
libHRDInterface001.a
Normal file
Binary file not shown.
@ -716,6 +716,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
|
||||
}
|
||||
}
|
||||
m_catEnabled=dlg.m_catEnabled;
|
||||
|
||||
if(m_catEnabled) {
|
||||
rigOpen();
|
||||
}
|
||||
@ -2773,11 +2774,12 @@ void MainWindow::rigOpen()
|
||||
{
|
||||
QString t;
|
||||
int ret;
|
||||
|
||||
rig = new Rig();
|
||||
if (!rig->init(m_rig)) {
|
||||
if(m_rig != 9999) {
|
||||
if (!rig->init(m_rig)) {
|
||||
msgBox("Rig init failure");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rig->setConf("rig_pathname", m_catPort.toAscii().data());
|
||||
@ -2793,7 +2795,7 @@ void MainWindow::rigOpen()
|
||||
rig->setConf("rts_state","OFF");
|
||||
rig->setConf("dtr_state","OFF");
|
||||
}
|
||||
ret=rig->open();
|
||||
ret=rig->open(m_rig);
|
||||
if(ret==RIG_OK) {
|
||||
m_bRigOpen=true;
|
||||
if(m_poll==0) ui->readFreq->setEnabled(true);
|
||||
|
56
rigclass.cpp
56
rigclass.cpp
@ -35,6 +35,7 @@
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include "rigclass.h"
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg);
|
||||
@ -76,12 +77,31 @@ int Rig::init(rig_model_t rig_model)
|
||||
return initOk;
|
||||
}
|
||||
|
||||
int Rig::open(void) {
|
||||
return rig_open(theRig);
|
||||
int Rig::open(int n) {
|
||||
m_hrd=(n==9999);
|
||||
if(m_hrd) {
|
||||
bool bConnect=false;
|
||||
bConnect = HRDInterfaceConnect(L"localhost",7809);
|
||||
if(bConnect) {
|
||||
const wchar_t* context=HRDInterfaceSendMessage(L"Get Context");
|
||||
m_context="[" + QString::fromWCharArray (context,-1) + "] ";
|
||||
return 0;
|
||||
} else {
|
||||
m_hrd=false;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return rig_open(theRig);
|
||||
}
|
||||
}
|
||||
|
||||
int Rig::close(void) {
|
||||
return rig_close(theRig);
|
||||
if(m_hrd) {
|
||||
HRDInterfaceDisconnect();
|
||||
|
||||
} else {
|
||||
return rig_close(theRig);
|
||||
}
|
||||
}
|
||||
|
||||
int Rig::setConf(const char *name, const char *val)
|
||||
@ -90,14 +110,38 @@ int Rig::setConf(const char *name, const char *val)
|
||||
}
|
||||
|
||||
int Rig::setFreq(freq_t freq, vfo_t vfo) {
|
||||
return rig_set_freq(theRig, vfo, freq);
|
||||
if(m_hrd) {
|
||||
QString t;
|
||||
int nhz=(int)freq;
|
||||
t=m_context + "Set Frequency-Hz " + QString::number(nhz);
|
||||
qDebug() << "a" << freq << nhz << t;
|
||||
const wchar_t* cmnd = (const wchar_t*) t.utf16();
|
||||
const wchar_t* result=HRDInterfaceSendMessage(cmnd);
|
||||
QString t2=QString::fromWCharArray (result,-1);
|
||||
if(t2=="OK") {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return rig_set_freq(theRig, vfo, freq);
|
||||
}
|
||||
}
|
||||
|
||||
freq_t Rig::getFreq(vfo_t vfo)
|
||||
{
|
||||
freq_t freq;
|
||||
rig_get_freq(theRig, vfo, &freq);
|
||||
return freq;
|
||||
if(m_hrd) {
|
||||
const wchar_t* cmnd = (const wchar_t*) (m_context+"Get Frequency").utf16();
|
||||
const wchar_t* freqString=HRDInterfaceSendMessage(cmnd);
|
||||
QString t2=QString::fromWCharArray (freqString,-1);
|
||||
HRDInterfaceFreeString(freqString);
|
||||
freq=t2.toDouble();
|
||||
return freq;
|
||||
} else {
|
||||
rig_get_freq(theRig, vfo, &freq);
|
||||
return freq;
|
||||
}
|
||||
}
|
||||
|
||||
int Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo) {
|
||||
|
13
rigclass.h
13
rigclass.h
@ -24,11 +24,13 @@
|
||||
|
||||
#include <hamlib/rig.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <QString>
|
||||
|
||||
class BACKEND_IMPEXP Rig {
|
||||
private:
|
||||
RIG* theRig; // Global ref. to the rig
|
||||
bool m_hrd;
|
||||
QString m_context;
|
||||
|
||||
protected:
|
||||
public:
|
||||
@ -41,7 +43,7 @@ public:
|
||||
int init(rig_model_t rig_model);
|
||||
|
||||
// This method open the communication port to the rig
|
||||
int open(void);
|
||||
int open(int n);
|
||||
|
||||
// This method close the communication port to the rig
|
||||
int close(void);
|
||||
@ -77,5 +79,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
const bool HRDInterfaceConnect(const wchar_t *host, const ushort);
|
||||
void HRDInterfaceDisconnect();
|
||||
const bool HRDInterfaceIsConnected();
|
||||
const wchar_t* HRDInterfaceSendMessage(const wchar_t *msg);
|
||||
void HRDInterfaceFreeString(const wchar_t *lstring);
|
||||
}
|
||||
|
||||
#endif // _RIGCLASS_H
|
||||
|
@ -66,6 +66,7 @@ LIBS += ../../hamlib-1.2.15.3/src/.libs/libhamlib.dll.a
|
||||
LIBS += ../wsjtx/lib/libjt9.a
|
||||
LIBS += ../wsjtx/libfftw3f_win.a
|
||||
LIBS += ../wsjtx/libpskreporter.a
|
||||
LIBS += ../wsjtx/libHRDInterface001.a
|
||||
LIBS += ../QtSupport/palir-02.dll
|
||||
LIBS += libwsock32
|
||||
LIBS += C:/MinGW/lib/libf95.a
|
||||
|
Loading…
Reference in New Issue
Block a user