kopia lustrzana https://github.com/Hamlib/Hamlib
Merge GitHub PR #1914
commit
fd68f38743
5
NEWS
5
NEWS
|
@ -14,16 +14,17 @@ Version 5.x -- future
|
|||
|
||||
Version 4.7.0
|
||||
* 2025-12-01 (target)
|
||||
* Some internal functions change names to avoid conflicts with apps.
|
||||
* POSIX threads are required to build and run Hamlib. Note that it was
|
||||
actually the case for 4.6.x, but now the configuration step will
|
||||
fail instead of the compilation.
|
||||
* Functions rig_get_conf, rot_get_conf, amp_get_conf deprecated;
|
||||
use *_get_conf2() instead.
|
||||
use *_get_conf2() instead. Also rig_set_trn and rig_get_trn deprecated.
|
||||
* Fix handling of unprintable characters in kenwood.c that broke radios
|
||||
such as the TM-D710/TM-V71 that use EOM_TH (\r) as the command terminator.
|
||||
(TNX, Lars Kellogg-Stedman and George Baltz).
|
||||
* Reduce/repair excess output from cppcheck.sh - mostly cosmetic changes (WIP)
|
||||
Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 642
|
||||
Output from `wc -l cppcheck.log` - 4.6.2: 981 now: 595
|
||||
* Remove dead getopt code. GitHub PR #1709. (TNX Daniele Forsi)
|
||||
* Move rig_cache to separate(calloc) storage. Prepare for other moves.
|
||||
Issue #1420
|
||||
|
|
|
@ -17,6 +17,7 @@ changes to ease transition to 5.0
|
|||
- Functions `rig_get_conf()`, `rot_get_conf()` and `amp_get_conf()` are deprecated and
|
||||
will be removed in 5.0. Use `..._get_conf2()` instead. See issue
|
||||
[#924](https://github.com/Hamlib/Hamlib/issues/924).
|
||||
- Functions `rig_set_trn()` & `rig_get_trn()` deprecated; operation now handled internally.
|
||||
- Documentation brought up to date.
|
||||
- (TBD)
|
||||
|
||||
|
|
|
@ -116,6 +116,8 @@
|
|||
// others
|
||||
%rename("$ignore", regexmatch$name="python_callbacks") ""; // internal structs and methods used by bindings
|
||||
%ignore rig_state::cache; // deprecated
|
||||
%ignore rig_set_trn; // deprecated
|
||||
%ignore rig_get_trn; // deprecated
|
||||
|
||||
#ifdef SWIGLUA
|
||||
%ignore Rig::set_level(setting_t,int,vfo_t);
|
||||
|
|
|
@ -49,7 +49,6 @@ class TestClass:
|
|||
'get_split_freq',
|
||||
'get_split_mode',
|
||||
'get_split_vfo',
|
||||
'get_trn',
|
||||
'get_ts',
|
||||
'get_vfo',
|
||||
'get_vfo_info',
|
||||
|
@ -103,7 +102,6 @@ class TestClass:
|
|||
'set_split_freq_mode',
|
||||
'set_split_mode',
|
||||
'set_split_vfo',
|
||||
'set_trn',
|
||||
'set_ts',
|
||||
'set_vfo',
|
||||
'set_vfo_callback',
|
||||
|
|
|
@ -286,7 +286,7 @@ class TestClass:
|
|||
assert isinstance(rig.get_split_freq(Hamlib.RIG_VFO_CURR), float)
|
||||
assert len(rig.get_split_mode()) == 2
|
||||
assert len(rig.get_split_mode(Hamlib.RIG_VFO_CURR)) == 2
|
||||
assert isinstance(rig.get_trn(), int) # deprecated
|
||||
# assert isinstance(rig.get_trn(), int) # deprecated
|
||||
assert isinstance(rig.get_ts(), int)
|
||||
assert isinstance(rig.get_ts(Hamlib.RIG_VFO_CURR), int)
|
||||
assert len(rig.get_vfo_info()) == 5
|
||||
|
@ -349,7 +349,7 @@ class TestClass:
|
|||
assert rig.set_split_mode(0, 0, 0) is None
|
||||
assert rig.set_split_vfo(0, 0) is None
|
||||
assert rig.set_split_vfo(0, 0, 0) is None
|
||||
assert rig.set_trn(0) is None # deprecated
|
||||
# assert rig.set_trn(0) is None # deprecated
|
||||
assert rig.set_ts(0, 0) is None
|
||||
assert rig.set_vfo_opt(0) is None
|
||||
assert rig.token_lookup("") is None
|
||||
|
|
|
@ -569,7 +569,7 @@ int *rig_spectrum_cb_python(RIG *rig, struct rig_spectrum_line *rig_spectrum_lin
|
|||
#define _VFO_DECL
|
||||
METHOD1(set_vfo, vfo_t) /* particular case */
|
||||
METHOD1(set_powerstat, powerstat_t)
|
||||
METHOD1(set_trn, int)
|
||||
// METHOD1(set_trn, int)
|
||||
METHOD1(has_get_level, setting_t)
|
||||
METHOD1(has_set_parm, setting_t)
|
||||
METHOD1(has_set_func, setting_t)
|
||||
|
@ -637,7 +637,7 @@ int *rig_spectrum_cb_python(RIG *rig, struct rig_spectrum_line *rig_spectrum_lin
|
|||
{ self->error_status = rig_get_vfo_info(self->rig, vfo, freq, mode, width, split, satmode); }
|
||||
METHOD1VGET(get_mem, int)
|
||||
METHOD1GET(get_powerstat, powerstat_t)
|
||||
METHOD1GET(get_trn, int)
|
||||
// METHOD1GET(get_trn, int)
|
||||
METHOD1VGET(get_dcd, dcd_t)
|
||||
|
||||
// Handling of event callbacks
|
||||
|
|
|
@ -616,20 +616,6 @@ float Rig::mW2power (unsigned int mwpower, freq_t freq, rmode_t mode)
|
|||
return power;
|
||||
}
|
||||
|
||||
void Rig::setTrn (int trn)
|
||||
{
|
||||
CHECK_RIG( rig_set_trn(theRig, trn) );
|
||||
}
|
||||
|
||||
int Rig::getTrn ()
|
||||
{
|
||||
int trn;
|
||||
|
||||
CHECK_RIG( rig_get_trn(theRig, &trn) );
|
||||
|
||||
return trn;
|
||||
}
|
||||
|
||||
void Rig::setBank (int bank, vfo_t vfo)
|
||||
{
|
||||
CHECK_RIG( rig_set_ts(theRig, vfo, bank) );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
set -x
|
||||
# set -x
|
||||
# Author Michael Black W9MDB
|
||||
# This SUPPRESS setting results in no warnings as of 2020-01-14
|
||||
# There are things that could still be done...especially in the C++ area
|
||||
|
@ -63,7 +63,7 @@ CHECK="\
|
|||
-D DECLARE_INITRIG_BACKEND \
|
||||
-D DECLARE_INITROT_BACKEND \
|
||||
-D DECLARE_INITAMP_BACKEND \
|
||||
-D B230400
|
||||
-D B230400 \
|
||||
-U RIG_LEVEL_LINEOUT \
|
||||
-U O_ASYNC \
|
||||
-U F_SETSIG \
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
// Our shared secret password
|
||||
#define HAMLIB_SECRET_LENGTH 32
|
||||
|
||||
#define HAMLIB_TRACE rig_debug(RIG_DEBUG_TRACE,"%s%s(%d) trace\n",spaces(STATE(rig)->depth), __FILE__, __LINE__)
|
||||
#define HAMLIB_TRACE rig_debug(RIG_DEBUG_TRACE,"%s%s(%d) trace\n",hl_stars(STATE(rig)->depth), __FILE__, __LINE__)
|
||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -2244,7 +2244,7 @@ struct rig_caps {
|
|||
int (*set_lock_mode)(RIG *rig, int mode);
|
||||
int (*get_lock_mode)(RIG *rig, int *mode);
|
||||
short timeout_retry; /*!< number of retries to make in case of read timeout errors, some serial interfaces may require this, 0 to use default value, -1 to disable */
|
||||
short morse_qsize; /* max length of morse */
|
||||
short morse_qsize; /*!< max length of morse message rig can accept in one command */
|
||||
// int (*bandwidth2rig)(RIG *rig, enum bandwidth_t bandwidth);
|
||||
// enum bandwidth_t (*rig2bandwidth)(RIG *rig, int rigbandwidth);
|
||||
};
|
||||
|
@ -2683,10 +2683,10 @@ struct s_rig {
|
|||
struct rig_callbacks callbacks; /*!< registered event callbacks */
|
||||
// state should really be a pointer but that's a LOT of changes involved
|
||||
struct rig_state state; /*!< Rig state */
|
||||
/* Data beyond this line is for hamlib internal use only,
|
||||
/* Data after this line is for hamlib internal use only,
|
||||
* and should *NOT* be referenced by applications, as layout will change!
|
||||
*/
|
||||
struct rig_cache *cache_addr;
|
||||
struct rig_cache *cache_addr; /*!< address of rig_cache buffer */
|
||||
};
|
||||
|
||||
|
||||
|
@ -3235,9 +3235,11 @@ rig_lookup_mem_caps HAMLIB_PARAMS((RIG *rig,
|
|||
extern HAMLIB_EXPORT(int)
|
||||
rig_mem_count HAMLIB_PARAMS((RIG *rig));
|
||||
|
||||
HL_DEPRECATED
|
||||
extern HAMLIB_EXPORT(int)
|
||||
rig_set_trn HAMLIB_PARAMS((RIG *rig,
|
||||
int trn));
|
||||
HL_DEPRECATED
|
||||
extern HAMLIB_EXPORT(int)
|
||||
rig_get_trn HAMLIB_PARAMS((RIG *rig,
|
||||
int *trn));
|
||||
|
@ -3356,7 +3358,7 @@ extern HAMLIB_EXPORT_VAR(char) debugmsgsave3[DEBUGMSGSAVE_SIZE]; // last-2 debu
|
|||
|
||||
// Measuring elapsed time -- local variable inside function when macro is used
|
||||
#define ELAPSED1 struct timespec __begin; elapsed_ms(&__begin, HAMLIB_ELAPSED_SET);
|
||||
#define ELAPSED2 rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s: elapsed=%.0lfms\n", spaces(STATE(rig)->depth), STATE(rig)->depth, __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET));
|
||||
#define ELAPSED2 rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s: elapsed=%.0lfms\n", hl_stars(STATE(rig)->depth), STATE(rig)->depth, __func__, elapsed_ms(&__begin, HAMLIB_ELAPSED_GET));
|
||||
|
||||
// use this instead of snprintf for automatic detection of buffer limit
|
||||
#define SNPRINTF(s,n,...) { if (snprintf(s,n,##__VA_ARGS__) >= (n)) fprintf(stderr,"***** %s(%d): message truncated *****\n", __func__, __LINE__); }
|
||||
|
|
|
@ -840,6 +840,7 @@ static int gqrx_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
|
||||
if (vfo == RIG_VFO_A)
|
||||
{
|
||||
int tempi;
|
||||
switch(level)
|
||||
{
|
||||
case RIG_LEVEL_AF:
|
||||
|
@ -851,12 +852,17 @@ static int gqrx_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
break;
|
||||
|
||||
case RIG_LEVEL_STRENGTH:
|
||||
val->i = round(rig_raw2val(round(val->f), &rig->caps->str_cal));
|
||||
// Overlapping read/write from one member of a union to another
|
||||
// is technically undefined behavior, according to the C
|
||||
// standard; use a temp to avoid cppcheck error.
|
||||
tempi = round(rig_raw2val(round(val->f), &rig->caps->str_cal));
|
||||
val->i = tempi;
|
||||
priv->curr_meter = val->i;
|
||||
break;
|
||||
|
||||
case RIG_LEVEL_RAWSTR:
|
||||
val->i = round(val->f);
|
||||
tempi = round(val->f);
|
||||
val->i = tempi;
|
||||
break;
|
||||
|
||||
default :
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "iofunc.h"
|
||||
#include "apex.h"
|
||||
|
||||
int apex_shared_loop_get_position(ROT *rot, float *az, float *el)
|
||||
static int apex_shared_loop_get_position(ROT *rot, float *az, float *el)
|
||||
{
|
||||
int loop = 10;
|
||||
|
||||
|
@ -21,7 +21,7 @@ int apex_shared_loop_get_position(ROT *rot, float *az, float *el)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
int apex_shared_loop_set_position(ROT *rot, float az, float dummy)
|
||||
static int apex_shared_loop_set_position(ROT *rot, float az, float dummy)
|
||||
{
|
||||
char cmdstr[16];
|
||||
int retval;
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../src/misc.h"
|
||||
#include <string.h>
|
||||
|
||||
/* ID 0310 == 310, Must drop leading zero */
|
||||
typedef enum nc_rigid_e
|
||||
|
@ -44,7 +43,7 @@ int write_sim(int fd, const unsigned char *buf, int buflen, const char *func,
|
|||
int linenum)
|
||||
{
|
||||
int n;
|
||||
dump_hex(buf, buflen);
|
||||
dumphex(buf, buflen);
|
||||
n = write(fd, buf, buflen);
|
||||
|
||||
if (n <= 0)
|
||||
|
@ -111,7 +110,7 @@ getmyline(int fd, char *buf)
|
|||
if (c == ';') { return i; }
|
||||
}
|
||||
|
||||
if (i == 0) { hl_usleep(10 * 1000); }
|
||||
if (i == 0) { sleep(1); }
|
||||
|
||||
return i;
|
||||
}
|
||||
|
@ -128,13 +127,16 @@ getmyline5(int fd, unsigned char *buf)
|
|||
buf[i++] = c;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (i > 0) {
|
||||
printf("n=%d %02x %02x %02x %02x %02x\n", i,
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (i == 0) {
|
||||
hl_usleep(10 * 1000);
|
||||
//hl_usleep(10 * 1000);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
return i;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
#include "misc.h"
|
||||
#include "sim.h"
|
||||
/* Simulators really shouldn't be using ANY of the definitions
|
||||
|
@ -585,7 +584,6 @@ int main(int argc, char **argv)
|
|||
unsigned char buf[BUFSIZE];
|
||||
int fd = openPort(argv[1]);
|
||||
|
||||
printf("%s: %s\n", argv[0], rig_version());
|
||||
#ifdef X25
|
||||
printf("x25/x26 command recognized\n");
|
||||
#else
|
||||
|
@ -622,7 +620,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
else
|
||||
{
|
||||
hl_usleep(1000 * 1000);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
rigStatus();
|
||||
|
|
45
src/misc.c
45
src/misc.c
|
@ -1031,11 +1031,13 @@ static const struct
|
|||
};
|
||||
|
||||
/**
|
||||
* \brief check input to set_level
|
||||
* \brief Check the input to rig_set_level
|
||||
* \ingroup lib_internal
|
||||
*
|
||||
* \param rig The rig handle
|
||||
* \param level RIG_LEVEL_* trying to set
|
||||
* \param val Raw input from the caller
|
||||
* \param gran If not NULL, set to location of level_gran data
|
||||
* \param[out] gran If not NULL, set to location of level_gran data
|
||||
*
|
||||
* \return RIG_OK if value is in range for this level, -RIG_EINVAL if not
|
||||
*/
|
||||
|
@ -2810,6 +2812,28 @@ static struct tm *gmtime_r(const time_t *t, struct tm *r)
|
|||
#endif // gmtime_r
|
||||
#endif // _WIN32
|
||||
|
||||
/**
|
||||
* \brief Get a string of stars for indenting messages
|
||||
* \ingroup lib_internal
|
||||
*
|
||||
* \param len number of stars (sounds kinda like a rating)
|
||||
* \return pointer to an appropriate string
|
||||
*/
|
||||
const char *hl_stars(int len)
|
||||
{
|
||||
#define MAX_STARS 128
|
||||
static const char s[MAX_STARS + 1] =
|
||||
"****************************************************************"
|
||||
"****************************************************************";
|
||||
|
||||
if (len < 0 || len > MAX_STARS)
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
return &s[MAX_STARS - len];
|
||||
}
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
char *date_strget(char *buf, int buflen, int localtime)
|
||||
{
|
||||
|
@ -2853,23 +2877,6 @@ char *rig_date_strget(char *buf, int buflen, int localtime)
|
|||
return date_strget(buf, buflen, localtime);
|
||||
}
|
||||
|
||||
#define MAX_SPACES 256
|
||||
const char *spaces(int len)
|
||||
{
|
||||
static const char s[MAX_SPACES + 1] =
|
||||
"****************************************************************"
|
||||
"****************************************************************"
|
||||
"****************************************************************"
|
||||
"****************************************************************";
|
||||
|
||||
if (len < 0 || len > MAX_SPACES)
|
||||
{
|
||||
len = 0;
|
||||
}
|
||||
|
||||
return &s[MAX_SPACES - len];
|
||||
}
|
||||
|
||||
// if which==0 rig_band_select str will be returned
|
||||
// if which!=0 the rig_parm_gran band str will be returned
|
||||
const char *rig_get_band_str(RIG *rig, hamlib_band_t band, int which)
|
||||
|
|
10
src/misc.h
10
src/misc.h
|
@ -35,12 +35,12 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
// a function to return just a string of spaces for indenting rig debug lines
|
||||
HAMLIB_EXPORT (const char *) spaces(int len);
|
||||
// a function to return just a string of stars for indenting rig debug lines
|
||||
HAMLIB_EXPORT (const char *) hl_stars(int len);
|
||||
|
||||
/*
|
||||
* Do a hex dump of the unsigned char array.
|
||||
*/
|
||||
|
||||
void dump_hex(const unsigned char ptr[], size_t size);
|
||||
|
||||
/*
|
||||
|
@ -154,7 +154,7 @@ extern HAMLIB_EXPORT(char *)date_strget(char *buf, int buflen, int localtime);
|
|||
void errmsg(int err, char *s, const char *func, const char *file, int line);
|
||||
#define ERRMSG(err, s) errmsg(err, s, __func__, __FILENAME__, __LINE__)
|
||||
#define ENTERFUNC { ++STATE(rig)->depth; \
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s(%d):%s entered\n", spaces(STATE(rig)->depth), STATE(rig)->depth, __FILENAME__, __LINE__, __func__); \
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s(%d):%s entered\n", hl_stars(STATE(rig)->depth), STATE(rig)->depth, __FILENAME__, __LINE__, __func__); \
|
||||
}
|
||||
#define ENTERFUNC2 { rig_debug(RIG_DEBUG_VERBOSE, "%s(%d):%s entered\n", __FILENAME__, __LINE__, __func__); \
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void errmsg(int err, char *s, const char *func, const char *file, int line);
|
|||
// could be a function call
|
||||
#define RETURNFUNC(rc) {do { \
|
||||
int rctmp = rc; \
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s(%d):%s returning(%ld) %s\n", spaces(STATE(rig)->depth), STATE(rig)->depth, __FILENAME__, __LINE__, __func__, (long int) (rctmp), rctmp<0?rigerror2(rctmp):""); \
|
||||
rig_debug(RIG_DEBUG_VERBOSE, "%s%d:%s(%d):%s returning(%ld) %s\n", hl_stars(STATE(rig)->depth), STATE(rig)->depth, __FILENAME__, __LINE__, __func__, (long int) (rctmp), rctmp<0?rigerror2(rctmp):""); \
|
||||
--STATE(rig)->depth; \
|
||||
return (rctmp); \
|
||||
} while(0);}
|
||||
|
|
|
@ -1059,6 +1059,7 @@ HAMLIB_EXPORT(int) rig_settings_get_path(char *path, int pathlen)
|
|||
home = "?HOME";
|
||||
}
|
||||
|
||||
// cppcheck-suppress nullPointerRedundantCheck
|
||||
snprintf(path, pathlen, "%s/.config", home);
|
||||
|
||||
if (xdgpath)
|
||||
|
@ -1098,13 +1099,13 @@ HAMLIB_EXPORT(int) rig_settings_save(const char *setting, void *value,
|
|||
FILE *fptmp;
|
||||
char path[4096];
|
||||
char buf[4096];
|
||||
char *cvalue = (char *)value;
|
||||
int *ivalue = (int *)value;
|
||||
const char *cvalue = (char *)value;
|
||||
const int *ivalue = (int *)value;
|
||||
int n = 0;
|
||||
long *lvalue = (long *) value;
|
||||
float *fvalue = (float *) value;
|
||||
double *dvalue = (double *) value;
|
||||
char *vformat = "Unknown format??";
|
||||
const long *lvalue = (long *) value;
|
||||
const float *fvalue = (float *) value;
|
||||
const double *dvalue = (double *) value;
|
||||
const char *vformat = "Unknown format??";
|
||||
char template[64];
|
||||
|
||||
rig_settings_get_path(path, sizeof(path));
|
||||
|
|
|
@ -14,7 +14,7 @@ DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum
|
|||
|
||||
bin_PROGRAMS = rigctl rigctld rigmem rigsmtr rigswr rotctl rotctld rigctlcom rigctltcp rigctlsync ampctl ampctld rigtestmcast rigtestmcastrx $(TESTLIBUSB) rigfreqwalk
|
||||
|
||||
check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testtrn testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels testmW2power test2038
|
||||
check_PROGRAMS = dumpmem testrig testrigopen testrigcaps testbcd testfreq listrigs testloc rig_bench testcache cachetest cachetest2 testcookie testgrid hamlibmodels testmW2power test2038
|
||||
# Document building testsecurity
|
||||
### check_PROGRAMS += testsecurity
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ rigmatrix - Output the HTML table of supported rigs, with .png files for freqs
|
|||
testbcd - Simple program to test BCD conversion, takes a number as arg.
|
||||
testfreq - Simple program to test Freq conversion, takes a number as arg.
|
||||
testrig - Sample program calling common API calls, uses rig_probe
|
||||
testtrn - Sample program using event notification (transceive mode)
|
||||
rigctl - Combined tool to execute any call of the API, see man page
|
||||
rigmem - Combined tool to load/save content of rig memory, see man page
|
||||
rotctl - Similar to 'rigctl' but for rotators, see man page
|
||||
|
|
101
tests/testtrn.c
101
tests/testtrn.c
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
* Hamlib sample program to test transceive mode (async event)
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "hamlib/rig.h"
|
||||
|
||||
#include "hamlib/config.h"
|
||||
|
||||
#define SERIAL_PORT "/dev/ttyS0"
|
||||
|
||||
|
||||
static int myfreq_event(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg)
|
||||
{
|
||||
int *count_ptr = (int *) arg;
|
||||
|
||||
printf("Rig changed freq to %"PRIfreq"Hz\n", freq);
|
||||
*count_ptr += 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
RIG *my_rig; /* handle to rig (instance) */
|
||||
int retcode; /* generic return code from functions */
|
||||
int i, count = 0;
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "%s <rig_num>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("testrig: Hello, I am your main() !\n");
|
||||
|
||||
/*
|
||||
* allocate memory, setup & open port
|
||||
*/
|
||||
|
||||
my_rig = rig_init(atoi(argv[1]));
|
||||
|
||||
if (!my_rig)
|
||||
{
|
||||
fprintf(stderr, "Unknown rig num: %d\n", atoi(argv[1]));
|
||||
fprintf(stderr, "Please check riglist.h\n");
|
||||
exit(1); /* whoops! something went wrong (mem alloc?) */
|
||||
}
|
||||
|
||||
rig_set_conf(my_rig, rig_token_lookup(my_rig, "rig_pathname"), SERIAL_PORT);
|
||||
|
||||
if (rig_open(my_rig))
|
||||
{
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("Port %s opened ok\n", SERIAL_PORT);
|
||||
|
||||
/*
|
||||
* Below are examples of set/get routines.
|
||||
* Must add checking of functionality map prior to command execution -- FS
|
||||
*
|
||||
*/
|
||||
|
||||
retcode = rig_set_freq(my_rig, RIG_VFO_CURR, 439700000);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
printf("rig_set_freq: error = %s \n", rigerror(retcode));
|
||||
}
|
||||
|
||||
rig_set_freq_callback(my_rig, myfreq_event, (rig_ptr_t)&count);
|
||||
|
||||
retcode = rig_set_trn(my_rig, RIG_TRN_RIG);
|
||||
|
||||
if (retcode != RIG_OK)
|
||||
{
|
||||
printf("rig_set_trn: error = %s \n", rigerror(retcode));
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
{
|
||||
printf("Loop count: %d\n", i);
|
||||
sleep(10); /* or anything smarter */
|
||||
}
|
||||
|
||||
printf("Frequency changed %d times\n", count);
|
||||
|
||||
rig_close(my_rig); /* close port */
|
||||
rig_cleanup(my_rig); /* if you care about memory */
|
||||
|
||||
printf("port %s closed ok \n", SERIAL_PORT);
|
||||
|
||||
return 0;
|
||||
}
|
Ładowanie…
Reference in New Issue