Hamlib  4.0~git
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 
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 
86 typedef enum
87 {
88  AMP_RESET_MEM, // erase tuner memory
89  AMP_RESET_FAULT, // reset any fault
90  AMP_RESET_AMP // for kpa1500
91 } amp_reset_t;
92 
96 typedef enum
97 {
98  AMP_FLAG_1 = (1 << 1),
99  AMP_FLAG_2 = (1 << 2)
100 } amp_type_t;
101 
102 // TBD AMP_TYPE
103 #define AMP_TYPE_MASK (AMP_FLAG_1|AMP_FLAG_2)
104 
105 #define AMP_TYPE_OTHER 0
106 #define AMP_TYPE_1 AMP_FLAG_1
107 #define AMP_TYPE_2 AMP_FLAG_2
108 #define AMP_TYPE_ALL (AMP_FLAG_1|AMP_FLAG_2)
109 
110 
112 {
114  AMP_LEVEL_SWR = (1 << 0),
115  AMP_LEVEL_NH = (1 << 1),
116  AMP_LEVEL_PF = (1 << 2),
117  AMP_LEVEL_PWR_INPUT = (1 << 3),
118  AMP_LEVEL_PWR_FWD = (1 << 4),
120  AMP_LEVEL_PWR_PEAK = (1 << 6),
121  AMP_LEVEL_FAULT = (1 << 7)
122 };
123 
124 #define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
125 #define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
126 #define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
127 #define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
128 
129 /* Basic amp type, can store some useful info about different amplifiers. Each
130  * lib must be able to populate this structure, so we can make useful
131  * enquiries about capablilities.
132  */
133 
151 #define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
152 struct amp_caps
153 {
155  const char *model_name;
156  const char *mfg_name;
157  const char *version;
158  const char *copyright;
161  int amp_type;
173  int timeout;
174  int retry;
176  const struct confparams *cfgparams;
177  const rig_ptr_t priv;
178  const char *amp_model_macro_name;
180  setting_t has_get_level;
181  setting_t has_set_level;
182 
183  gran_t level_gran[RIG_SETTING_MAX];
184  gran_t parm_gran[RIG_SETTING_MAX];
186  /*
187  * Amp Admin API
188  *
189  */
190 
191  int (*amp_init)(AMP *amp);
192  int (*amp_cleanup)(AMP *amp);
193  int (*amp_open)(AMP *amp);
194  int (*amp_close)(AMP *amp);
195 
196  int (*set_freq)(AMP *amp, freq_t val);
197  int (*get_freq)(AMP *amp, freq_t *val);
198 
199  int (*set_conf)(AMP *amp, token_t token, const char *val);
200  int (*get_conf)(AMP *amp, token_t token, char *val);
201 
202  /*
203  * General API commands, from most primitive to least.. :()
204  * List Set/Get functions pairs
205  */
206 
207  int (*reset)(AMP *amp, amp_reset_t reset);
208  int (*get_level)(AMP *amp, setting_t level, value_t *val);
209  int (*get_ext_level)(AMP *amp, token_t level, value_t *val);
210  int (*set_powerstat)(AMP *amp, powerstat_t status);
211  int (*get_powerstat)(AMP *amp, powerstat_t *status);
212 
213 
214  /* get firmware info, etc. */
215  const char *(*get_info)(AMP *amp);
216 
217  setting_t levels;
218  unsigned ext_levels;
219  const struct confparams *extlevels;
220  const struct confparams *extparms;
221 
222  const char *macro_name;
223 };
224 
225 
237 struct amp_state
238 {
239  /*
240  * overridable fields
241  */
242 
243  /*
244  * non overridable fields, internal use
245  */
249  rig_ptr_t priv;
250  rig_ptr_t obj;
252  setting_t has_get_level;
253 
254  gran_t level_gran[RIG_SETTING_MAX];
255  gran_t parm_gran[RIG_SETTING_MAX];
256 };
257 
258 
271 struct amp
272 {
273  struct amp_caps *caps;
274  struct amp_state state;
275 };
276 
277 
278 /* --------------- API function prototypes -----------------*/
279 
280 extern HAMLIB_EXPORT(AMP *)
281 amp_init HAMLIB_PARAMS((amp_model_t amp_model));
282 
283 extern HAMLIB_EXPORT(int)
284 amp_open HAMLIB_PARAMS((AMP *amp));
285 
286 extern HAMLIB_EXPORT(int)
287 amp_close HAMLIB_PARAMS((AMP *amp));
288 
289 extern HAMLIB_EXPORT(int)
290 amp_cleanup HAMLIB_PARAMS((AMP *amp));
291 
292 extern HAMLIB_EXPORT(int)
293 amp_set_conf HAMLIB_PARAMS((AMP *amp,
294  token_t token,
295  const char *val));
296 extern HAMLIB_EXPORT(int)
297 amp_get_conf HAMLIB_PARAMS((AMP *amp,
298  token_t token,
299  char *val));
300 extern HAMLIB_EXPORT(int)
301 amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
302  powerstat_t status));
303 extern HAMLIB_EXPORT(int)
304 amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
305  powerstat_t *status));
306 
307 
308 /*
309  * General API commands, from most primitive to least.. )
310  * List Set/Get functions pairs
311  */
312 extern HAMLIB_EXPORT(int)
313 amp_get_freq HAMLIB_PARAMS((AMP *amp,
314  freq_t *freq));
315 extern HAMLIB_EXPORT(int)
316 amp_set_freq HAMLIB_PARAMS((AMP *amp,
317  freq_t freq));
318 
319 extern HAMLIB_EXPORT(int)
320 amp_reset HAMLIB_PARAMS((AMP *amp,
321  amp_reset_t reset));
322 
323 extern HAMLIB_EXPORT(const char *)
324 amp_get_info HAMLIB_PARAMS((AMP *amp));
325 
326 extern HAMLIB_EXPORT(int)
327 amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
328 
329 extern HAMLIB_EXPORT(int)
330 amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
331 
332 extern HAMLIB_EXPORT(int)
333 amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
334 
335 extern HAMLIB_EXPORT(int)
336 amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
337  rig_ptr_t),
338  rig_ptr_t data));
339 
340 extern HAMLIB_EXPORT(int)
341 amp_load_backend HAMLIB_PARAMS((const char *be_name));
342 
343 extern HAMLIB_EXPORT(int)
344 amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
345 
346 extern HAMLIB_EXPORT(int)
347 amp_load_all_backends HAMLIB_PARAMS((void));
348 
349 extern HAMLIB_EXPORT(amp_model_t)
350 amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
351 
352 extern HAMLIB_EXPORT(int)
353 amp_token_foreach HAMLIB_PARAMS((AMP *amp,
354  int (*cfunc)(const struct confparams *,
355  rig_ptr_t),
356  rig_ptr_t data));
357 
358 extern HAMLIB_EXPORT(const struct confparams *)
359 amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
360  const char *name));
361 
362 extern HAMLIB_EXPORT(token_t)
363 amp_token_lookup HAMLIB_PARAMS((AMP *amp,
364  const char *name));
365 
366 extern HAMLIB_EXPORT(const struct amp_caps *)
367 amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
368 
369 extern HAMLIB_EXPORT(setting_t)
370 amp_has_get_level HAMLIB_PARAMS((AMP *amp,
371  setting_t level));
372 
373 extern HAMLIB_EXPORT(const struct confparams *)
374 amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
375  const char *name));
376 
377 extern HAMLIB_EXPORT(int)
378 amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
379  token_t token,
380  value_t *val));
381 
382 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
383 
384 extern HAMLIB_EXPORT(const struct confparams *)
385 rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
386  const char *name));
387 
388 
398 #define amp_debug rig_debug
399 
400 __END_DECLS
401 
402 #endif /* _AMPLIFIER_H */
403 
enum serial_handshake_e serial_handshake
Definition: amplifier.h:169
Amplifier data structure.
Definition: amplifier.h:152
int amp_set_powerstat(AMP *amp, powerstat_t status)
turn on/off the amplifier or standby/operate toggle
Definition: amplifier.c:674
int amp_set_conf(AMP *amp, token_t token, const char *val)
set a amplifier configuration parameter
Definition: amp_conf.c:584
double freq_t
Frequency type,.
Definition: rig.h:321
int timeout
Definition: amplifier.h:173
int comm_state
Definition: amplifier.h:248
gran_t parm_gran[64]
Definition: amplifier.h:255
long token_t
configuration token
Definition: rig.h:590
const char * copyright
Definition: amplifier.h:158
int serial_rate_max
Definition: amplifier.h:165
int amp_open(AMP *amp)
open the communication to the amp
Definition: amplifier.c:290
const char * model_name
Definition: amplifier.h:155
const char * mfg_name
Definition: amplifier.h:156
int serial_stop_bits
Definition: amplifier.h:167
const char * priv
Definition: amplifier.h:177
int amp_model_t
Convenience type definition for amplifier model.
Definition: amplist.h:99
powerstat_t
Radio power state.
Definition: rig.h:512
int retry
Definition: amplifier.h:174
int amp_reset(AMP *amp, amp_reset_t reset)
reset the amplifier
Definition: amplifier.c:533
amp_type_t
Amplifier type flags.
Definition: amplifier.h:96
token_t amp_token_lookup(AMP *amp, const char *name)
Simple lookup returning token id associated with name.
Definition: amp_conf.c:553
char * obj
Definition: amplifier.h:250
serial_handshake_e
Serial handshake.
Definition: rig.h:228
int write_delay
Definition: amplifier.h:171
gran_t level_gran[64]
Definition: amplifier.h:183
Definition: amplifier.h:113
int serial_data_bits
Definition: amplifier.h:166
Universal approach for passing values.
Definition: rig.h:716
enum rig_status_e status
Definition: amplifier.h:159
float swr_t
Type definition for SWR.
Definition: amplifier.h:66
The Rig structure.
Definition: rig.h:1856
Definition: amplifier.h:115
This is the master data structure, acting as a handle for the controlled amplifier.
Definition: amplifier.h:271
rig_status_e
Development status of the backend.
Definition: rig.h:280
gran_t parm_gran[64]
Definition: amplifier.h:184
int post_write_delay
Definition: amplifier.h:172
AMP * amp_init(amp_model_t amp_model)
allocate a new AMP handle
Definition: amplifier.c:176
Live data and customized fields.
Definition: amplifier.h:237
amp_level_e
Definition: amplifier.h:111
const struct confparams * cfgparams
Definition: amplifier.h:176
setting_t amp_has_get_level(AMP *amp, setting_t level)
check retrieval ability of level settings
Definition: settings.c:330
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
int serial_rate_min
Definition: amplifier.h:164
Definition: amplifier.h:121
hamlib_port_t ampport
Definition: amplifier.h:246
Definition: amplifier.h:118
const char * amp_model_macro_name
Definition: amplifier.h:178
const char * amp_get_info(AMP *amp)
get general information from the amplifier
Definition: amplifier.c:607
Definition: amplifier.h:116
token_t token
Definition: rig.h:626
Definition: amplifier.h:117
serial_parity_e
Serial parity.
Definition: rig.h:216
Definition: amplifier.h:99
Definition: amplifier.h:120
Hamlib rig data structures.
enum serial_parity_e serial_parity
Definition: amplifier.h:168
Definition: amplifier.h:119
struct amp_state state
Definition: amplifier.h:274
int amp_close(AMP *amp)
close the communication to the amp
Definition: amplifier.c:412
level/parm granularity definition
Definition: rig.h:1294
Definition: amplifier.h:114
const char * amp_strlevel(setting_t)
Convert enum AMP_LEVEL_... to alpha string.
Definition: misc.c:794
Definition: amplifier.h:98
gran_t level_gran[64]
Definition: amplifier.h:254
int tune_value_t
Type definition for tuning values capacitance and resistance.
Definition: amplifier.h:77
const char * version
Definition: amplifier.h:157
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_get_conf(AMP *amp, token_t token, char *val)
get the value of a configuration parameter
Definition: amp_conf.c:636
struct amp_caps * caps
Definition: amplifier.h:273
uint64_t setting_t
Setting.
Definition: rig.h:822
enum rig_port_e port_type
Definition: amplifier.h:162
const char * macro_name
Definition: amplifier.h:222
int amp_cleanup(AMP *amp)
release a amp handle and free associated memory
Definition: amplifier.c:491
Port definition.
Definition: rig.h:1655
Configuration parameter structure.
Definition: rig.h:625
rig_port_e
Port type.
Definition: rig.h:195
int amp_type
Definition: amplifier.h:161
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:153
char * priv
Definition: amplifier.h:249
amp_model_t amp_model
Definition: amplifier.h:154

Generated by doxygen 1.8.14

Hamlib documentation for version 4.0~git -- Sat Apr 4 2020 16:42:11
Project page: http://www.hamlib.org