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 *macro_name;
157  const char *mfg_name;
158  const char *version;
159  const char *copyright;
162  int amp_type;
174  int timeout;
175  int retry;
177  const struct confparams *cfgparams;
178  const rig_ptr_t priv;
179  const char *amp_model_macro_name;
181  setting_t has_get_level;
182  setting_t has_set_level;
183 
184  gran_t level_gran[RIG_SETTING_MAX];
185  gran_t parm_gran[RIG_SETTING_MAX];
187  /*
188  * Amp Admin API
189  *
190  */
191 
192  int (*amp_init)(AMP *amp);
193  int (*amp_cleanup)(AMP *amp);
194  int (*amp_open)(AMP *amp);
195  int (*amp_close)(AMP *amp);
196 
197  int (*set_freq)(AMP *amp, freq_t val);
198  int (*get_freq)(AMP *amp, freq_t *val);
199 
200  int (*set_conf)(AMP *amp, token_t token, const char *val);
201  int (*get_conf)(AMP *amp, token_t token, char *val);
202 
203  /*
204  * General API commands, from most primitive to least.. :()
205  * List Set/Get functions pairs
206  */
207 
208  int (*reset)(AMP *amp, amp_reset_t reset);
209  int (*get_level)(AMP *amp, setting_t level, value_t *val);
210  int (*get_ext_level)(AMP *amp, token_t level, value_t *val);
211  int (*set_powerstat)(AMP *amp, powerstat_t status);
212  int (*get_powerstat)(AMP *amp, powerstat_t *status);
213 
214 
215  /* get firmware info, etc. */
216  const char *(*get_info)(AMP *amp);
217 
218  setting_t levels;
219  unsigned ext_levels;
220  const struct confparams *extlevels;
221  const struct confparams *extparms;
222 };
223 
224 
236 struct amp_state
237 {
238  /*
239  * overridable fields
240  */
241 
242  /*
243  * non overridable fields, internal use
244  */
248  rig_ptr_t priv;
249  rig_ptr_t obj;
251  setting_t has_get_level;
252 
253  gran_t level_gran[RIG_SETTING_MAX];
254  gran_t parm_gran[RIG_SETTING_MAX];
255 };
256 
257 
270 struct amp
271 {
272  struct amp_caps *caps;
273  struct amp_state state;
274 };
275 
276 
277 /* --------------- API function prototypes -----------------*/
278 
279 extern HAMLIB_EXPORT(AMP *)
280 amp_init HAMLIB_PARAMS((amp_model_t amp_model));
281 
282 extern HAMLIB_EXPORT(int)
283 amp_open HAMLIB_PARAMS((AMP *amp));
284 
285 extern HAMLIB_EXPORT(int)
286 amp_close HAMLIB_PARAMS((AMP *amp));
287 
288 extern HAMLIB_EXPORT(int)
289 amp_cleanup HAMLIB_PARAMS((AMP *amp));
290 
291 extern HAMLIB_EXPORT(int)
292 amp_set_conf HAMLIB_PARAMS((AMP *amp,
293  token_t token,
294  const char *val));
295 extern HAMLIB_EXPORT(int)
296 amp_get_conf HAMLIB_PARAMS((AMP *amp,
297  token_t token,
298  char *val));
299 extern HAMLIB_EXPORT(int)
300 amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
301  powerstat_t status));
302 extern HAMLIB_EXPORT(int)
303 amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
304  powerstat_t *status));
305 
306 
307 /*
308  * General API commands, from most primitive to least.. )
309  * List Set/Get functions pairs
310  */
311 extern HAMLIB_EXPORT(int)
312 amp_get_freq HAMLIB_PARAMS((AMP *amp,
313  freq_t *freq));
314 extern HAMLIB_EXPORT(int)
315 amp_set_freq HAMLIB_PARAMS((AMP *amp,
316  freq_t freq));
317 
318 extern HAMLIB_EXPORT(int)
319 amp_reset HAMLIB_PARAMS((AMP *amp,
320  amp_reset_t reset));
321 
322 extern HAMLIB_EXPORT(const char *)
323 amp_get_info HAMLIB_PARAMS((AMP *amp));
324 
325 extern HAMLIB_EXPORT(int)
326 amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
327 
328 extern HAMLIB_EXPORT(int)
329 amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
330 
331 extern HAMLIB_EXPORT(int)
332 amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
333 
334 extern HAMLIB_EXPORT(int)
335 amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
336  rig_ptr_t),
337  rig_ptr_t data));
338 
339 extern HAMLIB_EXPORT(int)
340 amp_load_backend HAMLIB_PARAMS((const char *be_name));
341 
342 extern HAMLIB_EXPORT(int)
343 amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
344 
345 extern HAMLIB_EXPORT(int)
346 amp_load_all_backends HAMLIB_PARAMS((void));
347 
348 extern HAMLIB_EXPORT(amp_model_t)
349 amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
350 
351 extern HAMLIB_EXPORT(int)
352 amp_token_foreach HAMLIB_PARAMS((AMP *amp,
353  int (*cfunc)(const struct confparams *,
354  rig_ptr_t),
355  rig_ptr_t data));
356 
357 extern HAMLIB_EXPORT(const struct confparams *)
358 amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
359  const char *name));
360 
361 extern HAMLIB_EXPORT(token_t)
362 amp_token_lookup HAMLIB_PARAMS((AMP *amp,
363  const char *name));
364 
365 extern HAMLIB_EXPORT(const struct amp_caps *)
366 amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
367 
368 extern HAMLIB_EXPORT(setting_t)
369 amp_has_get_level HAMLIB_PARAMS((AMP *amp,
370  setting_t level));
371 
372 extern HAMLIB_EXPORT(const struct confparams *)
373 amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
374  const char *name));
375 
376 extern HAMLIB_EXPORT(int)
377 amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
378  token_t token,
379  value_t *val));
380 
381 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
382 
383 extern HAMLIB_EXPORT(const struct confparams *)
384 rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
385  const char *name));
386 
387 
397 #define amp_debug rig_debug
398 
399 __END_DECLS
400 
401 #endif /* _AMPLIFIER_H */
402 
rig_port_e
rig_port_e
Port type.
Definition: rig.h:195
hamlib_port
Port definition.
Definition: rig.h:1656
amp_model_t
int amp_model_t
Convenience type definition for amplifier model.
Definition: amplist.h:99
amp_set_conf
int amp_set_conf(AMP *amp, token_t token, const char *val)
set a amplifier configuration parameter
Definition: amp_conf.c:584
AMP_LEVEL_NONE
@ AMP_LEVEL_NONE
Definition: amplifier.h:113
amp_open
int amp_open(AMP *amp)
open the communication to the amp
Definition: amplifier.c:290
amp_caps::serial_rate_max
int serial_rate_max
Definition: amplifier.h:166
rig
The Rig structure.
Definition: rig.h:1857
amp_set_powerstat
int amp_set_powerstat(AMP *amp, powerstat_t status)
turn on/off the amplifier or standby/operate toggle
Definition: amplifier.c:674
AMP_LEVEL_SWR
@ AMP_LEVEL_SWR
Definition: amplifier.h:114
amp_strlevel
const char *HAMLIB_API amp_strlevel(setting_t)
Convert enum AMP_LEVEL_... to alpha string.
Definition: misc.c:796
AMP_LEVEL_PWR_PEAK
@ AMP_LEVEL_PWR_PEAK
Definition: amplifier.h:120
rig_status_e
rig_status_e
Development status of the backend.
Definition: rig.h:280
amp_caps::copyright
const char * copyright
Definition: amplifier.h:159
amp_caps::amp_type
int amp_type
Definition: amplifier.h:162
amp_caps::mfg_name
const char * mfg_name
Definition: amplifier.h:157
amp::state
struct amp_state state
Definition: amplifier.h:273
amp_caps
Amplifier data structure.
Definition: amplifier.h:152
amp_caps::version
const char * version
Definition: amplifier.h:158
confparams
Configuration parameter structure.
Definition: rig.h:625
rig_ext_lookup
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
amp_caps::amp_model_macro_name
const char * amp_model_macro_name
Definition: amplifier.h:179
amp_caps::retry
int retry
Definition: amplifier.h:175
AMP_LEVEL_NH
@ AMP_LEVEL_NH
Definition: amplifier.h:115
AMP_FLAG_1
@ AMP_FLAG_1
Definition: amplifier.h:98
AMP_LEVEL_PF
@ AMP_LEVEL_PF
Definition: amplifier.h:116
amp_state::comm_state
int comm_state
Definition: amplifier.h:247
powerstat_t
powerstat_t
Radio power state.
Definition: rig.h:512
amp_caps::amp_model
amp_model_t amp_model
Definition: amplifier.h:154
freq_t
double freq_t
Frequency type,.
Definition: rig.h:321
AMP_LEVEL_FAULT
@ AMP_LEVEL_FAULT
Definition: amplifier.h:121
amp_caps::serial_data_bits
int serial_data_bits
Definition: amplifier.h:167
amp_state::obj
char * obj
Definition: amplifier.h:249
amp_caps::priv
const char * priv
Definition: amplifier.h:178
amp_level_e
amp_level_e
Definition: amplifier.h:111
serial_handshake_e
serial_handshake_e
Serial handshake.
Definition: rig.h:228
value_t
Universal approach for passing values.
Definition: rig.h:716
amp_state
Live data and customized fields.
Definition: amplifier.h:236
amp_caps::timeout
int timeout
Definition: amplifier.h:174
amp_get_info
const char * amp_get_info(AMP *amp)
get general information from the amplifier
Definition: amplifier.c:607
amp_caps::level_gran
gran_t level_gran[64]
Definition: amplifier.h:184
amp_caps::status
enum rig_status_e status
Definition: amplifier.h:160
amp::caps
struct amp_caps * caps
Definition: amplifier.h:272
amp_caps::post_write_delay
int post_write_delay
Definition: amplifier.h:173
amp_caps::cfgparams
const struct confparams * cfgparams
Definition: amplifier.h:177
rig.h
Hamlib rig data structures.
amp_reset
int amp_reset(AMP *amp, amp_reset_t reset)
reset the amplifier
Definition: amplifier.c:533
AMP_FLAG_2
@ AMP_FLAG_2
Definition: amplifier.h:99
amp_token_lookup
token_t amp_token_lookup(AMP *amp, const char *name)
Simple lookup returning token id associated with name.
Definition: amp_conf.c:553
amp_close
int amp_close(AMP *amp)
close the communication to the amp
Definition: amplifier.c:412
amp_type_t
amp_type_t
Amplifier type flags.
Definition: amplifier.h:96
amp
This is the master data structure, acting as a handle for the controlled amplifier.
Definition: amplifier.h:270
amp_state::ampport
hamlib_port_t ampport
Definition: amplifier.h:245
amp_caps::write_delay
int write_delay
Definition: amplifier.h:172
amp_confparam_lookup
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
swr_t
float swr_t
Type definition for SWR.
Definition: amplifier.h:66
amp_caps::parm_gran
gran_t parm_gran[64]
Definition: amplifier.h:185
amp_init
AMP * amp_init(amp_model_t amp_model)
allocate a new AMP handle
Definition: amplifier.c:176
amp_caps::serial_parity
enum serial_parity_e serial_parity
Definition: amplifier.h:169
serial_parity_e
serial_parity_e
Serial parity.
Definition: rig.h:216
confparams::token
token_t token
Definition: rig.h:626
amp_caps::serial_handshake
enum serial_handshake_e serial_handshake
Definition: amplifier.h:170
amp_caps::macro_name
const char * macro_name
Definition: amplifier.h:156
amp_state::level_gran
gran_t level_gran[64]
Definition: amplifier.h:253
amp_caps::serial_stop_bits
int serial_stop_bits
Definition: amplifier.h:168
tune_value_t
int tune_value_t
Type definition for tuning values capacitance and resistance.
Definition: amplifier.h:77
AMP_LEVEL_PWR_FWD
@ AMP_LEVEL_PWR_FWD
Definition: amplifier.h:118
token_t
long token_t
configuration token
Definition: rig.h:590
amp_get_conf
int amp_get_conf(AMP *amp, token_t token, char *val)
get the value of a configuration parameter
Definition: amp_conf.c:636
amp_ext_lookup
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_LEVEL_PWR_REFLECTED
@ AMP_LEVEL_PWR_REFLECTED
Definition: amplifier.h:119
amp_state::priv
char * priv
Definition: amplifier.h:248
AMP_LEVEL_PWR_INPUT
@ AMP_LEVEL_PWR_INPUT
Definition: amplifier.h:117
amp_caps::model_name
const char * model_name
Definition: amplifier.h:155
amp_has_get_level
setting_t amp_has_get_level(AMP *amp, setting_t level)
check retrieval ability of level settings
Definition: settings.c:330
setting_t
uint64_t setting_t
Setting.
Definition: rig.h:823
amp_caps::port_type
enum rig_port_e port_type
Definition: amplifier.h:163
amp_caps::serial_rate_min
int serial_rate_min
Definition: amplifier.h:165
gran
level/parm granularity definition
Definition: rig.h:1295
amp_state::parm_gran
gran_t parm_gran[64]
Definition: amplifier.h:254
amp_cleanup
int amp_cleanup(AMP *amp)
release a amp handle and free associated memory
Definition: amplifier.c:491

Generated by doxygen 1.8.17

Hamlib documentation for version 4.0~git -- Sun Apr 5 2020 00:00:00
Project page: http://www.hamlib.org