Hamlib 4.7~git
Loading...
Searching...
No Matches
amplifier.h
Go to the documentation of this file.
1/*
2 * Hamlib Interface - Amplifier API header
3 * Copyright (c) 2000-2005 by Stephane Fillod
4 *
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21/* SPDX-License-Identifier: LGPL-2.1-or-later */
22
23#ifndef _AMPLIFIER_H
24#define _AMPLIFIER_H 1
25
26#include <hamlib/rig.h>
27#include <hamlib/amplist.h>
28
33
44
45
46
47__BEGIN_DECLS
48
49/* Forward struct references */
50
51struct amp;
52struct amp_state;
53
54
65typedef struct amp AMP;
66
67
80typedef float swr_t;
81
82
98typedef int tune_value_t;
99
100
104#define NETAMPCTL_RET "RPRT "
105
106
114
116typedef enum amp_type_e
117{
118 AMP_FLAG_1 = (1 << 1),
119 AMP_FLAG_2 = (1 << 2)
121
122// TBD AMP_TYPE
125#define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
126
127#define AMP_TYPE_OTHER 0
128#define AMP_TYPE_1 AMP_FLAG_1
129#define AMP_TYPE_2 AMP_FLAG_2
130#define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
132
133
149
150
152// Not used yet.
153#define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
154#define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
155#define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
156#define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
158
159/* Basic amp type, can store some useful info about different amplifiers. Each
160 * lib must be able to populate this structure, so we can make useful
161 * enquiries about capabilities.
162 */
163
169#define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
170
188{
190 const char *model_name;
191 const char *mfg_name;
192 const char *version;
193 const char *copyright;
195
198
205
209 int retry;
210
211 const struct confparams *cfgparams;
212 const rig_ptr_t priv;
214
217
220
221 /*
222 * Amp Admin API
223 *
224 */
225
226 int (*amp_init)(AMP *amp);
227 int (*amp_cleanup)(AMP *amp);
228 int (*amp_open)(AMP *amp);
229 int (*amp_close)(AMP *amp);
230
231 int (*set_freq)(AMP *amp, freq_t val);
232 int (*get_freq)(AMP *amp, freq_t *val);
233
234 int (*set_conf)(AMP *amp, hamlib_token_t token, const char *val);
235 int (*get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len);
236 int (*get_conf)(AMP *amp, hamlib_token_t token, char *val);
237
238 /*
239 * General API commands, from most primitive to least.. :()
240 * List Set/Get functions pairs
241 */
242
244 int (*get_level)(AMP *amp, setting_t level, value_t *val);
245 int (*set_level)(AMP *amp, setting_t level, value_t val);
250
251
252 /* get firmware info, etc. */
253 const char *(*get_info)(AMP *amp);
254
256 unsigned ext_levels;
257 const struct confparams *extlevels;
258 const struct confparams *extparms;
259
260 const char *macro_name;
261};
262
263//---Start cut here---
264// Amp state structure definition moved to include/hamlib/amp_state.h
265// Temporary include until 5.0
266#ifndef NO_OLD_INCLUDES
267
268__END_DECLS
269
270#include <hamlib/amp_state.h>
271
272__BEGIN_DECLS
273
274#endif
275
276//---End cut here---
287struct amp
288{
289 struct amp_caps *caps;
291};
292
293
295/* --------------- API function prototypes -----------------*/
296
297extern HAMLIB_EXPORT(AMP *)
298amp_init HAMLIB_PARAMS((amp_model_t amp_model));
299
300extern HAMLIB_EXPORT(int)
301amp_open HAMLIB_PARAMS((AMP *amp));
302
303extern HAMLIB_EXPORT(int)
304amp_close HAMLIB_PARAMS((AMP *amp));
305
306extern HAMLIB_EXPORT(int)
307amp_cleanup HAMLIB_PARAMS((AMP *amp));
308
309extern HAMLIB_EXPORT(int)
310amp_set_conf HAMLIB_PARAMS((AMP *amp,
311 hamlib_token_t token,
312 const char *val));
313HL_DEPRECATED extern HAMLIB_EXPORT(int)
314amp_get_conf HAMLIB_PARAMS((AMP *amp,
315 hamlib_token_t token,
316 char *val));
317extern HAMLIB_EXPORT(int)
318amp_get_conf2 HAMLIB_PARAMS((AMP *amp,
319 hamlib_token_t token,
320 char *val,
321 int val_len));
322extern HAMLIB_EXPORT(int)
323amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
324 powerstat_t status));
325extern HAMLIB_EXPORT(int)
326amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
327 powerstat_t *status));
328
329
330/*
331 * General API commands, from most primitive to least.. )
332 * List Set/Get functions pairs
333 */
334extern HAMLIB_EXPORT(int)
335amp_get_freq HAMLIB_PARAMS((AMP *amp,
336 freq_t *freq));
337extern HAMLIB_EXPORT(int)
338amp_set_freq HAMLIB_PARAMS((AMP *amp,
339 freq_t freq));
340
341extern HAMLIB_EXPORT(int)
342amp_reset HAMLIB_PARAMS((AMP *amp,
343 amp_reset_t reset));
344
345extern HAMLIB_EXPORT(const char *)
346amp_get_info HAMLIB_PARAMS((AMP *amp));
347
348extern HAMLIB_EXPORT(int)
349amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
350
351extern HAMLIB_EXPORT(int)
352amp_set_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t val));
353
354
355extern HAMLIB_EXPORT(int)
356amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
357
358extern HAMLIB_EXPORT(int)
359amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
360
361extern HAMLIB_EXPORT(int)
362amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
363 rig_ptr_t),
364 rig_ptr_t data));
365
366extern HAMLIB_EXPORT(int)
367amp_load_backend HAMLIB_PARAMS((const char *be_name));
368
369extern HAMLIB_EXPORT(int)
370amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
371
372extern HAMLIB_EXPORT(int)
373amp_load_all_backends HAMLIB_PARAMS((void));
374
375extern HAMLIB_EXPORT(amp_model_t)
376amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
377
378extern HAMLIB_EXPORT(int)
379amp_token_foreach HAMLIB_PARAMS((AMP *amp,
380 int (*cfunc)(const struct confparams *,
381 rig_ptr_t),
382 rig_ptr_t data));
383
384extern HAMLIB_EXPORT(const struct confparams *)
385amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
386 const char *name));
387
388extern HAMLIB_EXPORT(hamlib_token_t)
389amp_token_lookup HAMLIB_PARAMS((AMP *amp,
390 const char *name));
391
392extern HAMLIB_EXPORT(const struct amp_caps *)
393amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
394
395extern HAMLIB_EXPORT(setting_t)
396amp_has_get_level HAMLIB_PARAMS((AMP *amp,
397 setting_t level));
398
399extern HAMLIB_EXPORT(setting_t)
400amp_has_set_level HAMLIB_PARAMS((AMP *amp,
401 setting_t level));
402
403extern HAMLIB_EXPORT(const struct confparams *)
404amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
405 const char *name));
406
407extern HAMLIB_EXPORT(int)
408amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
409 hamlib_token_t token,
410 value_t *val));
411
412extern HAMLIB_EXPORT(int)
413amp_set_ext_level HAMLIB_PARAMS((AMP *amp,
414 hamlib_token_t token,
415 value_t val));
416
417extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
418
419extern HAMLIB_EXPORT(const struct confparams *)
420rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
421 const char *name));
422
423extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
424extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
425
426extern HAMLIB_EXPORT(void *) amp_data_pointer(AMP *amp, rig_ptrx_t idx);
427
429
430
437#define amp_debug rig_debug
438
439__END_DECLS
440
441#endif /* _AMPLIFIER_H */
442
Hamlib amplifier state structure.
Hamlib amplifier model definitions.
int amp_set_freq(AMP *amp, freq_t freq)
Set the operating frequency of the amplifier.
Definition amplifier.c:687
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:833
int amp_reset(AMP *amp, amp_reset_t reset)
Reset the amplifier.
Definition amplifier.c:608
float swr_t
Type definition for SWR (Standing Wave Ratio).
Definition amplifier.h:80
amp_reset_e
Amplifier reset tokens.
Definition amplifier.h:109
int amp_set_conf(AMP *amp, hamlib_token_t token, const char *val)
Set an amplifier configuration parameter.
Definition amp_conf.c:681
amp_type_e
Amplifier type flags.
Definition amplifier.h:117
setting_t amp_has_get_level(AMP *amp, setting_t level)
Check which level settings can be queried.
Definition amp_settings.c:103
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:646
int amp_cleanup(AMP *amp)
Release an AMP handle and free associated memory.
Definition amplifier.c:562
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:737
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:522
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
int amp_set_level(AMP *amp, setting_t level, value_t val)
Set the value of a requested level.
Definition amplifier.c:760
int amp_close(AMP *amp)
Close the communication channel to the amplifier.
Definition amplifier.c:470
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:906
AMP * amp_init(amp_model_t amp_model)
Allocate a new AMP handle.
Definition amplifier.c:184
void * amp_data_pointer(AMP *amp, rig_ptrx_t idx)
Get the address of amplifier data structure(s)
Definition amplifier.c:966
setting_t amp_has_set_level(AMP *amp, setting_t level)
Check which level settings can be set.
Definition amp_settings.c:70
enum amp_type_e amp_type_t
Amplifier type flags.
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:868
int tune_value_t
Type definition for the transmatch tuning values of capacitance and inductance.
Definition amplifier.h:98
const struct confparams * amp_confparam_lookup(AMP *amp, const char *name)
Query an amplifier configuration parameter token by its name.
Definition amp_conf.c:585
amp_level_e
Definition amplifier.h:137
int amp_get_powerstat(AMP *amp, powerstat_t *status)
Query the power or standby status of the amplifier.
Definition amplifier.c:943
int amp_get_level(AMP *amp, setting_t level, value_t *val)
Query the value of a requested level.
Definition amplifier.c:797
int amp_get_freq(AMP *amp, freq_t *freq)
Query the operating frequency of the amplifier.
Definition amplifier.c:647
struct amp AMP
Main amplifier handle type definition.
Definition amplifier.h:65
const char * amp_get_info(AMP *amp)
Query general information from the amplifier.
Definition amplifier.c:722
int amp_open(AMP *amp)
Open the communication channel to the amplifier.
Definition amplifier.c:311
enum amp_reset_e amp_reset_t
Amplifier reset tokens.
@ AMP_RESET_FAULT
Definition amplifier.h:111
@ AMP_RESET_MEM
Definition amplifier.h:110
@ AMP_RESET_AMP
Definition amplifier.h:112
@ AMP_FLAG_1
Definition amplifier.h:118
@ AMP_FLAG_2
Definition amplifier.h:119
@ AMP_LEVEL_PWR
Definition amplifier.h:147
@ AMP_LEVEL_PWR_FWD
Definition amplifier.h:143
@ AMP_LEVEL_NH
Definition amplifier.h:140
@ AMP_LEVEL_NONE
Definition amplifier.h:138
@ AMP_LEVEL_PWR_REFLECTED
Definition amplifier.h:144
@ AMP_LEVEL_PF
Definition amplifier.h:141
@ AMP_LEVEL_PWR_PEAK
Definition amplifier.h:145
@ AMP_LEVEL_PWR_INPUT
Definition amplifier.h:142
@ AMP_LEVEL_SWR
Definition amplifier.h:139
@ AMP_LEVEL_FAULT
Definition amplifier.h:146
int amp_model_t
Definition amplist.h:147
struct hamlib_port hamlib_port_t
Port definition.
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition misc.c:1151
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition misc.c:1242
serial_parity_e
Serial parity.
Definition rig.h:359
long hamlib_token_t
configuration token
Definition rig.h:893
uint64_t setting_t
Setting bit mask.
Definition rig.h:1234
powerstat_t
Radio power state.
Definition rig.h:738
double freq_t
Frequency type.
Definition rig.h:484
rig_port_e
Port type.
Definition rig.h:338
serial_handshake_e
Serial handshake.
Definition rig.h:371
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition rig.h:1240
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
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:290
struct gran gran_t
gran_t type
Definition rig.h:1771
rig_status_e
Development status of the backend.
Definition rig.h:443
Hamlib rig data structures.
Amplifier capabilities.
Definition amplifier.h:188
int(* get_freq)(AMP *amp, freq_t *val)
Definition amplifier.h:232
const struct confparams * cfgparams
Definition amplifier.h:211
int post_write_delay
Definition amplifier.h:207
int(* set_freq)(AMP *amp, freq_t val)
Definition amplifier.h:231
int(* amp_init)(AMP *amp)
Definition amplifier.h:226
const char * macro_name
Definition amplifier.h:260
int(* amp_open)(AMP *amp)
Definition amplifier.h:228
int(* get_ext_level)(AMP *amp, hamlib_token_t level, value_t *val)
Definition amplifier.h:246
int(* reset)(AMP *amp, amp_reset_t reset)
Definition amplifier.h:243
int amp_type
Definition amplifier.h:196
int serial_rate_min
Definition amplifier.h:199
const char * amp_model_macro_name
Definition amplifier.h:213
int(* get_level)(AMP *amp, setting_t level, value_t *val)
Definition amplifier.h:244
int serial_stop_bits
Definition amplifier.h:202
int(* get_powerstat)(AMP *amp, powerstat_t *status)
Definition amplifier.h:249
int serial_data_bits
Definition amplifier.h:201
int(* get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len)
Definition amplifier.h:235
int write_delay
Definition amplifier.h:206
const char * model_name
Definition amplifier.h:190
gran_t level_gran[64]
Definition amplifier.h:218
gran_t parm_gran[64]
Definition amplifier.h:219
int(* amp_cleanup)(AMP *amp)
Definition amplifier.h:227
enum rig_port_e port_type
Definition amplifier.h:197
int serial_rate_max
Definition amplifier.h:200
enum serial_parity_e serial_parity
Definition amplifier.h:203
int retry
Definition amplifier.h:209
const char * copyright
Definition amplifier.h:193
enum serial_handshake_e serial_handshake
Definition amplifier.h:204
int(* set_powerstat)(AMP *amp, powerstat_t status)
Definition amplifier.h:248
const struct confparams * extlevels
Definition amplifier.h:257
int(* set_level)(AMP *amp, setting_t level, value_t val)
Definition amplifier.h:245
enum rig_status_e status
Definition amplifier.h:194
int timeout
Definition amplifier.h:208
int(* amp_close)(AMP *amp)
Definition amplifier.h:229
setting_t levels
Definition amplifier.h:255
const struct confparams * extparms
Definition amplifier.h:258
const rig_ptr_t priv
Definition amplifier.h:212
const char * mfg_name
Definition amplifier.h:191
setting_t has_get_level
Definition amplifier.h:215
amp_model_t amp_model
Definition amplifier.h:189
const char * version
Definition amplifier.h:192
setting_t has_set_level
Definition amplifier.h:216
unsigned ext_levels
Definition amplifier.h:256
int(* set_conf)(AMP *amp, hamlib_token_t token, const char *val)
Definition amplifier.h:234
int(* get_conf)(AMP *amp, hamlib_token_t token, char *val)
Definition amplifier.h:236
int(* set_ext_level)(AMP *amp, hamlib_token_t level, value_t val)
Definition amplifier.h:247
Amplifier state structure.
Definition amp_state.h:55
Master amplifier structure.
Definition amplifier.h:288
struct amp_caps * caps
Definition amplifier.h:289
struct amp_state state
Definition amplifier.h:290
Configuration parameter structure.
Definition rig.h:933
Universal approach for passing values.
Definition rig.h:1058