diff --git a/lib/libhamlib.dll.a b/lib/libhamlib.dll.a new file mode 100644 index 000000000..7bb6d1bd5 Binary files /dev/null and b/lib/libhamlib.dll.a differ diff --git a/lib/rig_control.c b/lib/rig_control.c new file mode 100644 index 000000000..d105718e4 --- /dev/null +++ b/lib/rig_control.c @@ -0,0 +1,98 @@ +#include "config.h" +#include +#include +#include +#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); +} diff --git a/lib/tstrig.c b/lib/tstrig.c new file mode 100644 index 000000000..2e77fea5c --- /dev/null +++ b/lib/tstrig.c @@ -0,0 +1,26 @@ +#include "config.h" +#include +#include +#include +#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 +*/ diff --git a/lib/tstrig.h b/lib/tstrig.h new file mode 100644 index 000000000..ce62d3d7b --- /dev/null +++ b/lib/tstrig.h @@ -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 +#include + +/* + * 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 */ diff --git a/mainwindow.cpp b/mainwindow.cpp index 8f1007a7c..1a70d00a5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2552,4 +2552,9 @@ void MainWindow::on_tuneButton_clicked() ui->tuneButton->setStyleSheet(""); on_monitorButton_clicked(); } + /* + rigOpen(214,0); + rigSetFreq(10138700); + qDebug() << "Freq:" << rigFreq(); + */ } diff --git a/mainwindow.h b/mainwindow.h index ebb5284f9..c7c9f2fcf 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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 diff --git a/wsjtx.pro b/wsjtx.pro index 0fcfa641d..7810d9dcd 100644 --- a/wsjtx.pro +++ b/wsjtx.pro @@ -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