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
81typedef float swr_t;
82
83
101typedef int tune_value_t;
102
103
107#define NETAMPCTL_RET "RPRT "
108
109
111typedef enum
112{
113 AMP_RESET_MEM, // erase tuner memory
114 AMP_RESET_FAULT, // reset any fault
115 AMP_RESET_AMP // for kpa1500
116} amp_reset_t;
118
122typedef enum
123{
124 AMP_FLAG_1 = (1 << 1),
125 AMP_FLAG_2 = (1 << 2)
126} amp_type_t;
127
129// TBD AMP_TYPE
130#define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
131
132#define AMP_TYPE_OTHER 0
133#define AMP_TYPE_1 AMP_FLAG_1
134#define AMP_TYPE_2 AMP_FLAG_2
135#define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
137
138
140enum amp_level_e
141{
142 AMP_LEVEL_NONE = 0,
143 AMP_LEVEL_SWR = (1 << 0),
144 AMP_LEVEL_NH = (1 << 1),
145 AMP_LEVEL_PF = (1 << 2),
146 AMP_LEVEL_PWR_INPUT = (1 << 3),
147 AMP_LEVEL_PWR_FWD = (1 << 4),
148 AMP_LEVEL_PWR_REFLECTED = (1 << 5),
149 AMP_LEVEL_PWR_PEAK = (1 << 6),
150 AMP_LEVEL_FAULT = (1 << 7),
151 AMP_LEVEL_PWR = (1 << 8),
152};
154
156#define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
157#define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
158#define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
159#define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
161
162/* Basic amp type, can store some useful info about different amplifiers. Each
163 * lib must be able to populate this structure, so we can make useful
164 * enquiries about capabilities.
165 */
166
168#define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
170
190{
192 const char *model_name;
193 const char *mfg_name;
194 const char *version;
195 const char *copyright;
197
200
207
211 int retry;
212
213 const struct confparams *cfgparams;
214 const rig_ptr_t priv;
216
219
222
223 /*
224 * Amp Admin API
225 *
226 */
227
228 int (*amp_init)(AMP *amp);
229 int (*amp_cleanup)(AMP *amp);
230 int (*amp_open)(AMP *amp);
231 int (*amp_close)(AMP *amp);
232
233 int (*set_freq)(AMP *amp, freq_t val);
234 int (*get_freq)(AMP *amp, freq_t *val);
235
236 int (*set_conf)(AMP *amp, hamlib_token_t token, const char *val);
237 int (*get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len);
238 int (*get_conf)(AMP *amp, hamlib_token_t token, char *val);
239
240 /*
241 * General API commands, from most primitive to least.. :()
242 * List Set/Get functions pairs
243 */
244
245 int (*reset)(AMP *amp, amp_reset_t reset);
246 int (*get_level)(AMP *amp, setting_t level, value_t *val);
247 int (*set_level)(AMP *amp, setting_t level, value_t val);
252
253
254 /* get firmware info, etc. */
255 const char *(*get_info)(AMP *amp);
256
258 setting_t levels;
259 unsigned ext_levels;
261 const struct confparams *extlevels;
262 const struct confparams *extparms;
263
264 const char *macro_name;
265};
266
267
280{
281 /*
282 * overridable fields
283 */
284
285 /*
286 * non overridable fields, internal use
287 */
288 hamlib_port_t_deprecated ampport_deprecated;
289
291 rig_ptr_t priv;
292 rig_ptr_t obj;
293
296
299 hamlib_port_t ampport;
300};
301
302
315struct amp
316{
317 struct amp_caps *caps;
319};
320
321
323/* --------------- API function prototypes -----------------*/
324
325extern HAMLIB_EXPORT(AMP *)
326amp_init HAMLIB_PARAMS((amp_model_t amp_model));
327
328extern HAMLIB_EXPORT(int)
329amp_open HAMLIB_PARAMS((AMP *amp));
330
331extern HAMLIB_EXPORT(int)
332amp_close HAMLIB_PARAMS((AMP *amp));
333
334extern HAMLIB_EXPORT(int)
335amp_cleanup HAMLIB_PARAMS((AMP *amp));
336
337extern HAMLIB_EXPORT(int)
338amp_set_conf HAMLIB_PARAMS((AMP *amp,
339 hamlib_token_t token,
340 const char *val));
341extern HAMLIB_EXPORT(int)
342amp_get_conf HAMLIB_PARAMS((AMP *amp,
343 hamlib_token_t token,
344 char *val));
345extern HAMLIB_EXPORT(int)
346amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
347 powerstat_t status));
348extern HAMLIB_EXPORT(int)
349amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
350 powerstat_t *status));
351
352
353/*
354 * General API commands, from most primitive to least.. )
355 * List Set/Get functions pairs
356 */
357extern HAMLIB_EXPORT(int)
358amp_get_freq HAMLIB_PARAMS((AMP *amp,
359 freq_t *freq));
360extern HAMLIB_EXPORT(int)
361amp_set_freq HAMLIB_PARAMS((AMP *amp,
362 freq_t freq));
363
364extern HAMLIB_EXPORT(int)
365amp_reset HAMLIB_PARAMS((AMP *amp,
366 amp_reset_t reset));
367
368extern HAMLIB_EXPORT(const char *)
369amp_get_info HAMLIB_PARAMS((AMP *amp));
370
371extern HAMLIB_EXPORT(int)
372amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
373
374extern HAMLIB_EXPORT(int)
375amp_set_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t val));
376
377
378extern HAMLIB_EXPORT(int)
379amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
380
381extern HAMLIB_EXPORT(int)
382amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
383
384extern HAMLIB_EXPORT(int)
385amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
386 rig_ptr_t),
387 rig_ptr_t data));
388
389extern HAMLIB_EXPORT(int)
390amp_load_backend HAMLIB_PARAMS((const char *be_name));
391
392extern HAMLIB_EXPORT(int)
393amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
394
395extern HAMLIB_EXPORT(int)
396amp_load_all_backends HAMLIB_PARAMS((void));
397
398extern HAMLIB_EXPORT(amp_model_t)
399amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
400
401extern HAMLIB_EXPORT(int)
402amp_token_foreach HAMLIB_PARAMS((AMP *amp,
403 int (*cfunc)(const struct confparams *,
404 rig_ptr_t),
405 rig_ptr_t data));
406
407extern HAMLIB_EXPORT(const struct confparams *)
408amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
409 const char *name));
410
411extern HAMLIB_EXPORT(hamlib_token_t)
412amp_token_lookup HAMLIB_PARAMS((AMP *amp,
413 const char *name));
414
415extern HAMLIB_EXPORT(const struct amp_caps *)
416amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
417
418extern HAMLIB_EXPORT(setting_t)
419amp_has_get_level HAMLIB_PARAMS((AMP *amp,
420 setting_t level));
421
422extern HAMLIB_EXPORT(setting_t)
423amp_has_set_level HAMLIB_PARAMS((AMP *amp,
424 setting_t level));
425
426extern HAMLIB_EXPORT(const struct confparams *)
427amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
428 const char *name));
429
430extern HAMLIB_EXPORT(int)
431amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
432 hamlib_token_t token,
433 value_t *val));
434
435extern HAMLIB_EXPORT(int)
436amp_set_ext_level HAMLIB_PARAMS((AMP *amp,
437 hamlib_token_t token,
438 value_t val));
439
440extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
441
442extern HAMLIB_EXPORT(const struct confparams *)
443rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
444 const char *name));
445
446extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
447extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
448
449extern HAMLIB_EXPORT(void *) amp_data_pointer(AMP *amp, rig_ptrx_t idx);
450
452
453
462#define amp_debug rig_debug
463
464__END_DECLS
465
466#endif /* _AMPLIFIER_H */
467
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:81
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_t
Amplifier type flags.
Definition amplifier.h:123
setting_t amp_has_get_level(AMP *amp, setting_t level)
Check which level settings can be queried.
Definition amp_settings.c:102
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_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
int amp_model_t
Convenience type definition for an amplifier model.
Definition amplist.h:124
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:176
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:69
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:101
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
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
@ AMP_FLAG_1
Definition amplifier.h:124
@ AMP_FLAG_2
Definition amplifier.h:125
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition misc.c:1148
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition misc.c:1239
serial_parity_e
Serial parity.
Definition rig.h:331
long hamlib_token_t
configuration token
Definition rig.h:859
uint64_t setting_t
Setting.
Definition rig.h:1201
powerstat_t
Radio power state.
Definition rig.h:708
double freq_t
Frequency type,.
Definition rig.h:456
rig_port_e
Port type.
Definition rig.h:310
serial_handshake_e
Serial handshake.
Definition rig.h:343
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition rig.h:1207
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:232
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:262
struct gran gran_t
gran_t type
Definition rig.h:1738
rig_status_e
Development status of the backend.
Definition rig.h:415
Hamlib rig data structures.
Amplifier capabilities.
Definition amplifier.h:190
int(* get_freq)(AMP *amp, freq_t *val)
Definition amplifier.h:234
const struct confparams * cfgparams
Definition amplifier.h:213
int post_write_delay
Definition amplifier.h:209
int(* set_freq)(AMP *amp, freq_t val)
Definition amplifier.h:233
int(* amp_init)(AMP *amp)
Definition amplifier.h:228
const char * macro_name
Definition amplifier.h:264
int(* amp_open)(AMP *amp)
Definition amplifier.h:230
int(* get_ext_level)(AMP *amp, hamlib_token_t level, value_t *val)
Definition amplifier.h:248
int(* reset)(AMP *amp, amp_reset_t reset)
Definition amplifier.h:245
int amp_type
Definition amplifier.h:198
int serial_rate_min
Definition amplifier.h:201
const char * amp_model_macro_name
Definition amplifier.h:215
int(* get_level)(AMP *amp, setting_t level, value_t *val)
Definition amplifier.h:246
int serial_stop_bits
Definition amplifier.h:204
int(* get_powerstat)(AMP *amp, powerstat_t *status)
Definition amplifier.h:251
int serial_data_bits
Definition amplifier.h:203
int(* get_conf2)(AMP *amp, hamlib_token_t token, char *val, int val_len)
Definition amplifier.h:237
int write_delay
Definition amplifier.h:208
const char * model_name
Definition amplifier.h:192
gran_t level_gran[64]
Definition amplifier.h:220
gran_t parm_gran[64]
Definition amplifier.h:221
int(* amp_cleanup)(AMP *amp)
Definition amplifier.h:229
enum rig_port_e port_type
Definition amplifier.h:199
int serial_rate_max
Definition amplifier.h:202
enum serial_parity_e serial_parity
Definition amplifier.h:205
int retry
Definition amplifier.h:211
const char * copyright
Definition amplifier.h:195
enum serial_handshake_e serial_handshake
Definition amplifier.h:206
int(* set_powerstat)(AMP *amp, powerstat_t status)
Definition amplifier.h:250
const struct confparams * extlevels
Definition amplifier.h:261
int(* set_level)(AMP *amp, setting_t level, value_t val)
Definition amplifier.h:247
enum rig_status_e status
Definition amplifier.h:196
int timeout
Definition amplifier.h:210
int(* amp_close)(AMP *amp)
Definition amplifier.h:231
const struct confparams * extparms
Definition amplifier.h:262
const rig_ptr_t priv
Definition amplifier.h:214
const char * mfg_name
Definition amplifier.h:193
setting_t has_get_level
Definition amplifier.h:217
amp_model_t amp_model
Definition amplifier.h:191
const char * version
Definition amplifier.h:194
setting_t has_set_level
Definition amplifier.h:218
int(* set_conf)(AMP *amp, hamlib_token_t token, const char *val)
Definition amplifier.h:236
int(* get_conf)(AMP *amp, hamlib_token_t token, char *val)
Definition amplifier.h:238
int(* set_ext_level)(AMP *amp, hamlib_token_t level, value_t val)
Definition amplifier.h:249
Amplifier state structure.
Definition amplifier.h:280
gran_t level_gran[64]
Definition amplifier.h:297
int comm_state
Definition amplifier.h:290
hamlib_port_t ampport
Definition amplifier.h:299
setting_t has_set_level
Definition amplifier.h:295
gran_t parm_gran[64]
Definition amplifier.h:298
rig_ptr_t obj
Definition amplifier.h:292
rig_ptr_t priv
Definition amplifier.h:291
setting_t has_get_level
Definition amplifier.h:294
hamlib_port_t_deprecated ampport_deprecated
Definition amplifier.h:288
Master amplifier structure.
Definition amplifier.h:316
struct amp_caps * caps
Definition amplifier.h:317
struct amp_state state
Definition amplifier.h:318
Configuration parameter structure.
Definition rig.h:900
Universal approach for passing values.
Definition rig.h:1025