kopia lustrzana https://github.com/Hamlib/Hamlib
added set/get_conf support
git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@599 7ae35d74-ebe9-4afe-98af-79ac388436b8Hamlib-1.1.2
rodzic
d506e8c80c
commit
99b10b1aef
|
@ -2,7 +2,7 @@
|
|||
* Hamlib CI-V backend - description of IC-706 and variations
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod
|
||||
*
|
||||
* $Id: ic706.c,v 1.24 2001-07-13 19:08:15 f4cfe Exp $
|
||||
* $Id: ic706.c,v 1.25 2001-07-21 13:00:03 f4cfe Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -437,6 +437,10 @@ filters: {
|
|||
RIG_FLT_END,
|
||||
},
|
||||
|
||||
cfgparams: icom_cfg_params,
|
||||
set_conf: icom_set_conf,
|
||||
get_conf: icom_get_conf,
|
||||
|
||||
priv: (void*)&ic706mkiig_priv_caps,
|
||||
rig_init: icom_init,
|
||||
rig_cleanup: icom_cleanup,
|
||||
|
|
68
icom/icom.c
68
icom/icom.c
|
@ -2,7 +2,7 @@
|
|||
* Hamlib CI-V backend - main file
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod
|
||||
*
|
||||
* $Id: icom.c,v 1.35 2001-07-13 19:08:15 f4cfe Exp $
|
||||
* $Id: icom.c,v 1.36 2001-07-21 13:00:03 f4cfe Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -143,6 +143,21 @@ struct icom_addr {
|
|||
unsigned char re_civ_addr;
|
||||
};
|
||||
|
||||
|
||||
#define TOK_CIVADDR RIG_TOKEN_BACKEND(1)
|
||||
#define TOK_MODE731 RIG_TOKEN_BACKEND(2)
|
||||
|
||||
const struct confparams icom_cfg_params[] = {
|
||||
{ TOK_CIVADDR, "civaddr", "CI-V address", "Transceiver's CI-V address",
|
||||
"0", RIG_CONF_NUMERIC, { n: { 0, 0xff, 1 } }
|
||||
},
|
||||
{ TOK_MODE731, "mode731", "CI-V 731 mode", "CI-V operating frequency "
|
||||
"data length, needed for IC731 and IC735",
|
||||
"0", RIG_CONF_CHECKBUTTON
|
||||
},
|
||||
{ RIG_CONF_END, NULL, }
|
||||
};
|
||||
|
||||
/*
|
||||
* Please, if the default CI-V address of your rig is listed as UNKNOWN_ADDR,
|
||||
* send the value to <f4cfe@users.sourceforge.net> for inclusion. Thanks --SF
|
||||
|
@ -799,6 +814,57 @@ int icom_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
*/
|
||||
int icom_set_conf(RIG *rig, token_t token, const char *val)
|
||||
{
|
||||
struct icom_priv_data *priv;
|
||||
struct rig_state *rs;
|
||||
|
||||
rs = &rig->state;
|
||||
priv = (struct icom_priv_data*)rs->priv;
|
||||
|
||||
switch(token) {
|
||||
case TOK_CIVADDR:
|
||||
priv->re_civ_addr = atoi(val);
|
||||
break;
|
||||
case TOK_MODE731:
|
||||
priv->civ_731_mode = atoi(val) ? 1:0;
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* assumes rig!=NULL,
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
* and val points to a buffer big enough to hold the conf value.
|
||||
*/
|
||||
int icom_get_conf(RIG *rig, token_t token, char *val)
|
||||
{
|
||||
struct icom_priv_data *priv;
|
||||
struct rig_state *rs;
|
||||
|
||||
rs = &rig->state;
|
||||
priv = (struct icom_priv_data*)rs->priv;
|
||||
|
||||
switch(token) {
|
||||
case TOK_CIVADDR:
|
||||
sprintf(val, "%d", priv->re_civ_addr);
|
||||
break;
|
||||
case TOK_MODE731:
|
||||
sprintf(val, "%d", priv->civ_731_mode);
|
||||
break;
|
||||
default:
|
||||
return -RIG_EINVAL;
|
||||
}
|
||||
return RIG_OK;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* icom_set_ptt
|
||||
* Assumes rig!=NULL, rig->state.priv!=NULL
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib CI-V backend - main header
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod
|
||||
*
|
||||
* $Id: icom.h,v 1.25 2001-07-13 19:08:15 f4cfe Exp $
|
||||
* $Id: icom.h,v 1.26 2001-07-21 13:00:03 f4cfe Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -101,10 +101,14 @@ int icom_set_func(RIG *rig, vfo_t vfo, setting_t func, int status);
|
|||
int icom_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status);
|
||||
int icom_set_channel(RIG *rig, const channel_t *chan);
|
||||
int icom_get_channel(RIG *rig, channel_t *chan);
|
||||
int icom_set_conf(RIG *rig, token_t token, const char *val);
|
||||
int icom_get_conf(RIG *rig, token_t token, char *val);
|
||||
int icom_set_powerstat(RIG *rig, powerstat_t status);
|
||||
int icom_get_powerstat(RIG *rig, powerstat_t *status);
|
||||
int icom_decode_event(RIG *rig);
|
||||
|
||||
extern const struct confparams icom_cfg_params[];
|
||||
|
||||
extern const struct rig_caps ic706_caps;
|
||||
extern const struct rig_caps ic706mkii_caps;
|
||||
extern const struct rig_caps ic706mkiig_caps;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Hamlib Interface - API header
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton
|
||||
*
|
||||
* $Id: rig.h,v 1.47 2001-07-20 11:07:11 f4cfe Exp $
|
||||
* $Id: rig.h,v 1.48 2001-07-21 13:00:03 f4cfe Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -365,6 +365,43 @@ typedef long vfo_op_t;
|
|||
|
||||
typedef long scan_t;
|
||||
|
||||
/*
|
||||
* configuration token
|
||||
*/
|
||||
typedef long token_t;
|
||||
|
||||
#define RIG_CONF_END 0
|
||||
|
||||
#define RIG_TOKEN_BACKEND(t) (t)
|
||||
#define RIG_TOKEN_FRONTEND(t) ((t)|(1<<30))
|
||||
#define RIG_IS_TOKEN_FRONTEND(t) ((t)&(1<<30))
|
||||
|
||||
/*
|
||||
* strongly inspired from soundmedem. Thanks Thomas!
|
||||
*/
|
||||
#define RIG_CONF_STRING 0
|
||||
#define RIG_CONF_COMBO 1
|
||||
#define RIG_CONF_NUMERIC 2
|
||||
#define RIG_CONF_CHECKBUTTON 3
|
||||
|
||||
struct confparams {
|
||||
token_t token;
|
||||
const char *name; /* try to avoid spaces in the name */
|
||||
const char *label;
|
||||
const char *tooltip;
|
||||
const char *dflt;
|
||||
unsigned int type;
|
||||
union {
|
||||
struct {
|
||||
float min;
|
||||
float max;
|
||||
float step;
|
||||
} n;
|
||||
struct {
|
||||
const char *combostr[8];
|
||||
} c;
|
||||
} u;
|
||||
};
|
||||
|
||||
/*
|
||||
* When optional speech synthesizer is installed
|
||||
|
@ -407,7 +444,6 @@ union value_u {
|
|||
};
|
||||
typedef union value_u value_t;
|
||||
|
||||
|
||||
#define RIG_LEVEL_NONE 0ULL
|
||||
#define RIG_LEVEL_PREAMP (1<<0) /* Preamp, arg int (dB) */
|
||||
#define RIG_LEVEL_ATT (1<<1) /* Attenuator, arg int (dB) */
|
||||
|
@ -734,6 +770,7 @@ struct rig_caps {
|
|||
|
||||
struct filter_list filters[FLTLSTSIZ]; /* mode/filter table, at -6dB */
|
||||
|
||||
const struct confparams *cfgparams;
|
||||
const rig_ptr_t priv;
|
||||
|
||||
/*
|
||||
|
@ -820,6 +857,9 @@ struct rig_caps {
|
|||
int (*set_parm)(RIG *rig, setting_t parm, value_t val);
|
||||
int (*get_parm)(RIG *rig, setting_t parm, value_t *val);
|
||||
|
||||
int (*set_conf)(RIG *rig, token_t token, const char *val);
|
||||
int (*get_conf)(RIG *rig, token_t token, char *val);
|
||||
|
||||
int (*send_dtmf)(RIG *rig, vfo_t vfo, const char *digits);
|
||||
int (*recv_dtmf)(RIG *rig, vfo_t vfo, char *digits, int *length);
|
||||
int (*send_morse)(RIG *rig, vfo_t vfo, const char *msg);
|
||||
|
@ -1084,12 +1124,17 @@ extern HAMLIB_EXPORT(int) rig_get_level HAMLIB_PARAMS((RIG *rig, vfo_t vfo, sett
|
|||
extern HAMLIB_EXPORT(int) rig_set_parm HAMLIB_PARAMS((RIG *rig, setting_t parm, value_t val));
|
||||
extern HAMLIB_EXPORT(int) rig_get_parm HAMLIB_PARAMS((RIG *rig, setting_t parm, value_t *val));
|
||||
|
||||
extern HAMLIB_EXPORT(int) rig_set_conf HAMLIB_PARAMS((RIG *rig, token_t token, const char *val));
|
||||
extern HAMLIB_EXPORT(int) rig_get_conf HAMLIB_PARAMS((RIG *rig, token_t token, char *val));
|
||||
|
||||
extern HAMLIB_EXPORT(int) rig_set_powerstat HAMLIB_PARAMS((RIG *rig, powerstat_t status));
|
||||
extern HAMLIB_EXPORT(int) rig_get_powerstat HAMLIB_PARAMS((RIG *rig, powerstat_t *status));
|
||||
|
||||
extern HAMLIB_EXPORT(int) rig_reset HAMLIB_PARAMS((RIG *rig, reset_t reset)); /* dangerous! */
|
||||
|
||||
/* more to come -- FS */
|
||||
|
||||
extern HAMLIB_EXPORT(const struct confparams*) rig_confparam_lookup HAMLIB_PARAMS((RIG *rig, const char *name));
|
||||
extern HAMLIB_EXPORT(token_t) rig_token_lookup HAMLIB_PARAMS((RIG *rig, const char *name));
|
||||
|
||||
extern HAMLIB_EXPORT(int) rig_close HAMLIB_PARAMS((RIG *rig));
|
||||
extern HAMLIB_EXPORT(int) rig_cleanup HAMLIB_PARAMS((RIG *rig));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
INCLUDES = @INCLUDES@ $(INCLTDL)
|
||||
|
||||
lib_LTLIBRARIES = libhamlib.la
|
||||
libhamlib_la_SOURCES = rig.c serial.c misc.c register.c event.c cal.c
|
||||
libhamlib_la_SOURCES = rig.c serial.c misc.c register.c event.c cal.c conf.c
|
||||
libhamlib_la_LDFLAGS = -no-undefined -release @VERSION@
|
||||
libhamlib_la_LIBADD = $(LIBLTDL)
|
||||
libhamlib_la_DEPENDENCIES = $(LIBLTDL)
|
||||
|
@ -11,5 +11,5 @@ libhamlib_a_SOURCES = rig.c serial.c misc.c register.c event.c cal.c
|
|||
libhamlib_a_LIBADD = $(LIBLTDL)
|
||||
libhamlib_a_DEPENDENCIES = $(LIBLTDL)
|
||||
|
||||
noinst_HEADERS = event.h misc.h serial.h cal.h
|
||||
noinst_HEADERS = event.h misc.h serial.h cal.h conf.h
|
||||
|
||||
|
|
72
src/rig.c
72
src/rig.c
|
@ -12,7 +12,7 @@
|
|||
* Hamlib Interface - main file
|
||||
* Copyright (c) 2000,2001 by Stephane Fillod and Frank Singleton
|
||||
*
|
||||
* $Id: rig.c,v 1.41 2001-07-13 19:08:15 f4cfe Exp $
|
||||
* $Id: rig.c,v 1.42 2001-07-21 13:00:03 f4cfe Exp $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <hamlib/rig.h>
|
||||
#include <serial.h>
|
||||
#include "event.h"
|
||||
#include "conf.h"
|
||||
|
||||
/**
|
||||
* \brief Hamlib release number
|
||||
|
@ -58,8 +59,8 @@ const char hamlib_version[] = "Hamlib version " VERSION;
|
|||
*/
|
||||
const char hamlib_copyright[] =
|
||||
"Copyright (C) 2000, 2001 Stephane Fillod and Frank Singleton\n"
|
||||
"This is free software; see the source for copying conditions.\n"
|
||||
"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"
|
||||
"This is free software; see the source for copying conditions. "
|
||||
"There is NO\n warranty; not even for MERCHANTABILITY or FITNESS FOR A"
|
||||
"PARTICULAR PURPOSE.";
|
||||
|
||||
|
||||
|
@ -2357,7 +2358,7 @@ int rig_set_ctcss_sql(RIG *rig, vfo_t vfo, tone_t tone)
|
|||
* \note \a *tone is NOT in Hz, but in tenth of Hz! This way,
|
||||
* if the function rig_get_ctcss_sql() returns a subaudible tone of 885
|
||||
* for example, then the real tone is 88.5 Hz.
|
||||
* Also, a value of 0 for @tone means the Tone squelch is disabled.
|
||||
* Also, a value of 0 for \a tone means the Tone squelch is disabled.
|
||||
*
|
||||
* \return RIG_OK if the operation has been sucessful, otherwise
|
||||
* a negative value if an error occured (in which case, cause is
|
||||
|
@ -2642,7 +2643,7 @@ int rig_set_level(RIG *rig, vfo_t vfo, setting_t level, value_t val)
|
|||
* \param val The location where to store the value of \a level
|
||||
*
|
||||
* Retrieves the value of a \a level.
|
||||
* The level value @val can be a float or an integer. See #value_t
|
||||
* The level value \a val can be a float or an integer. See #value_t
|
||||
* for more information.
|
||||
*
|
||||
* RIG_LEVEL_STRENGTH: \a val is an integer, representing the S Meter
|
||||
|
@ -2692,7 +2693,7 @@ int rig_get_level(RIG *rig, vfo_t vfo, setting_t level, value_t *val)
|
|||
* \brief set a radio parameter
|
||||
* \param rig The rig handle
|
||||
* \param parm The parameter
|
||||
* \param val The value to set the parameter sto
|
||||
* \param val The value to set the parameter to
|
||||
*
|
||||
* Sets a parameter.
|
||||
* The parameter value \a val can be a float or an integer. See #value_t
|
||||
|
@ -2719,7 +2720,7 @@ int rig_set_parm(RIG *rig, setting_t parm, value_t val)
|
|||
* \brief get the value of a parameter
|
||||
* \param rig The rig handle
|
||||
* \param parm The parameter
|
||||
* \param val The location where to store the value of @parm
|
||||
* \param val The location where to store the value of \a parm
|
||||
*
|
||||
* Retrieves the value of a \a parm.
|
||||
* The parameter value \a val can be a float or an integer. See #value_t
|
||||
|
@ -2982,6 +2983,63 @@ int rig_get_func(RIG *rig, vfo_t vfo, setting_t func, int *status)
|
|||
return retcode;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set a radio configuration parameter
|
||||
* \param rig The rig handle
|
||||
* \param token The parameter
|
||||
* \param val The value to set the parameter to
|
||||
*
|
||||
* Sets a configuration parameter.
|
||||
*
|
||||
* \return RIG_OK if the operation has been sucessful, otherwise
|
||||
* a negative value if an error occured (in which case, cause is
|
||||
* set appropriately).
|
||||
*
|
||||
* \sa rig_get_conf()
|
||||
*/
|
||||
int rig_set_conf(RIG *rig, token_t token, const char *val)
|
||||
{
|
||||
if (!rig || !rig->caps)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (RIG_IS_TOKEN_FRONTEND(token))
|
||||
return frontend_set_conf(rig, token, val);
|
||||
|
||||
if (rig->caps->set_conf == NULL)
|
||||
return -RIG_ENAVAIL;
|
||||
|
||||
return rig->caps->set_conf(rig, token, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the value of a configuration parameter
|
||||
* \param rig The rig handle
|
||||
* \param token The parameter
|
||||
* \param val The location where to store the value of config \a token
|
||||
*
|
||||
* Retrieves the value of a configuration paramter associated with \a token.
|
||||
*
|
||||
* \return RIG_OK if the operation has been sucessful, otherwise
|
||||
* a negative value if an error occured (in which case, cause is
|
||||
* set appropriately).
|
||||
*
|
||||
* \sa rig_set_conf()
|
||||
*/
|
||||
int rig_get_conf(RIG *rig, token_t token, char *val)
|
||||
{
|
||||
if (!rig || !rig->caps || !val)
|
||||
return -RIG_EINVAL;
|
||||
|
||||
if (RIG_IS_TOKEN_FRONTEND(token))
|
||||
return frontend_get_conf(rig, token, val);
|
||||
|
||||
if (rig->caps->get_conf == NULL)
|
||||
return -RIG_ENAVAIL;
|
||||
|
||||
return rig->caps->get_conf(rig, token, val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief set the current memory channel number
|
||||
* \param rig The rig handle
|
||||
|
|
Ładowanie…
Reference in New Issue