mirror of
				https://github.com/saitohirga/WSJT-X.git
				synced 2025-10-30 20:40:28 -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
					
				
							
								
								
									
										51
									
								
								devsetup.cpp
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								devsetup.cpp
									
									
									
									
									
								
							| @ -126,6 +126,7 @@ void DevSetup::initDlg() | |||||||
|           this, SLOT(p4Error())); |           this, SLOT(p4Error())); | ||||||
|   p4.start("rigctl -l"); |   p4.start("rigctl -l"); | ||||||
|   p4.waitForFinished(1000); |   p4.waitForFinished(1000); | ||||||
|  |   ui.rigComboBox->addItem("  9999 Ham Radio Deluxe"); | ||||||
| 
 | 
 | ||||||
|   QPalette pal(ui.myCallEntry->palette()); |   QPalette pal(ui.myCallEntry->palette()); | ||||||
|   if(m_myCall=="") { |   if(m_myCall=="") { | ||||||
| @ -244,6 +245,7 @@ void DevSetup::accept() | |||||||
|   // Check to see whether SoundInThread must be restarted,
 |   // Check to see whether SoundInThread must be restarted,
 | ||||||
|   // and save user parameters.
 |   // and save user parameters.
 | ||||||
| 
 | 
 | ||||||
|  |   qDebug() << "a"; | ||||||
|   if(m_nDevIn!=ui.comboBoxSndIn->currentIndex() or |   if(m_nDevIn!=ui.comboBoxSndIn->currentIndex() or | ||||||
|      m_paInDevice!=m_inDevList[m_nDevIn]) m_restartSoundIn=true; |      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.f15->text()); | ||||||
|   m_dFreq.append(ui.f16->text()); |   m_dFreq.append(ui.f16->text()); | ||||||
| 
 | 
 | ||||||
|  |   qDebug() << "b"; | ||||||
|  | 
 | ||||||
|   if(m_bRigOpen) { |   if(m_bRigOpen) { | ||||||
|     rig->close(); |     rig->close(); | ||||||
|     delete rig; |     if(m_rig!=9999) delete rig; | ||||||
|  |     qDebug() << "c"; | ||||||
|     m_bRigOpen=false; |     m_bRigOpen=false; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -436,10 +441,12 @@ void DevSetup::on_testCATButton_clicked() | |||||||
|   if(!m_catEnabled) return; |   if(!m_catEnabled) return; | ||||||
|   if(m_bRigOpen) { |   if(m_bRigOpen) { | ||||||
|     rig->close(); |     rig->close(); | ||||||
|     delete rig; |     if(m_rig!=9999) delete rig; | ||||||
|     m_bRigOpen=false; |     m_bRigOpen=false; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|   rig = new Rig(); |   rig = new Rig(); | ||||||
|  |   if(m_rig != 9999) { | ||||||
|     if (!rig->init(m_rig)) { |     if (!rig->init(m_rig)) { | ||||||
|       msgBox("Rig init failure"); |       msgBox("Rig init failure"); | ||||||
|       return; |       return; | ||||||
| @ -459,8 +466,9 @@ void DevSetup::on_testCATButton_clicked() | |||||||
|       rig->setConf("rts_state","OFF"); |       rig->setConf("rts_state","OFF"); | ||||||
|       rig->setConf("dtr_state","OFF"); |       rig->setConf("dtr_state","OFF"); | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   ret=rig->open(); |   ret=rig->open(m_rig); | ||||||
|   if(ret==RIG_OK) { |   if(ret==RIG_OK) { | ||||||
|     m_bRigOpen=true; |     m_bRigOpen=true; | ||||||
|   } else { |   } else { | ||||||
| @ -530,3 +538,40 @@ void DevSetup::on_pttMethodComboBox_currentIndexChanged(int index) | |||||||
|   bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2; |   bool b=m_pttMethodIndex==1 or m_pttMethodIndex==2; | ||||||
|   ui.pttComboBox->setEnabled(b); |   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_pttMethodComboBox_currentIndexChanged(int index); | ||||||
| 
 | 
 | ||||||
|  |   void on_pbHRD_clicked(); | ||||||
|  | 
 | ||||||
| private: | private: | ||||||
|   Rig* rig; |   Rig* rig; | ||||||
|   void msgBox(QString t); |   void msgBox(QString t); | ||||||
| @ -101,4 +103,12 @@ private: | |||||||
| 
 | 
 | ||||||
| extern int ptt(int nport, int ntx, int* iptt, int* nopen); | 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
 | #endif // DEVSETUP_H
 | ||||||
|  | |||||||
| @ -104,6 +104,13 @@ | |||||||
|            </property> |            </property> | ||||||
|           </spacer> |           </spacer> | ||||||
|          </item> |          </item> | ||||||
|  |          <item> | ||||||
|  |           <widget class="QPushButton" name="pbHRD"> | ||||||
|  |            <property name="text"> | ||||||
|  |             <string>HRD</string> | ||||||
|  |            </property> | ||||||
|  |           </widget> | ||||||
|  |          </item> | ||||||
|          <item> |          <item> | ||||||
|           <widget class="QLabel" name="label_2"> |           <widget class="QLabel" name="label_2"> | ||||||
|            <property name="sizePolicy"> |            <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; |   m_catEnabled=dlg.m_catEnabled; | ||||||
|  | 
 | ||||||
|   if(m_catEnabled) { |   if(m_catEnabled) { | ||||||
|     rigOpen(); |     rigOpen(); | ||||||
|   } |   } | ||||||
| @ -2773,12 +2774,13 @@ void MainWindow::rigOpen() | |||||||
| { | { | ||||||
|   QString t; |   QString t; | ||||||
|   int ret; |   int ret; | ||||||
| 
 |  | ||||||
|   rig = new Rig(); |   rig = new Rig(); | ||||||
|  |   if(m_rig != 9999) { | ||||||
|     if (!rig->init(m_rig)) { |     if (!rig->init(m_rig)) { | ||||||
|       msgBox("Rig init failure"); |       msgBox("Rig init failure"); | ||||||
|       return; |       return; | ||||||
|     } |     } | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   rig->setConf("rig_pathname", m_catPort.toAscii().data()); |   rig->setConf("rig_pathname", m_catPort.toAscii().data()); | ||||||
|   char buf[80]; |   char buf[80]; | ||||||
| @ -2793,7 +2795,7 @@ void MainWindow::rigOpen() | |||||||
|     rig->setConf("rts_state","OFF"); |     rig->setConf("rts_state","OFF"); | ||||||
|     rig->setConf("dtr_state","OFF"); |     rig->setConf("dtr_state","OFF"); | ||||||
|   } |   } | ||||||
|   ret=rig->open(); |   ret=rig->open(m_rig); | ||||||
|   if(ret==RIG_OK) { |   if(ret==RIG_OK) { | ||||||
|     m_bRigOpen=true; |     m_bRigOpen=true; | ||||||
|     if(m_poll==0) ui->readFreq->setEnabled(true); |     if(m_poll==0) ui->readFreq->setEnabled(true); | ||||||
|  | |||||||
							
								
								
									
										46
									
								
								rigclass.cpp
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								rigclass.cpp
									
									
									
									
									
								
							| @ -35,6 +35,7 @@ | |||||||
| 
 | 
 | ||||||
| #include <hamlib/rig.h> | #include <hamlib/rig.h> | ||||||
| #include "rigclass.h" | #include "rigclass.h" | ||||||
|  | #include <QDebug> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg); | static int hamlibpp_freq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg); | ||||||
| @ -76,13 +77,32 @@ int Rig::init(rig_model_t rig_model) | |||||||
|     return initOk; |     return initOk; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int Rig::open(void) { | 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); |     return rig_open(theRig); | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| int Rig::close(void) { | int Rig::close(void) { | ||||||
|  |   if(m_hrd) { | ||||||
|  |     HRDInterfaceDisconnect(); | ||||||
|  | 
 | ||||||
|  |   } else { | ||||||
|     return rig_close(theRig); |     return rig_close(theRig); | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| int Rig::setConf(const char *name, const char *val) | int Rig::setConf(const char *name, const char *val) | ||||||
| { | { | ||||||
| @ -90,15 +110,39 @@ int Rig::setConf(const char *name, const char *val) | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| int Rig::setFreq(freq_t freq, vfo_t vfo) { | int Rig::setFreq(freq_t freq, vfo_t vfo) { | ||||||
|  |   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); |     return rig_set_freq(theRig, vfo, freq); | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| freq_t Rig::getFreq(vfo_t vfo) | freq_t Rig::getFreq(vfo_t vfo) | ||||||
| { | { | ||||||
|   freq_t freq; |   freq_t 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); |     rig_get_freq(theRig, vfo, &freq); | ||||||
|     return freq; |     return freq; | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| int Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo) { | int Rig::setMode(rmode_t mode, pbwidth_t width, vfo_t vfo) { | ||||||
|   return rig_set_mode(theRig, vfo, mode, width); |   return rig_set_mode(theRig, vfo, mode, width); | ||||||
|  | |||||||
							
								
								
									
										13
									
								
								rigclass.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								rigclass.h
									
									
									
									
									
								
							| @ -24,11 +24,13 @@ | |||||||
| 
 | 
 | ||||||
| #include <hamlib/rig.h> | #include <hamlib/rig.h> | ||||||
| #include <iostream> | #include <iostream> | ||||||
| 
 | #include <QString> | ||||||
| 
 | 
 | ||||||
| class BACKEND_IMPEXP Rig { | class BACKEND_IMPEXP Rig { | ||||||
| private: | private: | ||||||
|   RIG* theRig;  // Global ref. to the rig
 |   RIG* theRig;  // Global ref. to the rig
 | ||||||
|  |   bool m_hrd; | ||||||
|  |   QString m_context; | ||||||
| 
 | 
 | ||||||
| protected: | protected: | ||||||
| public: | public: | ||||||
| @ -41,7 +43,7 @@ public: | |||||||
|   int init(rig_model_t rig_model); |   int init(rig_model_t rig_model); | ||||||
| 
 | 
 | ||||||
|   // This method open the communication port to the rig
 |   // 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
 |   // This method close the communication port to the rig
 | ||||||
|   int close(void); |   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
 | #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/lib/libjt9.a | ||||||
| LIBS += ../wsjtx/libfftw3f_win.a | LIBS += ../wsjtx/libfftw3f_win.a | ||||||
| LIBS += ../wsjtx/libpskreporter.a | LIBS += ../wsjtx/libpskreporter.a | ||||||
|  | LIBS += ../wsjtx/libHRDInterface001.a | ||||||
| LIBS += ../QtSupport/palir-02.dll | LIBS += ../QtSupport/palir-02.dll | ||||||
| LIBS += libwsock32 | LIBS += libwsock32 | ||||||
| LIBS += C:/MinGW/lib/libf95.a | LIBS += C:/MinGW/lib/libf95.a | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user