Starting to implement direct calls to hamlib functions, rather than

using rigctl in a separate process.


git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3170 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2013-04-15 00:28:27 +00:00
parent d734aca363
commit 57d8bb4fd9
7 changed files with 187 additions and 0 deletions

BIN
lib/libhamlib.dll.a Normal file

Binary file not shown.

98
lib/rig_control.c Normal file
View File

@ -0,0 +1,98 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tstrig.h"
RIG *my_rig; // handle to rig
int set_conf(RIG *my_rig, char *conf_parms);
//------------------------------------------------------------------------
int set_conf(RIG *my_rig, char *conf_parms)
{
char *p, *q, *n;
int ret;
p = conf_parms;
while (p && *p != '\0') {
/* FIXME: left hand value of = cannot be null */
q = strchr(p, '=');
if ( !q )
return -RIG_EINVAL;
*q++ = '\0';
n = strchr(q, ',');
if (n) *n++ = '\0';
printf("%s %s\n",p,q);
ret = rig_set_conf(my_rig, rig_token_lookup(my_rig, p), q);
if (ret != RIG_OK)
return ret;
p = n;
}
return RIG_OK;
}
//------------------------------------------------------------------------
int rigOpen(rig_model_t my_model, int verbose)
{
int retcode; /* generic return code from functions */
char *civaddr = NULL; /* NULL means no need to set conf */
const char *rig_file;
const char *conf_parms2;
int serial_rate;
rig_set_debug(verbose);
my_rig=rig_init(my_model);
if (!my_rig) {
fprintf(stderr, "Unknown rig num %d, or initialization error.\n",my_model);
exit(2);
}
rig_file="COM1";
serial_rate=4800;
conf_parms2="data_bits=8,stop_bits=2,serial_handshake=Hardware";
retcode=set_conf(my_rig, conf_parms2);
if (retcode!=RIG_OK) {
fprintf(stderr, "Config parameter error: %s\n", rigerror(retcode));
exit(2);
}
if (rig_file)
strncpy(my_rig->state.rigport.pathname, rig_file, FILPATHLEN - 1);
if (serial_rate!=0)
my_rig->state.rigport.parm.serial.rate = serial_rate;
if (civaddr)
rig_set_conf(my_rig, rig_token_lookup(my_rig, "civaddr"), civaddr);
retcode = rig_open(my_rig);
return 0;
}
int rigSetFreq(int fHz)
{
return rig_set_freq(my_rig,RIG_VFO_CURR,fHz);
}
int rigFreq()
{
int iret=0;
freq_t freq;
iret=rig_get_freq(my_rig, RIG_VFO_CURR, &freq);
if (iret == RIG_OK ) {
printf("rig_get_freq: freq = %"PRIfreq"\n", freq);
} else {
printf("rig_get_freq: error = %s \n", rigerror(iret));
}
return freq;
}
void rigClose()
{
rig_close(my_rig);
rig_cleanup(my_rig);
}

26
lib/tstrig.c Normal file
View File

@ -0,0 +1,26 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tstrig.h"
int set_conf(RIG *my_rig, char *conf_parms);
int rig_control(rig_model_t my_model, int verbose);
int main (int argc, char *argv[])
{
rig_model_t my_model = RIG_MODEL_DUMMY;
int verbose=0;
my_model=214;
rig_control(my_model,verbose);
return 0;
}
/*
gcc -c -Wall -I../include rig_control.c
gcc -c -Wall -I../include tstrig.c
gcc -o tstrig.exe -Wl,--enable-auto-import tstrig.o rig_control.o libhamlib.dll.a
strip tstrig.exe
*/

50
lib/tstrig.h Normal file
View File

@ -0,0 +1,50 @@
/*
* rigctl_parse.h - (C) Stephane Fillod 2000-2010
*
* This program test/control a radio using Hamlib.
* It takes commands in interactive mode as well as
* from command line options.
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef RIGCTL_PARSE_H
#define RIGCTL_PARSE_H
#include <stdio.h>
#include <hamlib/rig.h>
/*
* external prototype
*/
int dumpcaps (RIG *, FILE *);
int dumpconf (RIG *, FILE *);
/*
* Prototypes
*/
void usage_rig(FILE *);
void version();
void list_models();
int dump_chan(FILE *, RIG*, channel_t*);
int print_conf_list(const struct confparams *cfp, rig_ptr_t data);
int set_conf(RIG *my_rig, char *conf_parms);
int rigctl_parse(RIG *my_rig, FILE *fin, FILE *fout, char *argv[], int argc);
#endif /* RIGCTL_PARSE_H */

View File

@ -2552,4 +2552,9 @@ void MainWindow::on_tuneButton_clicked()
ui->tuneButton->setStyleSheet("");
on_monitorButton_clicked();
}
/*
rigOpen(214,0);
rigSetFreq(10138700);
qDebug() << "Freq:" << rigFreq();
*/
}

View File

@ -362,6 +362,13 @@ void azdist_(char* MyGrid, char* HisGrid, double* utch, int* nAz, int* nEl,
int len1, int len2);
void morse_(char* msg, int* icw, int* ncw, int len);
//void rig_control(int nrig, int verbose);
void rigOpen(int nrig, int verbose);
void rigSetFreq(int fHz);
int rigFreq();
}
#endif // MAINWINDOW_H

View File

@ -66,6 +66,7 @@ LIBS += -lportaudio -lgfortran -lfftw3f
win32 {
INCLUDEPATH += c:/qwt-6.0.1/include
LIBS += ../wsjtx/lib/libjt9.a
LIBS += ../wsjtx/lib/libhamlib.dll.a
LIBS += ../wsjtx/libfftw3f_win.a
LIBS += ../wsjtx/libpskreporter.a
LIBS += ../QtSupport/palir-02.dll