mirror of https://github.com/saitohirga/WSJT-X.git
1. CAT control now working with calls to hamlib functions.
Needs testing!!! 2. Added "Test CAT Control" and "Test PTT" buttons on Setup | Configuration screen. (Must fix flaky behavior of calls to ptt().) git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3172 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
7bc09300eb
commit
b02d298518
38
devsetup.cpp
38
devsetup.cpp
|
@ -14,6 +14,9 @@ DevSetup::DevSetup(QWidget *parent) : QDialog(parent)
|
||||||
m_restartSoundIn=false;
|
m_restartSoundIn=false;
|
||||||
m_restartSoundOut=false;
|
m_restartSoundOut=false;
|
||||||
m_firstCall=true;
|
m_firstCall=true;
|
||||||
|
m_count=0;
|
||||||
|
m_iptt=0;
|
||||||
|
m_bRigOpen=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DevSetup::~DevSetup()
|
DevSetup::~DevSetup()
|
||||||
|
@ -369,3 +372,38 @@ void DevSetup::on_cbID73_toggled(bool checked)
|
||||||
{
|
{
|
||||||
m_After73=checked;
|
m_After73=checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevSetup::on_testCATButton_clicked()
|
||||||
|
{
|
||||||
|
if(!m_catEnabled) return;
|
||||||
|
if(!m_bRigOpen) {
|
||||||
|
QString conf_parms;
|
||||||
|
conf_parms.sprintf("data_bits=%d,stop_bits=%d,serial_handshake=",
|
||||||
|
m_dataBits,m_stopBits);
|
||||||
|
conf_parms+=m_handshake;
|
||||||
|
int iret=rigOpen(0,m_rig,m_catPort.toAscii().data(),m_serialRate,
|
||||||
|
conf_parms.toAscii().data());
|
||||||
|
if(iret!=0) {
|
||||||
|
msgBox("Failed to open connection to radio.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bRigOpen=true;
|
||||||
|
}
|
||||||
|
m_count=1-m_count;
|
||||||
|
int freq=10130000;
|
||||||
|
if(m_count!=1) freq=14078000;
|
||||||
|
rigSetFreq(freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevSetup::on_testPTTButton_clicked()
|
||||||
|
{
|
||||||
|
int iret=0;
|
||||||
|
m_iptt=1-m_iptt;
|
||||||
|
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
|
||||||
|
int iptt=m_iptt;
|
||||||
|
ptt(m_pttPort,iptt,&m_iptt,&m_COMportOpen);
|
||||||
|
}
|
||||||
|
if(m_pttMethodIndex==0 and m_bRigOpen) {
|
||||||
|
iret=rigSetPTT(m_iptt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,9 @@ public:
|
||||||
qint32 m_stopBits;
|
qint32 m_stopBits;
|
||||||
qint32 m_stopBitsIndex;
|
qint32 m_stopBitsIndex;
|
||||||
qint32 m_handshakeIndex;
|
qint32 m_handshakeIndex;
|
||||||
|
qint32 m_count;
|
||||||
|
qint32 m_iptt;
|
||||||
|
qint32 m_COMportOpen;
|
||||||
|
|
||||||
bool m_restartSoundIn;
|
bool m_restartSoundIn;
|
||||||
bool m_restartSoundOut;
|
bool m_restartSoundOut;
|
||||||
|
@ -41,6 +44,7 @@ public:
|
||||||
bool m_firstCall;
|
bool m_firstCall;
|
||||||
bool m_catEnabled;
|
bool m_catEnabled;
|
||||||
bool m_After73;
|
bool m_After73;
|
||||||
|
bool m_bRigOpen;
|
||||||
|
|
||||||
QString m_myCall;
|
QString m_myCall;
|
||||||
QString m_myGrid;
|
QString m_myGrid;
|
||||||
|
@ -74,6 +78,9 @@ private slots:
|
||||||
void on_stopBitsComboBox_activated(int index);
|
void on_stopBitsComboBox_activated(int index);
|
||||||
void on_rigComboBox_activated(int index);
|
void on_rigComboBox_activated(int index);
|
||||||
void on_cbID73_toggled(bool checked);
|
void on_cbID73_toggled(bool checked);
|
||||||
|
void on_testCATButton_clicked();
|
||||||
|
|
||||||
|
void on_testPTTButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void msgBox(QString t);
|
void msgBox(QString t);
|
||||||
|
|
2051
devsetup.ui
2051
devsetup.ui
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@ int set_conf(RIG *my_rig, char *conf_parms);
|
||||||
int set_conf(RIG *my_rig, char *conf_parms)
|
int set_conf(RIG *my_rig, char *conf_parms)
|
||||||
{
|
{
|
||||||
char *p, *q, *n;
|
char *p, *q, *n;
|
||||||
int ret;
|
int iret;
|
||||||
|
|
||||||
p = conf_parms;
|
p = conf_parms;
|
||||||
while (p && *p != '\0') {
|
while (p && *p != '\0') {
|
||||||
|
@ -26,38 +26,40 @@ int set_conf(RIG *my_rig, char *conf_parms)
|
||||||
|
|
||||||
printf("%s %s\n",p,q);
|
printf("%s %s\n",p,q);
|
||||||
|
|
||||||
ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
|
iret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
|
||||||
if (ret != RIG_OK)
|
if (iret != RIG_OK)
|
||||||
return ret;
|
return iret;
|
||||||
p = n;
|
p = n;
|
||||||
}
|
}
|
||||||
return RIG_OK;
|
return RIG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
int rigOpen(rig_model_t my_model, int verbose)
|
int rigOpen(int verbose, rig_model_t my_model, const char* rig_file,
|
||||||
|
int serial_rate, const char* conf_parms2)
|
||||||
{
|
{
|
||||||
int retcode; /* generic return code from functions */
|
int iret; /* generic return code from functions */
|
||||||
char *civaddr = NULL; /* NULL means no need to set conf */
|
char *civaddr = NULL; /* NULL means no need to set conf */
|
||||||
const char *rig_file;
|
// const char *rig_file;
|
||||||
const char *conf_parms2;
|
// const char *conf_parms2;
|
||||||
int serial_rate;
|
// int serial_rate;
|
||||||
|
|
||||||
rig_set_debug(verbose);
|
rig_set_debug(verbose);
|
||||||
my_rig=rig_init(my_model);
|
my_rig=rig_init(my_model);
|
||||||
|
|
||||||
if (!my_rig) {
|
if (!my_rig) {
|
||||||
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",my_model);
|
// fprintf(stderr, "Unknown rig num %d, or initialization error.\n",my_model);
|
||||||
exit(2);
|
return -1;
|
||||||
}
|
}
|
||||||
rig_file="COM1";
|
|
||||||
serial_rate=4800;
|
|
||||||
conf_parms2="data_bits=8,stop_bits=2,serial_handshake=Hardware";
|
|
||||||
|
|
||||||
retcode=set_conf(my_rig, conf_parms2);
|
// rig_file="COM1";
|
||||||
if (retcode!=RIG_OK) {
|
// serial_rate=4800;
|
||||||
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
|
// conf_parms2="data_bits=8,stop_bits=2,serial_handshake=Hardware";
|
||||||
exit(2);
|
|
||||||
|
iret=set_conf(my_rig, conf_parms2);
|
||||||
|
if (iret!=RIG_OK) {
|
||||||
|
// fprintf(stderr, "Config parameter error: %s\n", rigerror(iret));
|
||||||
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rig_file)
|
if (rig_file)
|
||||||
|
@ -69,7 +71,8 @@ int rigOpen(rig_model_t my_model, int verbose)
|
||||||
if (civaddr)
|
if (civaddr)
|
||||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
|
||||||
|
|
||||||
retcode = rig_open(my_rig);
|
iret = rig_open(my_rig);
|
||||||
|
if(iret!=0) return -3;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,17 +81,18 @@ int rigSetFreq(int fHz)
|
||||||
return rig_set_freq(my_rig,RIG_VFO_CURR,fHz);
|
return rig_set_freq(my_rig,RIG_VFO_CURR,fHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rigFreq()
|
int rigFreq(int *fHz)
|
||||||
{
|
{
|
||||||
int iret=0;
|
int iret=0;
|
||||||
freq_t freq;
|
freq_t freq;
|
||||||
iret=rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
iret=rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
|
||||||
if (iret == RIG_OK ) {
|
*fHz=freq;
|
||||||
printf("rig_get_freq: freq = %"PRIfreq"\n", freq);
|
return iret;
|
||||||
} else {
|
}
|
||||||
printf("rig_get_freq: error = %s \n", rigerror(iret));
|
|
||||||
}
|
int rigSetPTT(int iptt)
|
||||||
return freq;
|
{
|
||||||
|
return rig_set_ptt(my_rig, RIG_VFO_CURR, iptt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rigClose()
|
void rigClose()
|
||||||
|
|
|
@ -177,6 +177,7 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
|
||||||
m_watchdogLimit=5;
|
m_watchdogLimit=5;
|
||||||
m_tune=false;
|
m_tune=false;
|
||||||
m_repeatMsg=0;
|
m_repeatMsg=0;
|
||||||
|
m_bRigOpen=false;
|
||||||
decodeBusy(false);
|
decodeBusy(false);
|
||||||
|
|
||||||
ui->xThermo->setFillBrush(Qt::green);
|
ui->xThermo->setFillBrush(Qt::green);
|
||||||
|
@ -285,6 +286,23 @@ MainWindow::MainWindow(QSharedMemory *shdmem, QWidget *parent) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//###
|
||||||
|
if(m_catEnabled) {
|
||||||
|
QString conf_parms;
|
||||||
|
conf_parms.sprintf("data_bits=%d,stop_bits=%d,serial_handshake=",
|
||||||
|
m_dataBits,m_stopBits);
|
||||||
|
conf_parms+=m_handshake;
|
||||||
|
int iret=rigOpen(0,m_rig,m_catPort.toAscii().data(),m_serialRate,
|
||||||
|
conf_parms.toAscii().data());
|
||||||
|
if(iret!=0) {
|
||||||
|
msgBox("Failed to open connection to radio.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_bRigOpen=true;
|
||||||
|
}
|
||||||
|
//###
|
||||||
|
|
||||||
} // End of MainWindow constructor
|
} // End of MainWindow constructor
|
||||||
|
|
||||||
//--------------------------------------------------- MainWindow destructor
|
//--------------------------------------------------- MainWindow destructor
|
||||||
|
@ -599,6 +617,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
|
||||||
dlg.m_stopBitsIndex=m_stopBitsIndex;
|
dlg.m_stopBitsIndex=m_stopBitsIndex;
|
||||||
dlg.m_handshake=m_handshake;
|
dlg.m_handshake=m_handshake;
|
||||||
dlg.m_handshakeIndex=m_handshakeIndex;
|
dlg.m_handshakeIndex=m_handshakeIndex;
|
||||||
|
dlg.m_bRigOpen=m_bRigOpen;
|
||||||
|
|
||||||
dlg.initDlg();
|
dlg.initDlg();
|
||||||
if(dlg.exec() == QDialog::Accepted) {
|
if(dlg.exec() == QDialog::Accepted) {
|
||||||
|
@ -627,6 +646,7 @@ void MainWindow::on_actionDeviceSetup_triggered() //Setup Dialog
|
||||||
m_stopBitsIndex=dlg.m_stopBitsIndex;
|
m_stopBitsIndex=dlg.m_stopBitsIndex;
|
||||||
m_handshake=dlg.m_handshake;
|
m_handshake=dlg.m_handshake;
|
||||||
m_handshakeIndex=dlg.m_handshakeIndex;
|
m_handshakeIndex=dlg.m_handshakeIndex;
|
||||||
|
m_bRigOpen=dlg.m_bRigOpen;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if(dlg.m_pskReporter!=m_pskReporter) {
|
if(dlg.m_pskReporter!=m_pskReporter) {
|
||||||
|
@ -1406,8 +1426,8 @@ void MainWindow::guiUpdate()
|
||||||
//Raise PTT
|
//Raise PTT
|
||||||
if(m_pttMethodIndex==0) { //CAT control for PTT
|
if(m_pttMethodIndex==0) { //CAT control for PTT
|
||||||
m_cmnd=rig_command() + " T 1";
|
m_cmnd=rig_command() + " T 1";
|
||||||
p3.start(m_cmnd);
|
// p3.start(m_cmnd);
|
||||||
p3.waitForFinished();
|
// p3.waitForFinished();
|
||||||
m_iptt=1;
|
m_iptt=1;
|
||||||
}
|
}
|
||||||
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR or RTS
|
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR or RTS
|
||||||
|
@ -1539,8 +1559,8 @@ void MainWindow::guiUpdate()
|
||||||
//Lower PTT
|
//Lower PTT
|
||||||
if(m_pttMethodIndex==0) { //CAT
|
if(m_pttMethodIndex==0) { //CAT
|
||||||
m_cmnd=rig_command() + " T 0";
|
m_cmnd=rig_command() + " T 0";
|
||||||
p3.start(m_cmnd);
|
// p3.start(m_cmnd);
|
||||||
p3.waitForFinished();
|
// p3.waitForFinished();
|
||||||
}
|
}
|
||||||
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR-RTS
|
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) { //DTR-RTS
|
||||||
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
|
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
|
||||||
|
@ -1598,12 +1618,20 @@ void MainWindow::guiUpdate()
|
||||||
}
|
}
|
||||||
m_hsym0=khsym;
|
m_hsym0=khsym;
|
||||||
m_sec0=nsec;
|
m_sec0=nsec;
|
||||||
|
/*
|
||||||
if(m_catEnabled) {
|
if(m_catEnabled) {
|
||||||
m_cmnd=rig_command() + " f";
|
m_cmnd=rig_command() + " f";
|
||||||
p3.start(m_cmnd);
|
p3.start(m_cmnd);
|
||||||
p3.waitForFinished();
|
p3.waitForFinished();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
if(m_bRigOpen) {
|
||||||
|
int fHz;
|
||||||
|
int iret=rigFreq(&fHz);
|
||||||
|
double fMHz=fHz/1000000.0;
|
||||||
|
int d=1000000.0*(fMHz-m_dialFreq);
|
||||||
|
if(abs(d)>0) dialFreqChanged2(fMHz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
iptt0=m_iptt;
|
iptt0=m_iptt;
|
||||||
|
@ -1675,8 +1703,8 @@ void MainWindow::stopTx2()
|
||||||
//Lower PTT
|
//Lower PTT
|
||||||
if(m_pttMethodIndex==0) {
|
if(m_pttMethodIndex==0) {
|
||||||
m_cmnd=rig_command() + " T 0";
|
m_cmnd=rig_command() + " T 0";
|
||||||
p3.start(m_cmnd);
|
// p3.start(m_cmnd);
|
||||||
p3.waitForFinished();
|
// p3.waitForFinished();
|
||||||
}
|
}
|
||||||
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
|
if(m_pttMethodIndex==1 or m_pttMethodIndex==2) {
|
||||||
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
|
ptt(m_pttPort,0,&m_iptt,&m_COMportOpen);
|
||||||
|
@ -2407,8 +2435,9 @@ void MainWindow::on_bandComboBox_currentIndexChanged(int index)
|
||||||
m_dialFreq=t.toDouble();
|
m_dialFreq=t.toDouble();
|
||||||
dialFreqChanged2(m_dialFreq);
|
dialFreqChanged2(m_dialFreq);
|
||||||
m_repeatMsg=0;
|
m_repeatMsg=0;
|
||||||
|
int nHz=int(1000000.0*m_dialFreq + 0.5);
|
||||||
|
/*
|
||||||
if(m_catEnabled) {
|
if(m_catEnabled) {
|
||||||
int nHz=int(1000000.0*m_dialFreq + 0.5);
|
|
||||||
QString cmnd1,cmnd3;
|
QString cmnd1,cmnd3;
|
||||||
cmnd1=rig_command();
|
cmnd1=rig_command();
|
||||||
cmnd3.sprintf(" F %d",nHz);
|
cmnd3.sprintf(" F %d",nHz);
|
||||||
|
@ -2416,6 +2445,9 @@ void MainWindow::on_bandComboBox_currentIndexChanged(int index)
|
||||||
p3.start(m_cmnd);
|
p3.start(m_cmnd);
|
||||||
p3.waitForFinished();
|
p3.waitForFinished();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(m_bRigOpen) rigSetFreq(nHz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionPrompt_to_log_QSO_triggered(bool checked)
|
void MainWindow::on_actionPrompt_to_log_QSO_triggered(bool checked)
|
||||||
|
|
11
mainwindow.h
11
mainwindow.h
|
@ -247,6 +247,7 @@ private:
|
||||||
bool m_runaway;
|
bool m_runaway;
|
||||||
bool m_tx2QSO;
|
bool m_tx2QSO;
|
||||||
bool m_tune;
|
bool m_tune;
|
||||||
|
bool m_bRigOpen;
|
||||||
|
|
||||||
char m_decoded[80];
|
char m_decoded[80];
|
||||||
|
|
||||||
|
@ -341,7 +342,7 @@ extern int killbyname(const char* progName);
|
||||||
extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
|
extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
|
||||||
int minChan[], int maxChan[],
|
int minChan[], int maxChan[],
|
||||||
int minSpeed[], int maxSpeed[]);
|
int minSpeed[], int maxSpeed[]);
|
||||||
extern int ptt(int nport, int itx, int* iptt);
|
extern int ptt(int nport, int itx, int* iptt, int* nopen);
|
||||||
//extern int ReporterInitialize(char* hostname, char* port);
|
//extern int ReporterInitialize(char* hostname, char* port);
|
||||||
|
|
||||||
|
|
||||||
|
@ -365,9 +366,13 @@ void morse_(char* msg, int* icw, int* ncw, int len);
|
||||||
|
|
||||||
//void rig_control(int nrig, int verbose);
|
//void rig_control(int nrig, int verbose);
|
||||||
|
|
||||||
int rigOpen(int nrig, int verbose);
|
int rigOpen(int vervose, int nrig, const char* rig_file, int serial_rate,
|
||||||
|
const char* conf_parms);
|
||||||
|
|
||||||
void rigSetFreq(int fHz);
|
void rigSetFreq(int fHz);
|
||||||
int rigFreq();
|
int rigFreq(int *fHz);
|
||||||
|
int rigSetPTT(int iptt);
|
||||||
|
void rigClose();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2097,7 +2097,7 @@ answer callers</string>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDeviceSetup">
|
<action name="actionDeviceSetup">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Configuration</string>
|
<string>Configuration</string>
|
||||||
|
|
Loading…
Reference in New Issue