Hamlib  4.5.5
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 
46 __BEGIN_DECLS
47 
48 /* Forward struct references */
49 
50 struct amp;
51 struct amp_state;
52 
53 
64 typedef struct amp AMP;
65 
66 
80 typedef float swr_t;
81 
82 
100 typedef int tune_value_t;
101 
102 
106 #define NETAMPCTL_RET "RPRT "
107 
108 
110 typedef 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 
121 typedef 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)
135 
137 
139 enum 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  AMP_LEVEL_PWR = (1 << 8),
151 };
153 
155 #define AMP_LEVEL_FLOAT_LIST (AMP_LEVEL_SWR)
156 #define AMP_LEVEL_STRING_LIST (AMP_LEVEL_FAULT)
157 #define AMP_LEVEL_IS_FLOAT(l) ((l)&AMP_LEVEL_FLOAT_LIST)
158 #define AMP_LEVEL_IS_STRING(l) ((l)&AMP_LEVEL_STRING_LIST)
159 
161 /* Basic amp type, can store some useful info about different amplifiers. Each
162  * lib must be able to populate this structure, so we can make useful
163  * enquiries about capabilities.
164  */
165 
167 #define AMP_MODEL(arg) .amp_model=arg,.macro_name=#arg
168 
188 struct amp_caps
189 {
191  const char *model_name;
192  const char *mfg_name;
193  const char *version;
194  const char *copyright;
197  int amp_type;
209  int timeout;
210  int retry;
212  const struct confparams *cfgparams;
213  const rig_ptr_t priv;
214  const char *amp_model_macro_name;
222  /*
223  * Amp Admin API
224  *
225  */
226 
227  int (*amp_init)(AMP *amp);
228  int (*amp_cleanup)(AMP *amp);
229  int (*amp_open)(AMP *amp);
230  int (*amp_close)(AMP *amp);
232  int (*set_freq)(AMP *amp, freq_t val);
233  int (*get_freq)(AMP *amp, freq_t *val);
235  int (*set_conf)(AMP *amp, token_t token, const char *val);
236  int (*get_conf2)(AMP *amp, token_t token, char *val, int val_len);
237  int (*get_conf)(AMP *amp, token_t token, char *val);
239  /*
240  * General API commands, from most primitive to least.. :()
241  * List Set/Get functions pairs
242  */
243 
244  int (*reset)(AMP *amp, amp_reset_t reset);
245  int (*get_level)(AMP *amp, setting_t level, value_t *val);
246  int (*set_level)(AMP *amp, setting_t level, value_t val);
247  int (*get_ext_level)(AMP *amp, token_t level, value_t *val);
248  int (*set_ext_level)(AMP *amp, token_t level, value_t val);
253  /* get firmware info, etc. */
254  const char *(*get_info)(AMP *amp);
256  setting_t levels;
258  unsigned ext_levels;
260  const struct confparams *extlevels;
261  const struct confparams *extparms;
263  const char *macro_name;
264 };
265 
266 
278 struct amp_state
279 {
280  /*
281  * overridable fields
282  */
283 
284  /*
285  * non overridable fields, internal use
286  */
287  hamlib_port_t_deprecated ampport_deprecated;
290  rig_ptr_t priv;
291  rig_ptr_t obj;
298  hamlib_port_t ampport;
299 };
300 
301 
314 struct amp
315 {
316  struct amp_caps *caps;
317  struct amp_state state;
318 };
319 
320 
322 /* --------------- API function prototypes -----------------*/
323 
324 extern HAMLIB_EXPORT(AMP *)
325 amp_init HAMLIB_PARAMS((amp_model_t amp_model));
326 
327 extern HAMLIB_EXPORT(int)
328 amp_open HAMLIB_PARAMS((AMP *amp));
329 
330 extern HAMLIB_EXPORT(int)
331 amp_close HAMLIB_PARAMS((AMP *amp));
332 
333 extern HAMLIB_EXPORT(int)
334 amp_cleanup HAMLIB_PARAMS((AMP *amp));
335 
336 extern HAMLIB_EXPORT(int)
337 amp_set_conf HAMLIB_PARAMS((AMP *amp,
338  token_t token,
339  const char *val));
340 extern HAMLIB_EXPORT(int)
341 amp_get_conf HAMLIB_PARAMS((AMP *amp,
342  token_t token,
343  char *val));
344 extern HAMLIB_EXPORT(int)
345 amp_set_powerstat HAMLIB_PARAMS((AMP *amp,
346  powerstat_t status));
347 extern HAMLIB_EXPORT(int)
348 amp_get_powerstat HAMLIB_PARAMS((AMP *amp,
349  powerstat_t *status));
350 
351 
352 /*
353  * General API commands, from most primitive to least.. )
354  * List Set/Get functions pairs
355  */
356 extern HAMLIB_EXPORT(int)
357 amp_get_freq HAMLIB_PARAMS((AMP *amp,
358  freq_t *freq));
359 extern HAMLIB_EXPORT(int)
360 amp_set_freq HAMLIB_PARAMS((AMP *amp,
361  freq_t freq));
362 
363 extern HAMLIB_EXPORT(int)
364 amp_reset HAMLIB_PARAMS((AMP *amp,
365  amp_reset_t reset));
366 
367 extern HAMLIB_EXPORT(const char *)
368 amp_get_info HAMLIB_PARAMS((AMP *amp));
369 
370 extern HAMLIB_EXPORT(int)
371 amp_get_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t *val));
372 
373 extern HAMLIB_EXPORT(int)
374 amp_set_level HAMLIB_PARAMS((AMP *amp, setting_t level, value_t val));
375 
376 
377 extern HAMLIB_EXPORT(int)
378 amp_register HAMLIB_PARAMS((const struct amp_caps *caps));
379 
380 extern HAMLIB_EXPORT(int)
381 amp_unregister HAMLIB_PARAMS((amp_model_t amp_model));
382 
383 extern HAMLIB_EXPORT(int)
384 amp_list_foreach HAMLIB_PARAMS((int (*cfunc)(const struct amp_caps *,
385  rig_ptr_t),
386  rig_ptr_t data));
387 
388 extern HAMLIB_EXPORT(int)
389 amp_load_backend HAMLIB_PARAMS((const char *be_name));
390 
391 extern HAMLIB_EXPORT(int)
392 amp_check_backend HAMLIB_PARAMS((amp_model_t amp_model));
393 
394 extern HAMLIB_EXPORT(int)
395 amp_load_all_backends HAMLIB_PARAMS((void));
396 
397 extern HAMLIB_EXPORT(amp_model_t)
398 amp_probe_all HAMLIB_PARAMS((hamlib_port_t *p));
399 
400 extern HAMLIB_EXPORT(int)
401 amp_token_foreach HAMLIB_PARAMS((AMP *amp,
402  int (*cfunc)(const struct confparams *,
403  rig_ptr_t),
404  rig_ptr_t data));
405 
406 extern HAMLIB_EXPORT(const struct confparams *)
407 amp_confparam_lookup HAMLIB_PARAMS((AMP *amp,
408  const char *name));
409 
410 extern HAMLIB_EXPORT(token_t)
411 amp_token_lookup HAMLIB_PARAMS((AMP *amp,
412  const char *name));
413 
414 extern HAMLIB_EXPORT(const struct amp_caps *)
415 amp_get_caps HAMLIB_PARAMS((amp_model_t amp_model));
416 
417 extern HAMLIB_EXPORT(setting_t)
418 amp_has_get_level HAMLIB_PARAMS((AMP *amp,
419  setting_t level));
420 
421 extern HAMLIB_EXPORT(setting_t)
422 amp_has_set_level HAMLIB_PARAMS((AMP *amp,
423  setting_t level));
424 
425 extern HAMLIB_EXPORT(const struct confparams *)
426 amp_ext_lookup HAMLIB_PARAMS((AMP *amp,
427  const char *name));
428 
429 extern HAMLIB_EXPORT(int)
430 amp_get_ext_level HAMLIB_PARAMS((AMP *amp,
431  token_t token,
432  value_t *val));
433 
434 extern HAMLIB_EXPORT(int)
435 amp_set_ext_level HAMLIB_PARAMS((AMP *amp,
436  token_t token,
437  value_t val));
438 
439 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
440 
441 extern HAMLIB_EXPORT(const struct confparams *)
442 rig_ext_lookup HAMLIB_PARAMS((RIG *rig,
443  const char *name));
444 
445 extern HAMLIB_EXPORT(setting_t) amp_parse_level(const char *s);
446 extern HAMLIB_EXPORT(const char *) amp_strlevel(setting_t);
447 
449 
450 
459 #define amp_debug rig_debug
460 
461 __END_DECLS
462 
463 #endif /* _AMPLIFIER_H */
464 
rig_port_e
rig_port_e
Port type.
Definition: rig.h:264
amp_model_t
int amp_model_t
Convenience type definition for an amplifier model.
Definition: amplist.h:119
amp_set_conf
int amp_set_conf(AMP *amp, token_t token, const char *val)
Set an amplifier configuration parameter.
Definition: amp_conf.c:654
s_rig
The Rig structure.
Definition: rig.h:2662
amp_open
int amp_open(AMP *amp)
Open the communication channel to the amplifier.
Definition: amplifier.c:305
amp_caps::serial_rate_max
int serial_rate_max
Definition: amplifier.h:201
amp_caps::extparms
const struct confparams * extparms
Definition: amplifier.h:261
amp_set_powerstat
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:875
rig_status_e
rig_status_e
Development status of the backend.
Definition: rig.h:369
amp_caps::priv
const rig_ptr_t priv
Definition: amplifier.h:213
amp_caps::copyright
const char * copyright
Definition: amplifier.h:194
amp_type_t
amp_type_t
Amplifier type flags.
Definition: amplifier.h:121
amp_caps::amp_type
int amp_type
Definition: amplifier.h:197
amp_caps::reset
int(* reset)(AMP *amp, amp_reset_t reset)
Definition: amplifier.h:244
amp_caps::mfg_name
const char * mfg_name
Definition: amplifier.h:192
amp_caps::get_level
int(* get_level)(AMP *amp, setting_t level, value_t *val)
Definition: amplifier.h:245
amp::state
struct amp_state state
Definition: amplifier.h:317
amp_caps
Amplifier capabilities.
Definition: amplifier.h:188
amp_caps::amp_cleanup
int(* amp_cleanup)(AMP *amp)
Definition: amplifier.h:228
amp_caps::version
const char * version
Definition: amplifier.h:193
AMP_FLAG_1
@ AMP_FLAG_1
Definition: amplifier.h:123
amp_ext_lookup
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
AMP_FLAG_2
@ AMP_FLAG_2
Definition: amplifier.h:124
confparams
Configuration parameter structure.
Definition: rig.h:806
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:232
amp_caps::amp_model_macro_name
const char * amp_model_macro_name
Definition: amplifier.h:214
amp_caps::retry
int retry
Definition: amplifier.h:210
amp_get_freq
int amp_get_freq(AMP *amp, freq_t *freq)
Query the operating frequency of the amplifier.
Definition: amplifier.c:616
amp_state::comm_state
int comm_state
Definition: amplifier.h:289
powerstat_t
powerstat_t
Radio power state.
Definition: rig.h:662
amp_caps::has_get_level
setting_t has_get_level
Definition: amplifier.h:216
amp_caps::amp_model
amp_model_t amp_model
Definition: amplifier.h:190
amp_strlevel
const char * amp_strlevel(setting_t level)
Convert enum AMP_LEVEL_... to alpha string.
Definition: misc.c:1112
amp_get_powerstat
int amp_get_powerstat(AMP *amp, powerstat_t *status)
Query the power or standby status of the amplifier.
Definition: amplifier.c:912
freq_t
double freq_t
Frequency type,.
Definition: rig.h:410
amp_caps::serial_data_bits
int serial_data_bits
Definition: amplifier.h:202
amp_caps::set_powerstat
int(* set_powerstat)(AMP *amp, powerstat_t status)
Definition: amplifier.h:249
serial_handshake_e
serial_handshake_e
Serial handshake.
Definition: rig.h:297
amp_state::has_set_level
setting_t has_set_level
Definition: amplifier.h:294
value_t
Universal approach for passing values.
Definition: rig.h:931
amp_state
Amplifier state structure.
Definition: amplifier.h:278
amp_caps::timeout
int timeout
Definition: amplifier.h:209
amp_get_info
const char * amp_get_info(AMP *amp)
Query general information from the amplifier.
Definition: amplifier.c:691
amp_caps::level_gran
gran_t level_gran[64]
Definition: amplifier.h:219
amp_parse_level
setting_t amp_parse_level(const char *s)
Convert alpha string to enum AMP_LEVEL_...
Definition: misc.c:1021
amp_caps::status
enum rig_status_e status
Definition: amplifier.h:195
amp::caps
struct amp_caps * caps
Definition: amplifier.h:316
amplist.h
Hamlib amplifier model definitions.
amp_caps::post_write_delay
int post_write_delay
Definition: amplifier.h:208
amp_caps::cfgparams
const struct confparams * cfgparams
Definition: amplifier.h:212
rig.h
Hamlib rig data structures.
amp_caps::get_powerstat
int(* get_powerstat)(AMP *amp, powerstat_t *status)
Definition: amplifier.h:250
amp_reset
int amp_reset(AMP *amp, amp_reset_t reset)
Reset the amplifier.
Definition: amplifier.c:577
amp_caps::amp_close
int(* amp_close)(AMP *amp)
Definition: amplifier.h:230
swr_t
float swr_t
Type definition for SWR (Standing Wave Ratio).
Definition: amplifier.h:80
amp_has_set_level
setting_t amp_has_set_level(AMP *amp, setting_t level)
Check which level settings can be set.
Definition: amp_settings.c:69
amp_caps::extlevels
const struct confparams * extlevels
Definition: amplifier.h:260
amp_token_lookup
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:619
amp_close
int amp_close(AMP *amp)
Close the communication channel to the amplifier.
Definition: amplifier.c:445
amp_caps::has_set_level
setting_t has_set_level
Definition: amplifier.h:217
amp
Master amplifier structure.
Definition: amplifier.h:314
amp_caps::set_ext_level
int(* set_ext_level)(AMP *amp, token_t level, value_t val)
Definition: amplifier.h:248
amp_state::ampport
hamlib_port_t ampport
Definition: amplifier.h:298
amp_caps::write_delay
int write_delay
Definition: amplifier.h:207
amp_confparam_lookup
const struct confparams * amp_confparam_lookup(AMP *amp, const char *name)
Query an amplifier configuration parameter token by its name.
Definition: amp_conf.c:558
amp_caps::parm_gran
gran_t parm_gran[64]
Definition: amplifier.h:220
amp_init
AMP * amp_init(amp_model_t amp_model)
Allocate a new AMP handle.
Definition: amplifier.c:183
amp_caps::serial_parity
enum serial_parity_e serial_parity
Definition: amplifier.h:204
amp_get_level
int amp_get_level(AMP *amp, setting_t level, value_t *val)
Query the value of a requested level.
Definition: amplifier.c:766
tune_value_t
int tune_value_t
Type definition for the transmatch tuning values of capacitance and inductance.
Definition: amplifier.h:100
serial_parity_e
serial_parity_e
Serial parity.
Definition: rig.h:285
confparams::token
token_t token
Definition: rig.h:807
amp_caps::set_level
int(* set_level)(AMP *amp, setting_t level, value_t val)
Definition: amplifier.h:246
amp_set_ext_level
int amp_set_ext_level(AMP *amp, token_t level, value_t val)
Set the value of a requested extension levels token.
Definition: amplifier.c:802
amp_caps::serial_handshake
enum serial_handshake_e serial_handshake
Definition: amplifier.h:205
amp_caps::amp_init
int(* amp_init)(AMP *amp)
Definition: amplifier.h:227
amp_state::ampport_deprecated
hamlib_port_t_deprecated ampport_deprecated
Definition: amplifier.h:287
amp_caps::macro_name
const char * macro_name
Definition: amplifier.h:263
amp_state::level_gran
gran_t level_gran[64]
Definition: amplifier.h:296
amp_caps::serial_stop_bits
int serial_stop_bits
Definition: amplifier.h:203
amp_caps::get_conf
int(* get_conf)(AMP *amp, token_t token, char *val)
Definition: amplifier.h:237
token_t
long token_t
configuration token
Definition: rig.h:767
amp_state::has_get_level
setting_t has_get_level
Definition: amplifier.h:293
amp_set_level
int amp_set_level(AMP *amp, setting_t level, value_t val)
Set the value of a requested level.
Definition: amplifier.c:729
amp_caps::set_conf
int(* set_conf)(AMP *amp, token_t token, const char *val)
Definition: amplifier.h:235
amp_get_ext_level
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:837
amp_caps::get_freq
int(* get_freq)(AMP *amp, freq_t *val)
Definition: amplifier.h:233
amp_caps::amp_open
int(* amp_open)(AMP *amp)
Definition: amplifier.h:229
amp_caps::get_conf2
int(* get_conf2)(AMP *amp, token_t token, char *val, int val_len)
Definition: amplifier.h:236
amp_caps::model_name
const char * model_name
Definition: amplifier.h:191
setting_t
uint64_t setting_t
Setting.
Definition: rig.h:1092
amp_set_freq
int amp_set_freq(AMP *amp, freq_t freq)
Set the operating frequency of the amplifier.
Definition: amplifier.c:656
amp_has_get_level
setting_t amp_has_get_level(AMP *amp, setting_t level)
Check which level settings can be queried.
Definition: amp_settings.c:102
amp_caps::port_type
enum rig_port_e port_type
Definition: amplifier.h:198
amp_caps::serial_rate_min
int serial_rate_min
Definition: amplifier.h:200
amp_state::obj
rig_ptr_t obj
Definition: amplifier.h:291
amp_caps::set_freq
int(* set_freq)(AMP *amp, freq_t val)
Definition: amplifier.h:232
RIG_SETTING_MAX
#define RIG_SETTING_MAX
Maximum # of rig settings.
Definition: rig.h:1098
gran
level/parm granularity definition
Definition: rig.h:1611
amp_state::parm_gran
gran_t parm_gran[64]
Definition: amplifier.h:297
amp_caps::get_ext_level
int(* get_ext_level)(AMP *amp, token_t level, value_t *val)
Definition: amplifier.h:247
amp_cleanup
int amp_cleanup(AMP *amp)
Release an AMP handle and free associated memory.
Definition: amplifier.c:531
amp_state::priv
rig_ptr_t priv
Definition: amplifier.h:290