Hamlib 4.4
amplifier.h
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
22#ifndef _AMPLIFIER_H
23#define _AMPLIFIER_H 1
24
25#include <hamlib/rig.h>
26#include <hamlib/amplist.h>
27
46__BEGIN_DECLS
47
48/* Forward struct references */
49
50struct amp;
51struct amp_state;
52
53
64typedef struct amp AMP;
65
66
80typedef float swr_t;
81
82
100typedef int tune_value_t;
101
102
106#define NETAMPCTL_RET "RPRT "
107
108
110typedef enum
111{
112 AMP_RESET_MEM, // erase tuner memory
113 AMP_RESET_FAULT, // reset any fault
114 AMP_RESET_AMP // for kpa1500
115} amp_reset_t;
117
121typedef enum
122{
123 AMP_FLAG_1 = (1 << 1),
124 AMP_FLAG_2 = (1 << 2)
125} amp_type_t;
126
128// TBD AMP_TYPE
129#define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
130
131#define AMP_TYPE_OTHER 0
132#define AMP_TYPE_1 AMP_FLAG_1
133#define AMP_TYPE_2 AMP_FLAG_2
134#define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
136
137
139enum amp_level_e
140{
141 AMP_LEVEL_NONE = 0,
142 AMP_LEVEL_SWR = (1 << 0),
143 AMP_LEVEL_NH = (1 << 1),
144 AMP_LEVEL_PF = (1 << 2),
145 AMP_LEVEL_PWR_INPUT = (1 << 3),
146 AMP_LEVEL_PWR_FWD = (1 << 4),
147 AMP_LEVEL_PWR_REFLECTED = (1 << 5),
148 AMP_LEVEL_PWR_PEAK = (1 << 6),
149 AMP_LEVEL_FAULT = (1 << 7)
150};
152
154#define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
155#define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
156#define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
157#define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
159
160/* Basic amp type, can store some useful info about different amplifiers. Each
161 * lib must be able to populate this structure, so we can make useful
162 * enquiries about capabilities.
163 */
164
166#define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
168
187struct amp_caps
188{
189 amp_model_t amp_model;
190 const char *model_name;
191 const char *mfg_name;
192 const char *version;
193 const char *copyright;
194 enum rig_status_e status;
196 int amp_type;
197 enum rig_port_e port_type;
199 int serial_rate_min;
200 int serial_rate_max;
201 int serial_data_bits;
202 int serial_stop_bits;
203 enum serial_parity_e serial_parity;
204 enum serial_handshake_e serial_handshake;
206 int write_delay;
207 int post_write_delay;
208 int timeout;
209 int retry;
211 const struct confparams *cfgparams;
212 const rig_ptr_t priv;
213 const char *amp_model_macro_name;
215 setting_t has_get_level;
216 setting_t has_set_level;
218 gran_t level_gran[RIG_SETTING_MAX];
219 gran_t parm_gran[RIG_SETTING_MAX];
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);
231 int (*set_freq)(AMP *amp, freq_t val);
232 int (*get_freq)(AMP *amp, freq_t *val);
234 int (*set_conf)(AMP *amp, token_t token, const char *val);
235 int (*get_conf)(AMP *amp, token_t token, char *val);
237 /*
238 * General API commands, from most primitive to least.. :()
239 * List Set/Get functions pairs
240 */
241
242 int (*reset)(AMP *amp, amp_reset_t reset);
243 int (*get_level)(AMP *amp, setting_t level, value_t *val);
244 int (*get_ext_level)(AMP *amp, token_t level, value_t *val);
245 int (*set_powerstat)(AMP *amp, powerstat_t status);
246 int (*get_powerstat)(AMP *amp, powerstat_t *status);
249 /* get firmware info, etc. */
250 const char *(*get_info)(AMP *amp);
253 setting_t levels;
254 unsigned ext_levels;
256 const struct confparams *extlevels;
257 const struct confparams *extparms;
259 const char *macro_name;
260};
261
262
274struct amp_state
275{
276 /*
277 * overridable fields
278 */
279
280 /*
281 * non overridable fields, internal use
282 */
283 hamlib_port_t ampport;
285 int comm_state;
286 rig_ptr_t priv;
287 rig_ptr_t obj;
289 setting_t has_get_level;
291 gran_t level_gran[RIG_SETTING_MAX];
292 gran_t parm_gran[RIG_SETTING_MAX];
293};
294
295
308struct amp
309{
310 struct amp_caps *caps;
311 struct amp_state state;
312};
313
314
316/* --------------- API function prototypes -----------------*/
317
318extern HAMLIB_EXPORT(AMP *)
319amp_init HAMLIB_PARAMS((amp_model_t amp_model));
320
321extern HAMLIB_EXPORT(int)
322amp_open HAMLIB_PARAMS((AMP *amp));
323
324extern HAMLIB_EXPORT(int)
325amp_close HAMLIB_PARAMS((AMP *amp));
326
327extern HAMLIB_EXPORT(int)
328amp_cleanup HAMLIB_PARAMS((AMP *amp));
329
330extern HAMLIB_EXPORT(int)
331amp_set_conf HAMLIB_PARAMS((AMP *amp,
332 token_t token,
333 const char *val));
334extern HAMLIB_EXPORT(int)
335amp_get_conf HAMLIB_PARAMS((AMP *amp,
336 token_t token,
337 char *val));
338extern HAMLIB_EXPORT(int)
339amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
340 powerstat_t status));
341extern HAMLIB_EXPORT(int)
342amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
343 powerstat_t *status));
344
345
346/*
347 * General API commands, from most primitive to least.. )
348 * List Set/Get functions pairs
349 */
350extern HAMLIB_EXPORT(int)
351amp_get_freq HAMLIB_PARAMS((AMP *amp,
352 freq_t *freq));
353extern HAMLIB_EXPORT(int)
354amp_set_freq HAMLIB_PARAMS((AMP *amp,
355 freq_t freq));
356
357extern HAMLIB_EXPORT(int)
358amp_reset HAMLIB_PARAMS((AMP *amp,
359 amp_reset_t reset));
360
361extern HAMLIB_EXPORT(const char *)
362amp_get_info HAMLIB_PARAMS((AMP *amp));
363
364extern HAMLIB_EXPORT(int)
365amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
366
367extern HAMLIB_EXPORT(int)
368amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
369
370extern HAMLIB_EXPORT(int)
371amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
372
373extern HAMLIB_EXPORT(int)
374amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
375 rig_ptr_t),
376 rig_ptr_t data));
377
378extern HAMLIB_EXPORT(int)
379amp_load_backend HAMLIB_PARAMS((const char *be_name));
380
381extern HAMLIB_EXPORT(int)
382amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
383
384extern HAMLIB_EXPORT(int)
385amp_load_all_backends HAMLIB_PARAMS((void));
386
387extern HAMLIB_EXPORT(amp_model_t)
388amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
389
390extern HAMLIB_EXPORT(int)
391amp_token_foreach HAMLIB_PARAMS((AMP *amp,
392 int (*cfunc)(const struct confparams *,
393 rig_ptr_t),
394 rig_ptr_t data));
395
396extern HAMLIB_EXPORT(const struct confparams *)
397amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
398 const char *name));
399
400extern HAMLIB_EXPORT(token_t)
401amp_token_lookup HAMLIB_PARAMS((AMP *amp,
402 const char *name));
403
404extern HAMLIB_EXPORT(const struct amp_caps *)
405amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
406
407extern HAMLIB_EXPORT(setting_t)
408amp_has_get_level HAMLIB_PARAMS((AMP *amp,
409 setting_t level));
410
411extern HAMLIB_EXPORT(const struct confparams *)
412amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
413 const char *name));
414
415extern HAMLIB_EXPORT(int)
416amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
417 token_t token,
418 value_t *val));
419
420extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
421
422extern HAMLIB_EXPORT(const struct confparams *)
423rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
424 const char *name));
425
426extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
427extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
428
430
431
440#define amp_debug rig_debug
441
442__END_DECLS
443
444#endif /* _AMPLIFIER_H */
445
Hamlib amplifier model definitions.
int amp_set_freq(AMP *amp, freq_t freq)
Set the operating frequency of the amplifier.
Definition: amplifier.c:644
int amp_reset(AMP *amp, amp_reset_t reset)
Reset the amplifier.
Definition: amplifier.c:565
int amp_set_conf(AMP *amp, token_t token, const char *val)
Set an amplifier configuration parameter.
Definition: amp_conf.c:644
setting_t amp_has_get_level(AMP *amp, setting_t level)
Check which level settings can be queried.
Definition: amp_settings.c:73
int amp_cleanup(AMP *amp)
Release an #AMP handle and free associated memory.
Definition: amplifier.c:519
int amp_model_t
Convenience type definition for an amplifier model.
Definition: amplist.h:115
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:180
int amp_close(AMP *amp)
Close the communication channel to the amplifier.
Definition: amplifier.c:437
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:791
AMP * amp_init(amp_model_t amp_model)
Allocate a new #AMP handle.
Definition: amplifier.c:185
int amp_get_conf(AMP *amp, token_t token, char *val)
Query the value of an amplifier configuration parameter.
Definition: amp_conf.c:700
const struct confparams * amp_confparam_lookup(AMP *amp, const char *name)
Query an amplifier configuration parameter token by its name.
Definition: amp_conf.c:548
int amp_get_powerstat(AMP *amp, powerstat_t *status)
Query the power or standby status of the amplifier.
Definition: amplifier.c:828
int amp_get_ext_level(AMP *amp, token_t level, value_t *val)
Query the value of a requested extension levels token.
Definition: amplifier.c:753
int amp_get_level(AMP *amp, setting_t level, value_t *val)
Query the value of a requested level.
Definition: amplifier.c:717
int amp_get_freq(AMP *amp, freq_t *freq)
Query the operating frequency of the amplifier.
Definition: amplifier.c:604
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:609
const char * amp_get_info(AMP *amp)
Query general information from the amplifier.
Definition: amplifier.c:679
int amp_open(AMP *amp)
Open the communication channel to the amplifier.
Definition: amplifier.c:301
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition: misc.c:977
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition: misc.c:1068
serial_parity_e
Serial parity.
Definition: rig.h:261
token_t token
Definition: rig.h:739
uint64_t setting_t
Setting.
Definition: rig.h:1036
powerstat_t
Radio power state.
Definition: rig.h:621
double freq_t
Frequency type,.
Definition: rig.h:368
rig_port_e
Port type.
Definition: rig.h:240
serial_handshake_e
Serial handshake.
Definition: rig.h:273
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition: rig.h:1042
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:236
struct s_rig RIG
Rig structure definition (see rig for details).
Definition: rig.h:196
long token_t
configuration token
Definition: rig.h:699
rig_status_e
Development status of the backend.
Definition: rig.h:327
Hamlib rig data structures.
Configuration parameter structure.
Definition: rig.h:738
level/parm granularity definition
Definition: rig.h:1550
Universal approach for passing values.
Definition: rig.h:875