Hamlib  4.1
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 
22 #ifndef _AMPLIFIER_H
23 #define _AMPLIFIER_H 1
24 
25 #include <hamlib/rig.h>
26 #include <hamlib/amplist.h>
27 
43 __BEGIN_DECLS
44 
45 /* Forward struct references */
46 
47 struct amp;
48 struct amp_state;
49 
50 
55 typedef struct amp AMP;
56 
57 
66 typedef float swr_t;
67 
68 
77 typedef int tune_value_t;
78 
79 
83 #define NETAMPCTL_RET "RPRT "
84 
85 
87 typedef enum
88 {
89  AMP_RESET_MEM, // erase tuner memory
90  AMP_RESET_FAULT, // reset any fault
91  AMP_RESET_AMP // for kpa1500
92 } amp_reset_t;
94 
98 typedef enum
99 {
100  AMP_FLAG_1 = (1 << 1),
101  AMP_FLAG_2 = (1 << 2)
103 
105 // TBD AMP_TYPE
106 #define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
107 
108 #define AMP_TYPE_OTHER 0
109 #define AMP_TYPE_1 AMP_FLAG_1
110 #define AMP_TYPE_2 AMP_FLAG_2
111 #define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
113 
114 
116 enum amp_level_e
117 {
118  AMP_LEVEL_NONE = 0,
119  AMP_LEVEL_SWR = (1 << 0),
120  AMP_LEVEL_NH = (1 << 1),
121  AMP_LEVEL_PF = (1 << 2),
122  AMP_LEVEL_PWR_INPUT = (1 << 3),
123  AMP_LEVEL_PWR_FWD = (1 << 4),
124  AMP_LEVEL_PWR_REFLECTED = (1 << 5),
125  AMP_LEVEL_PWR_PEAK = (1 << 6),
126  AMP_LEVEL_FAULT = (1 << 7)
127 };
129 
131 #define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
132 #define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
133 #define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
134 #define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
136 
137 /* Basic amp type, can store some useful info about different amplifiers. Each
138  * lib must be able to populate this structure, so we can make useful
139  * enquiries about capabilities.
140  */
141 
160 #define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
161 struct amp_caps
162 {
163  amp_model_t amp_model;
164  const char *model_name;
165  const char *mfg_name;
166  const char *version;
167  const char *copyright;
168  enum rig_status_e status;
170  int amp_type;
171  enum rig_port_e port_type;
173  int serial_rate_min;
174  int serial_rate_max;
175  int serial_data_bits;
176  int serial_stop_bits;
177  enum serial_parity_e serial_parity;
178  enum serial_handshake_e serial_handshake;
180  int write_delay;
181  int post_write_delay;
182  int timeout;
183  int retry;
185  const struct confparams *cfgparams;
186  const rig_ptr_t priv;
187  const char *amp_model_macro_name;
189  setting_t has_get_level;
190  setting_t has_set_level;
191 
192  gran_t level_gran[RIG_SETTING_MAX];
193  gran_t parm_gran[RIG_SETTING_MAX];
195  /*
196  * Amp Admin API
197  *
198  */
199 
200  int (*amp_init)(AMP *amp);
201  int (*amp_cleanup)(AMP *amp);
202  int (*amp_open)(AMP *amp);
203  int (*amp_close)(AMP *amp);
204 
205  int (*set_freq)(AMP *amp, freq_t val);
206  int (*get_freq)(AMP *amp, freq_t *val);
207 
208  int (*set_conf)(AMP *amp, token_t token, const char *val);
209  int (*get_conf)(AMP *amp, token_t token, char *val);
210 
211  /*
212  * General API commands, from most primitive to least.. :()
213  * List Set/Get functions pairs
214  */
215 
216  int (*reset)(AMP *amp, amp_reset_t reset);
217  int (*get_level)(AMP *amp, setting_t level, value_t *val);
218  int (*get_ext_level)(AMP *amp, token_t level, value_t *val);
219  int (*set_powerstat)(AMP *amp, powerstat_t status);
220  int (*get_powerstat)(AMP *amp, powerstat_t *status);
221 
222 
223  /* get firmware info, etc. */
224  const char *(*get_info)(AMP *amp);
225 
226  setting_t levels;
227  unsigned ext_levels;
228  const struct confparams *extlevels;
229  const struct confparams *extparms;
230 
231  const char *macro_name;
232 };
234 
235 
247 struct amp_state
248 {
249  /*
250  * overridable fields
251  */
252 
253  /*
254  * non overridable fields, internal use
255  */
256  hamlib_port_t ampport;
259  rig_ptr_t priv;
260  rig_ptr_t obj;
263  setting_t has_get_level;
265 
268 };
269 
270 
283 struct amp
284 {
285  struct amp_caps *caps;
286  struct amp_state state;
287 };
288 
289 
291 /* --------------- API function prototypes -----------------*/
292 
293 extern HAMLIB_EXPORT(AMP *)
294 amp_init HAMLIB_PARAMS((amp_model_t amp_model));
295 
296 extern HAMLIB_EXPORT(int)
297 amp_open HAMLIB_PARAMS((AMP *amp));
298 
299 extern HAMLIB_EXPORT(int)
300 amp_close HAMLIB_PARAMS((AMP *amp));
301 
302 extern HAMLIB_EXPORT(int)
303 amp_cleanup HAMLIB_PARAMS((AMP *amp));
304 
305 extern HAMLIB_EXPORT(int)
306 amp_set_conf HAMLIB_PARAMS((AMP *amp,
307  token_t token,
308  const char *val));
309 extern HAMLIB_EXPORT(int)
310 amp_get_conf HAMLIB_PARAMS((AMP *amp,
311  token_t token,
312  char *val));
313 extern HAMLIB_EXPORT(int)
314 amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
315  powerstat_t status));
316 extern HAMLIB_EXPORT(int)
317 amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
318  powerstat_t *status));
319 
320 
321 /*
322  * General API commands, from most primitive to least.. )
323  * List Set/Get functions pairs
324  */
325 extern HAMLIB_EXPORT(int)
326 amp_get_freq HAMLIB_PARAMS((AMP *amp,
327  freq_t *freq));
328 extern HAMLIB_EXPORT(int)
329 amp_set_freq HAMLIB_PARAMS((AMP *amp,
330  freq_t freq));
331 
332 extern HAMLIB_EXPORT(int)
333 amp_reset HAMLIB_PARAMS((AMP *amp,
334  amp_reset_t reset));
335 
336 extern HAMLIB_EXPORT(const char *)
337 amp_get_info HAMLIB_PARAMS((AMP *amp));
338 
339 extern HAMLIB_EXPORT(int)
340 amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
341 
342 extern HAMLIB_EXPORT(int)
343 amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
344 
345 extern HAMLIB_EXPORT(int)
346 amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
347 
348 extern HAMLIB_EXPORT(int)
349 amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
350  rig_ptr_t),
351  rig_ptr_t data));
352 
353 extern HAMLIB_EXPORT(int)
354 amp_load_backend HAMLIB_PARAMS((const char *be_name));
355 
356 extern HAMLIB_EXPORT(int)
357 amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
358 
359 extern HAMLIB_EXPORT(int)
360 amp_load_all_backends HAMLIB_PARAMS((void));
361 
362 extern HAMLIB_EXPORT(amp_model_t)
363 amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
364 
365 extern HAMLIB_EXPORT(int)
366 amp_token_foreach HAMLIB_PARAMS((AMP *amp,
367  int (*cfunc)(const struct confparams *,
368  rig_ptr_t),
369  rig_ptr_t data));
370 
371 extern HAMLIB_EXPORT(const struct confparams *)
372 amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
373  const char *name));
374 
375 extern HAMLIB_EXPORT(token_t)
376 amp_token_lookup HAMLIB_PARAMS((AMP *amp,
377  const char *name));
378 
379 extern HAMLIB_EXPORT(const struct amp_caps *)
380 amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
381 
382 extern HAMLIB_EXPORT(setting_t)
383 amp_has_get_level HAMLIB_PARAMS((AMP *amp,
384  setting_t level));
385 
386 extern HAMLIB_EXPORT(const struct confparams *)
387 amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
388  const char *name));
389 
390 extern HAMLIB_EXPORT(int)
391 amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
392  token_t token,
393  value_t *val));
394 
395 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
396 
397 extern HAMLIB_EXPORT(const struct confparams *)
398 rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
399  const char *name));
400 
401 extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
402 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
403 
405 
406 
416 #define amp_debug rig_debug
417 
418 __END_DECLS
419 
420 #endif /* _AMPLIFIER_H */
421 
float swr_t
Type definition for SWR.
Definition: amplifier.h:66
amp_type_t
Amplifier type flags.
Definition: amplifier.h:99
int tune_value_t
Type definition for tuning values capacitance and resistance.
Definition: amplifier.h:77
const struct confparams * amp_ext_lookup(AMP *amp, const char *name)
lookup ext token by its name, return pointer to confparams struct.
Definition: extamp.c:155
@ AMP_FLAG_1
Definition: amplifier.h:100
@ AMP_FLAG_2
Definition: amplifier.h:101
const char * amp_get_info(AMP *amp)
get general information from the amplifier
Definition: amplifier.c:622
int amp_reset(AMP *amp, amp_reset_t reset)
reset the amplifier
Definition: amplifier.c:543
int amp_set_conf(AMP *amp, token_t token, const char *val)
set a amplifier configuration parameter
Definition: amp_conf.c:584
AMP * amp_init(amp_model_t amp_model)
allocate a new AMP handle
Definition: amplifier.c:177
setting_t amp_has_get_level(AMP *amp, setting_t level)
check retrieval ability of level settings
Definition: amp_settings.c:62
int amp_cleanup(AMP *amp)
release a amp handle and free associated memory
Definition: amplifier.c:501
int amp_close(AMP *amp)
close the communication to the amp
Definition: amplifier.c:422
int amp_set_powerstat(AMP *amp, powerstat_t status)
turn on/off the amplifier or standby/operate toggle
Definition: amplifier.c:693
int amp_get_conf(AMP *amp, token_t token, char *val)
get the value of a configuration parameter
Definition: amp_conf.c:636
token_t amp_token_lookup(AMP *amp, const char *name)
Simple lookup returning token id associated with name.
Definition: amp_conf.c:553
const struct confparams * amp_confparam_lookup(AMP *amp, const char *name)
lookup conf token by its name, return pointer to confparams struct.
Definition: amp_conf.c:500
int amp_open(AMP *amp)
open the communication to the amp
Definition: amplifier.c:290
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition: misc.c:946
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition: misc.c:1037
serial_parity_e
Serial parity.
Definition: rig.h:228
uint64_t setting_t
Setting.
Definition: rig.h:964
powerstat_t
Radio power state.
Definition: rig.h:574
double freq_t
Frequency type,.
Definition: rig.h:335
rig_port_e
Port type.
Definition: rig.h:207
serial_handshake_e
Serial handshake.
Definition: rig.h:240
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition: rig.h:970
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
long token_t
configuration token
Definition: rig.h:652
rig_status_e
Development status of the backend.
Definition: rig.h:294
Hamlib rig data structures.
Amplifier data structure.
Live data and customized fields.
Definition: amplifier.h:248
gran_t level_gran[64]
Definition: amplifier.h:266
int comm_state
Definition: amplifier.h:258
hamlib_port_t ampport
Definition: amplifier.h:256
gran_t parm_gran[64]
Definition: amplifier.h:267
rig_ptr_t obj
Definition: amplifier.h:260
rig_ptr_t priv
Definition: amplifier.h:259
This is the master data structure, acting as a handle for the controlled amplifier.
Definition: amplifier.h:284
struct amp_caps * caps
Definition: amplifier.h:285
struct amp_state state
Definition: amplifier.h:286
Configuration parameter structure.
Definition: rig.h:691
token_t token
Definition: rig.h:692
level/parm granularity definition
Definition: rig.h:1478
The Rig structure.
Definition: rig.h:2260
Universal approach for passing values.
Definition: rig.h:828

Generated by doxygen 1.9.1

Hamlib documentation for version 4.1 -- Mon Feb 1 2021 08:00:28
Project page: http://www.hamlib.org