Hamlib 4.7~git
 
Loading...
Searching...
No Matches
rigclass.h
1/*
2 * Hamlib C++ bindings - API header
3 * Copyright (c) 2001-2002 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 _RIGCLASS_H
23#define _RIGCLASS_H 1
24
25#include <hamlib/rig.h>
26#include <iostream>
27
28
30class HAMLIB_CPP_IMPEXP Rig
31{
32private:
33 RIG *theRig; // Global ref. to the rig
34
35protected:
36public:
37 explicit Rig(rig_model_t rig_model);
38
39 virtual ~Rig();
40#if __cplusplus >= 201103L
41 Rig(const Rig&) = delete;
42 Rig& operator=(const Rig&) = delete;
43#else
44 Rig(const Rig&);
45 Rig& operator=(const Rig&);
46#endif
47
48
49 struct rig_caps *caps;
50
51 // This method opens the communication port to the rig
52 void open(void);
53
54 // This method closes the communication port to the rig
55 void close(void);
56
57 void setConf(hamlib_token_t token, const char *val);
58 void setConf(const char *name, const char *val);
59 void getConf(hamlib_token_t token, char *val);
60 void getConf(const char *name, char *val);
61 hamlib_token_t tokenLookup(const char *name);
62
63 void setFreq(freq_t freq, vfo_t vfo = RIG_VFO_CURR);
64 freq_t getFreq(vfo_t vfo = RIG_VFO_CURR);
65 void setMode(rmode_t,
67 vfo_t vfo = RIG_VFO_CURR);
68
69 rmode_t getMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
70 void setVFO(vfo_t);
71 vfo_t getVFO();
72
73 void setPTT(ptt_t ptt, vfo_t vfo = RIG_VFO_CURR);
74 ptt_t getPTT(vfo_t vfo = RIG_VFO_CURR);
75 dcd_t getDCD(vfo_t vfo = RIG_VFO_CURR);
76
77 void setLevel(setting_t level, int vali, vfo_t vfo = RIG_VFO_CURR);
78 void setLevel(setting_t level, float valf, vfo_t vfo = RIG_VFO_CURR);
79 void getLevel(setting_t level, int& vali, vfo_t vfo = RIG_VFO_CURR);
80 void getLevel(setting_t level, float& valf, vfo_t vfo = RIG_VFO_CURR);
81 int getLevelI(setting_t level, vfo_t vfo = RIG_VFO_CURR);
82 float getLevelF(setting_t level, vfo_t vfo = RIG_VFO_CURR);
83 bool hasGetLevel(setting_t level);
84 bool hasSetLevel(setting_t level);
85
86 void setParm(setting_t parm, int vali);
87 void setParm(setting_t parm, float valf);
88 void getParm(setting_t parm, int& vali);
89 void getParm(setting_t parm, float& valf);
90 int getParmI(setting_t parm);
91 float getParmF(setting_t parm);
92 bool hasGetParm(setting_t parm);
93 bool hasSetParm(setting_t parm);
94
95 void setFunc(setting_t func, bool status, vfo_t vfo = RIG_VFO_CURR);
96 bool getFunc(setting_t func, vfo_t vfo = RIG_VFO_CURR);
97 bool hasGetFunc(setting_t func);
98 bool hasSetFunc(setting_t func);
99
100 void VFOop(vfo_op_t op, vfo_t vfo = RIG_VFO_CURR);
101 bool hasVFOop(vfo_op_t op);
102
103 void scan(scan_t scan, int ch, vfo_t vfo = RIG_VFO_CURR);
104 bool hasScan(scan_t scan);
105
106 const char * getInfo(void);
107 pbwidth_t passbandNormal(rmode_t);
108 pbwidth_t passbandNarrow(rmode_t);
109 pbwidth_t passbandWide(rmode_t);
110
111 void setRptrShift(rptr_shift_t rptr_shift, vfo_t vfo = RIG_VFO_CURR);
112 rptr_shift_t getRptrShift(vfo_t vfo = RIG_VFO_CURR);
113 void setRptrOffs(shortfreq_t rptr_offs, vfo_t vfo = RIG_VFO_CURR);
114 shortfreq_t getRptrOffs(vfo_t vfo = RIG_VFO_CURR);
115 void setTs(shortfreq_t ts, vfo_t vfo = RIG_VFO_CURR);
116 shortfreq_t getTs(vfo_t vfo = RIG_VFO_CURR);
117
118 void setCTCSS(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
119 tone_t getCTCSS(vfo_t vfo = RIG_VFO_CURR);
120 void setDCS(tone_t code, vfo_t vfo = RIG_VFO_CURR);
121 tone_t getDCS(vfo_t vfo = RIG_VFO_CURR);
122
123 void setCTCSSsql(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
124 tone_t getCTCSSsql(vfo_t vfo = RIG_VFO_CURR);
125 void setDCSsql(tone_t tone, vfo_t vfo = RIG_VFO_CURR);
126 tone_t getDCSsql(vfo_t vfo = RIG_VFO_CURR);
127
128
129 unsigned int power2mW(float power, freq_t freq, rmode_t mode);
130 float mW2power(unsigned int mwpower, freq_t freq, rmode_t mode);
131 void setTrn(int trn);
132 int getTrn(void);
133 void setBank(int bank, vfo_t vfo = RIG_VFO_CURR);
134 void setMem(int ch, vfo_t vfo = RIG_VFO_CURR);
135 int getMem(vfo_t vfo = RIG_VFO_CURR);
136
137 void setChannel(const channel_t *chan, vfo_t vfo);
138 void getChannel(channel_t *chan, vfo_t vfo, int readOnly);
139
140 void setPowerStat(powerstat_t status);
141 powerstat_t getPowerStat(void);
142 rmode_t RngRxModes(freq_t freq);
143 rmode_t RngTxModes(freq_t freq);
144
145 void setSplitFreq(freq_t tx_freq, vfo_t vfo = RIG_VFO_CURR);
146 freq_t getSplitFreq(vfo_t vfo = RIG_VFO_CURR);
147 void setSplitMode(rmode_t,
149 vfo_t vfo = RIG_VFO_CURR);
150
151 rmode_t getSplitMode(pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
152 void setSplitFreqMode(freq_t, rmode_t,
154 vfo_t vfo = RIG_VFO_CURR);
155
156 freq_t getSplitFreqMode(rmode_t&, pbwidth_t&, vfo_t vfo = RIG_VFO_CURR);
157 void setSplitVFO(split_t split,
158 vfo_t vfo = RIG_VFO_CURR,
159 vfo_t tx_vfo = RIG_VFO_CURR);
160
161 split_t getSplitVFO(vfo_t& tx_vfo, vfo_t vfo = RIG_VFO_CURR);
162
163 void setRit(shortfreq_t rit, vfo_t vfo = RIG_VFO_CURR);
164 shortfreq_t getRit(vfo_t vfo = RIG_VFO_CURR);
165 void setXit(shortfreq_t xit, vfo_t vfo = RIG_VFO_CURR);
166 shortfreq_t getXit(vfo_t vfo = RIG_VFO_CURR);
167
168 void setAnt(value_t option, ant_t ant, vfo_t vfo = RIG_VFO_CURR);
169 ant_t getAnt(ant_t &ant_rx, ant_t &ant_tx, ant_t ant, value_t &option, ant_t &ant_curr, vfo_t vfo = RIG_VFO_CURR);
170
171 void sendDtmf(const char *digits, vfo_t vfo = RIG_VFO_CURR);
172 int recvDtmf(char *digits, vfo_t vfo = RIG_VFO_CURR);
173 void sendMorse(const char *msg, vfo_t vfo = RIG_VFO_CURR);
174
175
176 shortfreq_t getResolution(rmode_t mode);
177 void reset(reset_t reset);
178
179 // callbacks available in your derived object
180// cppcheck-suppress unusedFunction
181 virtual int FreqEvent(vfo_t, freq_t, rig_ptr_t) const
182 {
183 return RIG_OK;
184 }
185// cppcheck-suppress unusedFunction
186 virtual int ModeEvent(vfo_t, rmode_t, pbwidth_t, rig_ptr_t) const
187 {
188 return RIG_OK;
189 }
190// cppcheck-suppress unusedFunction
191 virtual int VFOEvent(vfo_t, rig_ptr_t) const
192 {
193 return RIG_OK;
194 }
195// cppcheck-suppress unusedFunction
196 virtual int PTTEvent(vfo_t, ptt_t, rig_ptr_t) const
197 {
198 return RIG_OK;
199 }
200// cppcheck-suppress unusedFunction
201 virtual int DCDEvent(vfo_t, dcd_t, rig_ptr_t) const
202 {
203 return RIG_OK;
204 }
205};
207
208
209#ifdef __GNUG__
210# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
211# if HAVE_TYPEINFO
212# include <typeinfo>
213# endif
214# endif
215#endif
216
217#if defined(__GNUG__)
218# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
219# if ETIP_NEEDS_MATH_H
220# if ETIP_NEEDS_MATH_EXCEPTION
221# undef exception
222# define exception math_exception
223# endif
224# include <math.h>
225# endif
226# undef exception
227# define exception builtin_exception
228# if HAVE_GPP_BUILTIN_H
229# include <gpp/builtin.h>
230# elif HAVE_GXX_BUILTIN_H
231# include <g++/builtin.h>
232# else
233# include <builtin.h>
234# endif
235# undef exception
236# endif
237#elif defined (__SUNPRO_CC)
238# include <generic.h>
239# include <string.h>
240#else
241# include <string.h>
242#endif
243
244
245extern "C" {
246#if HAVE_VALUES_H
247# include <values.h>
248#endif
249
250#include <assert.h>
251#include <errno.h>
252}
253
254#include <iostream>
255#if !(defined(__GNUG__)||defined(__SUNPRO_CC)||defined(_WIN32))
256extern "C" void exit(int);
257#endif
258
259
261// Forward Declarations
262class HAMLIB_CPP_IMPEXP RigException
263{
264public:
265 const char *message;
266 int errorno;
267
268 explicit RigException(const char *msg, int err)
269 : message(msg), errorno(err)
270 {};
271
272 explicit RigException(int err)
273 : message(rigerror(err)), errorno(err)
274 {};
275
276 explicit RigException(const char *msg)
277 : message(msg), errorno(-RIG_EINTERNAL)
278 {};
279
280 virtual ~RigException()
281 {};
282
283 void print() const
284 {
285 std::cerr << "Rig exception: " << message << std::endl;
286 }
287 virtual const char *classname() const
288 {
289 return "Rig";
290 }
291};
293
294
295// cppcheck-suppress unusedFunction
296inline void THROW(const RigException *e)
297{
298#if defined(__GNUG__)
299# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
300 (*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
301#else
302 throw *e;
303#endif
304#elif defined(_MSC_VER)
305 throw* e;
306#elif defined(__SUNPRO_CC)
307// cppcheck-suppress cstyleCast
308 genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
309#else
310
311 if (e) {
312 std::cerr << e->message << std::endl;
313 }
314
315 exit(0);
316#endif
317}
318
319#define THROWS(s)
320
321
322#endif // _RIGCLASS_H
unsigned int vfo_t
VFO definition.
Definition rig.h:516
unsigned int ant_t
Antenna typedef.
Definition rig.h:982
long hamlib_token_t
configuration token
Definition rig.h:859
uint64_t rmode_t
Radio mode.
Definition rig.h:1359
shortfreq_t pbwidth_t
Definition rig.h:648
split_t
Split mode.
Definition rig.h:445
rptr_shift_t
Repeater shift type.
Definition rig.h:435
struct channel channel_t
Channel structure typedef.
Definition rig.h:1612
uint64_t setting_t
Setting.
Definition rig.h:1201
powerstat_t
Radio power state.
Definition rig.h:708
scan_t
Rig Scan operation.
Definition rig.h:843
#define RIG_VFO_CURR
currVFO – current "tunable channel"/VFO
Definition rig.h:571
double freq_t
Frequency type,.
Definition rig.h:456
ptt_t
PTT status.
Definition rig.h:679
#define RIG_PASSBAND_NORMAL
Macro for bandpass to be set to normal.
Definition rig.h:637
vfo_op_t
VFO operation.
Definition rig.h:750
signed long shortfreq_t
Short frequency type.
Definition rig.h:478
struct s_rig RIG
Rig structure definition (see rig for details).
Definition rig.h:262
reset_t
Reset operation.
Definition rig.h:720
@ RIG_OK
Definition rig.h:189
@ RIG_EINTERNAL
Definition rig.h:196
Hamlib rig data structures.
uint32_t rig_model_t
Convenience type definition for rig model.
Definition riglist.h:707