Loading...
Searching...
No Matches
amplifier.h
Go to the documentation of this file.
/*
* Hamlib Interface - Amplifier API header
* Copyright (c) 2000-2005 by Stephane Fillod
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#ifndef _AMPLIFIER_H
#define _AMPLIFIER_H 1
#include <hamlib/rig.h>
#include <hamlib/amplist.h>
__BEGIN_DECLS
/* Forward struct references */
struct amp;
struct amp_state;
typedef struct amp AMP;
typedef float swr_t;
typedef int tune_value_t;
#define NETAMPCTL_RET "RPRT "
typedef enum amp_reset_e
{
AMP_RESET_MEM,
AMP_RESET_FAULT,
AMP_RESET_AMP
} amp_reset_t;
typedef enum amp_type_e
{
AMP_FLAG_1 = (1 << 1),
AMP_FLAG_2 = (1 << 2)
} amp_type_t;
// TBD AMP_TYPE
#define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
#define AMP_TYPE_OTHER 0
#define AMP_TYPE_1 AMP_FLAG_1
#define AMP_TYPE_2 AMP_FLAG_2
#define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
enum amp_level_e
{
AMP_LEVEL_NONE = 0,
AMP_LEVEL_SWR = (1 << 0),
AMP_LEVEL_NH = (1 << 1),
AMP_LEVEL_PF = (1 << 2),
AMP_LEVEL_PWR_INPUT = (1 << 3),
AMP_LEVEL_PWR_FWD = (1 << 4),
AMP_LEVEL_PWR_REFLECTED = (1 << 5),
AMP_LEVEL_PWR_PEAK = (1 << 6),
AMP_LEVEL_FAULT = (1 << 7),
AMP_LEVEL_PWR = (1 << 8),
};
// Not used yet.
#define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
#define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
#define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
#define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
/* Basic amp type, can store some useful info about different amplifiers. Each
* lib must be able to populate this structure, so we can make useful
* enquiries about capabilities.
*/
#define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
struct amp_caps
{
amp_model_t amp_model;
const char *model_name;
const char *mfg_name;
const char *version;
const char *copyright;
enum rig_status_e status;
int amp_type;
enum rig_port_e port_type;
int serial_rate_min;
int serial_rate_max;
int serial_data_bits;
int serial_stop_bits;
enum serial_parity_e serial_parity;
enum serial_handshake_e serial_handshake;
int write_delay;
int post_write_delay;
int timeout;
int retry;
const struct confparams *cfgparams;
const rig_ptr_t priv;
const char *amp_model_macro_name;
setting_t has_get_level;
setting_t has_set_level;
gran_t level_gran[RIG_SETTING_MAX];
gran_t parm_gran[RIG_SETTING_MAX];
/*
* Amp Admin API
*
*/
int (*amp_init)(AMP *amp);
int (*amp_cleanup)(AMP *amp);
int (*amp_open)(AMP *amp);
int (*amp_close)(AMP *amp);
int (*set_freq)(AMP *amp, freq_t val);
int (*get_freq)(AMP *amp, freq_t *val);
int (*set_conf)(AMP *amp, hamlib_token_t token, const char *val);
int (*get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len);
int (*get_conf)(AMP *amp, hamlib_token_t token, char *val);
/*
* General API commands, from most primitive to least.. :()
* List Set/Get functions pairs
*/
int (*reset)(AMP *amp, amp_reset_t reset);
int (*get_level)(AMP *amp, setting_t level, value_t *val);
int (*set_level)(AMP *amp, setting_t level, value_t val);
int (*get_ext_level)(AMP *amp, hamlib_token_t level, value_t *val);
int (*set_ext_level)(AMP *amp, hamlib_token_t level, value_t val);
int (*set_powerstat)(AMP *amp, powerstat_t status);
int (*get_powerstat)(AMP *amp, powerstat_t *status);
/* get firmware info, etc. */
const char *(*get_info)(AMP *amp);
setting_t levels;
unsigned ext_levels;
const struct confparams *extlevels;
const struct confparams *extparms;
const char *macro_name;
};
//---Start cut here---
// Amp state structure definition moved to include/hamlib/amp_state.h
// Temporary include until 5.0
#ifndef NO_OLD_INCLUDES
__END_DECLS
#include <hamlib/amp_state.h>
__BEGIN_DECLS
#endif
//---End cut here---
struct amp
{
struct amp_caps *caps;
struct amp_state state;
};
/* --------------- API function prototypes -----------------*/
extern HAMLIB_EXPORT(AMP *)
amp_init HAMLIB_PARAMS((amp_model_t amp_model));
extern HAMLIB_EXPORT(int)
amp_open HAMLIB_PARAMS((AMP *amp));
extern HAMLIB_EXPORT(int)
amp_close HAMLIB_PARAMS((AMP *amp));
extern HAMLIB_EXPORT(int)
amp_cleanup HAMLIB_PARAMS((AMP *amp));
extern HAMLIB_EXPORT(int)
amp_set_conf HAMLIB_PARAMS((AMP *amp,
hamlib_token_t token,
const char *val));
HL_DEPRECATED extern HAMLIB_EXPORT(int)
amp_get_conf HAMLIB_PARAMS((AMP *amp,
hamlib_token_t token,
char *val));
extern HAMLIB_EXPORT(int)
amp_get_conf2 HAMLIB_PARAMS((AMP *amp,
hamlib_token_t token,
char *val,
int val_len));
extern HAMLIB_EXPORT(int)
amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
powerstat_t status));
extern HAMLIB_EXPORT(int)
amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
powerstat_t *status));
/*
* General API commands, from most primitive to least.. )
* List Set/Get functions pairs
*/
extern HAMLIB_EXPORT(int)
amp_get_freq HAMLIB_PARAMS((AMP *amp,
freq_t *freq));
extern HAMLIB_EXPORT(int)
amp_set_freq HAMLIB_PARAMS((AMP *amp,
freq_t freq));
extern HAMLIB_EXPORT(int)
amp_reset HAMLIB_PARAMS((AMP *amp,
amp_reset_t reset));
extern HAMLIB_EXPORT(const char *)
amp_get_info HAMLIB_PARAMS((AMP *amp));
extern HAMLIB_EXPORT(int)
amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
extern HAMLIB_EXPORT(int)
amp_set_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t val));
extern HAMLIB_EXPORT(int)
amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
extern HAMLIB_EXPORT(int)
amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
extern HAMLIB_EXPORT(int)
amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
rig_ptr_t),
rig_ptr_t data));
extern HAMLIB_EXPORT(int)
amp_load_backend HAMLIB_PARAMS((const char *be_name));
extern HAMLIB_EXPORT(int)
amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
extern HAMLIB_EXPORT(int)
amp_load_all_backends HAMLIB_PARAMS((void));
extern HAMLIB_EXPORT(amp_model_t)
amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
extern HAMLIB_EXPORT(int)
amp_token_foreach HAMLIB_PARAMS((AMP *amp,
int (*cfunc)(const struct confparams *,
rig_ptr_t),
rig_ptr_t data));
extern HAMLIB_EXPORT(const struct confparams *)
amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
const char *name));
extern HAMLIB_EXPORT(hamlib_token_t)
amp_token_lookup HAMLIB_PARAMS((AMP *amp,
const char *name));
extern HAMLIB_EXPORT(const struct amp_caps *)
amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
extern HAMLIB_EXPORT(setting_t)
amp_has_get_level HAMLIB_PARAMS((AMP *amp,
setting_t level));
extern HAMLIB_EXPORT(setting_t)
amp_has_set_level HAMLIB_PARAMS((AMP *amp,
setting_t level));
extern HAMLIB_EXPORT(const struct confparams *)
amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
const char *name));
extern HAMLIB_EXPORT(int)
amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
hamlib_token_t token,
value_t *val));
extern HAMLIB_EXPORT(int)
amp_set_ext_level HAMLIB_PARAMS((AMP *amp,
hamlib_token_t token,
value_t val));
extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
extern HAMLIB_EXPORT(const struct confparams *)
rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
const char *name));
extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
extern HAMLIB_EXPORT(void *) amp_data_pointer(AMP *amp, rig_ptrx_t idx);
#define amp_debug rig_debug
__END_DECLS
#endif /* _AMPLIFIER_H */
amp_state.h
Hamlib amplifier state structure.
amplist.h
Hamlib amplifier model definitions.
amp_set_freq
int amp_set_freq(AMP *amp, freq_t freq)
Set the operating frequency of the amplifier.
Definition amplifier.c:688
amp_set_ext_level
int amp_set_ext_level(AMP *amp, hamlib_token_t level, value_t val)
Set the value of a requested extension levels token.
Definition amplifier.c:834
amp_reset
int amp_reset(AMP *amp, amp_reset_t reset)
Reset the amplifier.
Definition amplifier.c:609
swr_t
float swr_t
Type definition for SWR (Standing Wave Ratio).
Definition amplifier.h:80
amp_reset_e
amp_reset_e
Amplifier reset tokens.
Definition amplifier.h:109
amp_set_conf
int amp_set_conf(AMP *amp, hamlib_token_t token, const char *val)
Set an amplifier configuration parameter.
Definition amp_conf.c:682
amp_type_e
amp_type_e
Amplifier type flags.
Definition amplifier.h:117
amp_has_get_level
setting_t amp_has_get_level(AMP *amp, setting_t level)
Check which level settings can be queried.
Definition amp_settings.c:103
amp_token_lookup
hamlib_token_t amp_token_lookup(AMP *amp, const char *name)
Search for the token ID associated with an amplifier configuration parameter token name.
Definition amp_conf.c:647
amp_cleanup
int amp_cleanup(AMP *amp)
Release an AMP handle and free associated memory.
Definition amplifier.c:563
amp_get_conf2
int amp_get_conf2(AMP *amp, hamlib_token_t token, char *val, int val_len)
Query the value of an amplifier configuration parameter.
Definition amp_conf.c:738
amp_token_foreach
int amp_token_foreach(AMP *amp, int(*cfunc)(const struct confparams *, rig_ptr_t), rig_ptr_t data)
Executes cfunc on all the elements stored in the configuration parameters table.
Definition amp_conf.c:523
amp_ext_lookup
const struct confparams * amp_ext_lookup(AMP *amp, const char *name)
Lookup an extension levels or parameters token by its name and return a pointer to the containing con...
Definition extamp.c:172
amp_set_level
int amp_set_level(AMP *amp, setting_t level, value_t val)
Set the value of a requested level.
Definition amplifier.c:761
amp_close
int amp_close(AMP *amp)
Close the communication channel to the amplifier.
Definition amplifier.c:471
amp_set_powerstat
int amp_set_powerstat(AMP *amp, powerstat_t status)
Turn the amplifier On or Off or toggle the Standby or Operate status.
Definition amplifier.c:907
amp_init
AMP * amp_init(amp_model_t amp_model)
Allocate a new AMP handle.
Definition amplifier.c:185
amp_data_pointer
void * amp_data_pointer(AMP *amp, rig_ptrx_t idx)
Get the address of amplifier data structure(s).
Definition amplifier.c:967
amp_has_set_level
setting_t amp_has_set_level(AMP *amp, setting_t level)
Check which level settings can be set.
Definition amp_settings.c:70
amp_type_t
enum amp_type_e amp_type_t
Amplifier type flags.
amp_get_ext_level
int amp_get_ext_level(AMP *amp, hamlib_token_t level, value_t *val)
Query the value of a requested extension levels token.
Definition amplifier.c:869
tune_value_t
int tune_value_t
Type definition for the transmatch tuning values of capacitance and inductance.
Definition amplifier.h:98
amp_confparam_lookup
const struct confparams * amp_confparam_lookup(AMP *amp, const char *name)
Query an amplifier configuration parameter token by its name.
Definition amp_conf.c:586
amp_level_e
amp_level_e
Definition amplifier.h:137
amp_get_powerstat
int amp_get_powerstat(AMP *amp, powerstat_t *status)
Query the power or standby status of the amplifier.
Definition amplifier.c:944
amp_get_level
int amp_get_level(AMP *amp, setting_t level, value_t *val)
Query the value of a requested level.
Definition amplifier.c:798
amp_get_freq
int amp_get_freq(AMP *amp, freq_t *freq)
Query the operating frequency of the amplifier.
Definition amplifier.c:648
AMP
struct amp AMP
Main amplifier handle type definition.
Definition amplifier.h:65
amp_get_info
const char * amp_get_info(AMP *amp)
Query general information from the amplifier.
Definition amplifier.c:723
amp_open
int amp_open(AMP *amp)
Open the communication channel to the amplifier.
Definition amplifier.c:312
amp_reset_t
enum amp_reset_e amp_reset_t
Amplifier reset tokens.
AMP_RESET_FAULT
@ AMP_RESET_FAULT
Definition amplifier.h:111
AMP_RESET_MEM
@ AMP_RESET_MEM
Definition amplifier.h:110
AMP_RESET_AMP
@ AMP_RESET_AMP
Definition amplifier.h:112
AMP_FLAG_1
@ AMP_FLAG_1
Definition amplifier.h:118
AMP_FLAG_2
@ AMP_FLAG_2
Definition amplifier.h:119
AMP_LEVEL_PWR
@ AMP_LEVEL_PWR
Definition amplifier.h:147
AMP_LEVEL_PWR_FWD
@ AMP_LEVEL_PWR_FWD
Definition amplifier.h:143
AMP_LEVEL_NH
@ AMP_LEVEL_NH
Definition amplifier.h:140
AMP_LEVEL_NONE
@ AMP_LEVEL_NONE
Definition amplifier.h:138
AMP_LEVEL_PWR_REFLECTED
@ AMP_LEVEL_PWR_REFLECTED
Definition amplifier.h:144
AMP_LEVEL_PF
@ AMP_LEVEL_PF
Definition amplifier.h:141
AMP_LEVEL_PWR_PEAK
@ AMP_LEVEL_PWR_PEAK
Definition amplifier.h:145
AMP_LEVEL_PWR_INPUT
@ AMP_LEVEL_PWR_INPUT
Definition amplifier.h:142
AMP_LEVEL_SWR
@ AMP_LEVEL_SWR
Definition amplifier.h:139
AMP_LEVEL_FAULT
@ AMP_LEVEL_FAULT
Definition amplifier.h:146
amp_model_t
int amp_model_t
Definition amplist.h:147
hamlib_port_t
struct hamlib_port hamlib_port_t
Port definition.
amp_parse_level
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition misc.c:1160
amp_strlevel
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition misc.c:1251
serial_parity_e
serial_parity_e
Serial parity.
Definition rig.h:348
hamlib_token_t
long hamlib_token_t
configuration token
Definition rig.h:882
setting_t
uint64_t setting_t
Setting bit mask.
Definition rig.h:1223
powerstat_t
powerstat_t
Radio power state.
Definition rig.h:727
freq_t
double freq_t
Frequency type.
Definition rig.h:473
rig_port_e
rig_port_e
Port type.
Definition rig.h:327
serial_handshake_e
serial_handshake_e
Serial handshake.
Definition rig.h:360
RIG_SETTING_MAX
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition rig.h:1229
rig_ext_lookup
const struct confparams * rig_ext_lookup(RIG *rig, const char *name)
lookup ext token by its name, return pointer to confparams struct.
Definition ext.c:231
RIG
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:277
gran_t
struct gran gran_t
gran_t type
Definition rig.h:1760
rig_status_e
rig_status_e
Development status of the backend.
Definition rig.h:432
rig.h
Hamlib rig data structures.
amp_caps
Amplifier capabilities.
Definition amplifier.h:188
amp_caps::get_freq
int(* get_freq)(AMP *amp, freq_t *val)
Definition amplifier.h:232
amp_caps::cfgparams
const struct confparams * cfgparams
Definition amplifier.h:211
amp_caps::post_write_delay
int post_write_delay
Definition amplifier.h:207
amp_caps::set_freq
int(* set_freq)(AMP *amp, freq_t val)
Definition amplifier.h:231
amp_caps::amp_init
int(* amp_init)(AMP *amp)
Definition amplifier.h:226
amp_caps::macro_name
const char * macro_name
Definition amplifier.h:260
amp_caps::amp_open
int(* amp_open)(AMP *amp)
Definition amplifier.h:228
amp_caps::get_ext_level
int(* get_ext_level)(AMP *amp, hamlib_token_t level, value_t *val)
Definition amplifier.h:246
amp_caps::reset
int(* reset)(AMP *amp, amp_reset_t reset)
Definition amplifier.h:243
amp_caps::amp_type
int amp_type
Definition amplifier.h:196
amp_caps::serial_rate_min
int serial_rate_min
Definition amplifier.h:199
amp_caps::amp_model_macro_name
const char * amp_model_macro_name
Definition amplifier.h:213
amp_caps::get_level
int(* get_level)(AMP *amp, setting_t level, value_t *val)
Definition amplifier.h:244
amp_caps::serial_stop_bits
int serial_stop_bits
Definition amplifier.h:202
amp_caps::get_powerstat
int(* get_powerstat)(AMP *amp, powerstat_t *status)
Definition amplifier.h:249
amp_caps::serial_data_bits
int serial_data_bits
Definition amplifier.h:201
amp_caps::get_conf2
int(* get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len)
Definition amplifier.h:235
amp_caps::write_delay
int write_delay
Definition amplifier.h:206
amp_caps::model_name
const char * model_name
Definition amplifier.h:190
amp_caps::level_gran
gran_t level_gran[64]
Definition amplifier.h:218
amp_caps::parm_gran
gran_t parm_gran[64]
Definition amplifier.h:219
amp_caps::amp_cleanup
int(* amp_cleanup)(AMP *amp)
Definition amplifier.h:227
amp_caps::port_type
enum rig_port_e port_type
Definition amplifier.h:197
amp_caps::serial_rate_max
int serial_rate_max
Definition amplifier.h:200
amp_caps::serial_parity
enum serial_parity_e serial_parity
Definition amplifier.h:203
amp_caps::retry
int retry
Definition amplifier.h:209
amp_caps::copyright
const char * copyright
Definition amplifier.h:193
amp_caps::serial_handshake
enum serial_handshake_e serial_handshake
Definition amplifier.h:204
amp_caps::set_powerstat
int(* set_powerstat)(AMP *amp, powerstat_t status)
Definition amplifier.h:248
amp_caps::extlevels
const struct confparams * extlevels
Definition amplifier.h:257
amp_caps::set_level
int(* set_level)(AMP *amp, setting_t level, value_t val)
Definition amplifier.h:245
amp_caps::status
enum rig_status_e status
Definition amplifier.h:194
amp_caps::timeout
int timeout
Definition amplifier.h:208
amp_caps::amp_close
int(* amp_close)(AMP *amp)
Definition amplifier.h:229
amp_caps::levels
setting_t levels
Definition amplifier.h:255
amp_caps::extparms
const struct confparams * extparms
Definition amplifier.h:258
amp_caps::priv
const rig_ptr_t priv
Definition amplifier.h:212
amp_caps::mfg_name
const char * mfg_name
Definition amplifier.h:191
amp_caps::has_get_level
setting_t has_get_level
Definition amplifier.h:215
amp_caps::amp_model
amp_model_t amp_model
Definition amplifier.h:189
amp_caps::version
const char * version
Definition amplifier.h:192
amp_caps::has_set_level
setting_t has_set_level
Definition amplifier.h:216
amp_caps::ext_levels
unsigned ext_levels
Definition amplifier.h:256
amp_caps::set_conf
int(* set_conf)(AMP *amp, hamlib_token_t token, const char *val)
Definition amplifier.h:234
amp_caps::get_conf
int(* get_conf)(AMP *amp, hamlib_token_t token, char *val)
Definition amplifier.h:236
amp_caps::set_ext_level
int(* set_ext_level)(AMP *amp, hamlib_token_t level, value_t val)
Definition amplifier.h:247
amp_state
Amplifier state structure.
Definition amp_state.h:55
amp
Master amplifier structure.
Definition amplifier.h:288
amp::caps
struct amp_caps * caps
Definition amplifier.h:289
amp::state
struct amp_state state
Definition amplifier.h:290
confparams
Configuration parameter structure.
Definition rig.h:922
value_t
Universal approach for passing values.
Definition rig.h:1047