hamlib 0.1.26 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +18 -85
- package/index.d.ts +41 -0
- package/lib/index.js +39 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/{libhamlib.4.dylib → libhamlib.5.dylib} +0 -0
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/{libhamlib.4.dylib → libhamlib.5.dylib} +0 -0
- package/prebuilds/darwin-x64/node.napi.node +0 -0
- package/prebuilds/linux-arm64/libhamlib.so +0 -0
- package/prebuilds/linux-arm64/libhamlib.so.5 +0 -0
- package/prebuilds/linux-arm64/{libhamlib.so.4 → libhamlib.so.5.0.0} +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/{libhamlib.so.4 → libhamlib.so} +0 -0
- package/prebuilds/linux-x64/libhamlib.so.5 +0 -0
- package/prebuilds/linux-x64/libhamlib.so.5.0.0 +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-x64/hamlib_shim.dll +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/addon.cpp +4 -0
- package/src/hamlib.cpp +1105 -1134
- package/src/hamlib.h +39 -37
- package/src/shim/hamlib_shim.c +865 -0
- package/src/shim/hamlib_shim.h +511 -0
- package/prebuilds/BUILD_INFO.txt +0 -14
- package/src/hamlib_compat.h +0 -44
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hamlib_shim.c - Pure C implementation of the Hamlib shim layer
|
|
3
|
+
*
|
|
4
|
+
* This file wraps all Hamlib C API calls and struct accesses, providing
|
|
5
|
+
* a clean C ABI boundary. It must be compiled with the same compiler
|
|
6
|
+
* as Hamlib (MinGW on Windows, gcc/clang on Unix).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef HAMLIB_SHIM_BUILD
|
|
10
|
+
#define HAMLIB_SHIM_BUILD
|
|
11
|
+
#endif
|
|
12
|
+
#include "hamlib_shim.h"
|
|
13
|
+
#include <hamlib/rig.h>
|
|
14
|
+
#include <string.h>
|
|
15
|
+
#include <stdio.h>
|
|
16
|
+
|
|
17
|
+
/* ===== Lifecycle ===== */
|
|
18
|
+
|
|
19
|
+
SHIM_API hamlib_shim_handle_t shim_rig_init(unsigned int model) {
|
|
20
|
+
return (hamlib_shim_handle_t)rig_init((rig_model_t)model);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
SHIM_API int shim_rig_open(hamlib_shim_handle_t h) {
|
|
24
|
+
return rig_open((RIG*)h);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
SHIM_API int shim_rig_close(hamlib_shim_handle_t h) {
|
|
28
|
+
return rig_close((RIG*)h);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
SHIM_API int shim_rig_cleanup(hamlib_shim_handle_t h) {
|
|
32
|
+
return rig_cleanup((RIG*)h);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
SHIM_API const char* shim_rigerror(int errcode) {
|
|
36
|
+
return rigerror(errcode);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* ===== Debug / Utility ===== */
|
|
40
|
+
|
|
41
|
+
SHIM_API void shim_rig_set_debug(int level) {
|
|
42
|
+
rig_set_debug((enum rig_debug_level_e)level);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
SHIM_API int shim_rig_get_debug(void) {
|
|
46
|
+
/* Hamlib doesn't have rig_get_debug in all versions,
|
|
47
|
+
but we use the global variable if available */
|
|
48
|
+
#ifdef HAVE_RIG_GET_DEBUG
|
|
49
|
+
return (int)rig_get_debug();
|
|
50
|
+
#else
|
|
51
|
+
return -1; /* Not available */
|
|
52
|
+
#endif
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
SHIM_API const char* shim_rig_get_version(void) {
|
|
56
|
+
return hamlib_version;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
SHIM_API int shim_rig_load_all_backends(void) {
|
|
60
|
+
return rig_load_all_backends();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Internal callback adapter for rig_list_foreach */
|
|
64
|
+
struct shim_list_adapter {
|
|
65
|
+
shim_rig_list_cb_t user_cb;
|
|
66
|
+
void* user_data;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
static int shim_list_foreach_adapter(const struct rig_caps *caps, void *data) {
|
|
70
|
+
struct shim_list_adapter *adapter = (struct shim_list_adapter*)data;
|
|
71
|
+
shim_rig_info_t info;
|
|
72
|
+
info.rig_model = caps->rig_model;
|
|
73
|
+
info.model_name = caps->model_name ? caps->model_name : "";
|
|
74
|
+
info.mfg_name = caps->mfg_name ? caps->mfg_name : "";
|
|
75
|
+
info.version = caps->version ? caps->version : "";
|
|
76
|
+
info.status = (int)caps->status;
|
|
77
|
+
info.rig_type = (int)(caps->rig_type & RIG_TYPE_MASK);
|
|
78
|
+
return adapter->user_cb(&info, adapter->user_data);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
SHIM_API int shim_rig_list_foreach(shim_rig_list_cb_t cb, void* data) {
|
|
82
|
+
struct shim_list_adapter adapter;
|
|
83
|
+
adapter.user_cb = cb;
|
|
84
|
+
adapter.user_data = data;
|
|
85
|
+
return rig_list_foreach(shim_list_foreach_adapter, &adapter);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
SHIM_API const char* shim_rig_strstatus(int status) {
|
|
89
|
+
return rig_strstatus((enum rig_status_e)status);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ===== Port configuration ===== */
|
|
93
|
+
|
|
94
|
+
SHIM_API void shim_rig_set_port_path(hamlib_shim_handle_t h, const char* path) {
|
|
95
|
+
RIG* rig = (RIG*)h;
|
|
96
|
+
strncpy(rig->state.rigport.pathname, path, HAMLIB_FILPATHLEN - 1);
|
|
97
|
+
rig->state.rigport.pathname[HAMLIB_FILPATHLEN - 1] = '\0';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
SHIM_API void shim_rig_set_port_type(hamlib_shim_handle_t h, int type) {
|
|
101
|
+
RIG* rig = (RIG*)h;
|
|
102
|
+
rig->state.rigport.type.rig = (enum rig_port_e)type;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Serial config */
|
|
106
|
+
SHIM_API void shim_rig_set_serial_rate(hamlib_shim_handle_t h, int rate) {
|
|
107
|
+
RIG* rig = (RIG*)h;
|
|
108
|
+
rig->state.rigport.parm.serial.rate = rate;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
SHIM_API int shim_rig_get_serial_rate(hamlib_shim_handle_t h) {
|
|
112
|
+
RIG* rig = (RIG*)h;
|
|
113
|
+
return rig->state.rigport.parm.serial.rate;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
SHIM_API void shim_rig_set_serial_data_bits(hamlib_shim_handle_t h, int bits) {
|
|
117
|
+
RIG* rig = (RIG*)h;
|
|
118
|
+
rig->state.rigport.parm.serial.data_bits = bits;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
SHIM_API int shim_rig_get_serial_data_bits(hamlib_shim_handle_t h) {
|
|
122
|
+
RIG* rig = (RIG*)h;
|
|
123
|
+
return rig->state.rigport.parm.serial.data_bits;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
SHIM_API void shim_rig_set_serial_stop_bits(hamlib_shim_handle_t h, int bits) {
|
|
127
|
+
RIG* rig = (RIG*)h;
|
|
128
|
+
rig->state.rigport.parm.serial.stop_bits = bits;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
SHIM_API int shim_rig_get_serial_stop_bits(hamlib_shim_handle_t h) {
|
|
132
|
+
RIG* rig = (RIG*)h;
|
|
133
|
+
return rig->state.rigport.parm.serial.stop_bits;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
SHIM_API void shim_rig_set_serial_parity(hamlib_shim_handle_t h, int parity) {
|
|
137
|
+
RIG* rig = (RIG*)h;
|
|
138
|
+
rig->state.rigport.parm.serial.parity = (enum serial_parity_e)parity;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
SHIM_API int shim_rig_get_serial_parity(hamlib_shim_handle_t h) {
|
|
142
|
+
RIG* rig = (RIG*)h;
|
|
143
|
+
return (int)rig->state.rigport.parm.serial.parity;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
SHIM_API void shim_rig_set_serial_handshake(hamlib_shim_handle_t h, int handshake) {
|
|
147
|
+
RIG* rig = (RIG*)h;
|
|
148
|
+
rig->state.rigport.parm.serial.handshake = (enum serial_handshake_e)handshake;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
SHIM_API int shim_rig_get_serial_handshake(hamlib_shim_handle_t h) {
|
|
152
|
+
RIG* rig = (RIG*)h;
|
|
153
|
+
return (int)rig->state.rigport.parm.serial.handshake;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
SHIM_API void shim_rig_set_serial_rts_state(hamlib_shim_handle_t h, int state) {
|
|
157
|
+
RIG* rig = (RIG*)h;
|
|
158
|
+
rig->state.rigport.parm.serial.rts_state = (enum serial_control_state_e)state;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
SHIM_API int shim_rig_get_serial_rts_state(hamlib_shim_handle_t h) {
|
|
162
|
+
RIG* rig = (RIG*)h;
|
|
163
|
+
return (int)rig->state.rigport.parm.serial.rts_state;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
SHIM_API void shim_rig_set_serial_dtr_state(hamlib_shim_handle_t h, int state) {
|
|
167
|
+
RIG* rig = (RIG*)h;
|
|
168
|
+
rig->state.rigport.parm.serial.dtr_state = (enum serial_control_state_e)state;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
SHIM_API int shim_rig_get_serial_dtr_state(hamlib_shim_handle_t h) {
|
|
172
|
+
RIG* rig = (RIG*)h;
|
|
173
|
+
return (int)rig->state.rigport.parm.serial.dtr_state;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* Port timing */
|
|
177
|
+
SHIM_API void shim_rig_set_port_timeout(hamlib_shim_handle_t h, int ms) {
|
|
178
|
+
RIG* rig = (RIG*)h;
|
|
179
|
+
rig->state.rigport.timeout = ms;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
SHIM_API int shim_rig_get_port_timeout(hamlib_shim_handle_t h) {
|
|
183
|
+
RIG* rig = (RIG*)h;
|
|
184
|
+
return rig->state.rigport.timeout;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
SHIM_API void shim_rig_set_port_retry(hamlib_shim_handle_t h, int count) {
|
|
188
|
+
RIG* rig = (RIG*)h;
|
|
189
|
+
rig->state.rigport.retry = (short)count;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
SHIM_API int shim_rig_get_port_retry(hamlib_shim_handle_t h) {
|
|
193
|
+
RIG* rig = (RIG*)h;
|
|
194
|
+
return (int)rig->state.rigport.retry;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
SHIM_API void shim_rig_set_port_write_delay(hamlib_shim_handle_t h, int ms) {
|
|
198
|
+
RIG* rig = (RIG*)h;
|
|
199
|
+
rig->state.rigport.write_delay = ms;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
SHIM_API int shim_rig_get_port_write_delay(hamlib_shim_handle_t h) {
|
|
203
|
+
RIG* rig = (RIG*)h;
|
|
204
|
+
return rig->state.rigport.write_delay;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
SHIM_API void shim_rig_set_port_post_write_delay(hamlib_shim_handle_t h, int ms) {
|
|
208
|
+
RIG* rig = (RIG*)h;
|
|
209
|
+
rig->state.rigport.post_write_delay = ms;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
SHIM_API int shim_rig_get_port_post_write_delay(hamlib_shim_handle_t h) {
|
|
213
|
+
RIG* rig = (RIG*)h;
|
|
214
|
+
return rig->state.rigport.post_write_delay;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
SHIM_API void shim_rig_set_port_flushx(hamlib_shim_handle_t h, int enable) {
|
|
218
|
+
RIG* rig = (RIG*)h;
|
|
219
|
+
rig->state.rigport.flushx = enable;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
SHIM_API int shim_rig_get_port_flushx(hamlib_shim_handle_t h) {
|
|
223
|
+
RIG* rig = (RIG*)h;
|
|
224
|
+
return rig->state.rigport.flushx;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/* PTT/DCD port type */
|
|
228
|
+
SHIM_API void shim_rig_set_ptt_type(hamlib_shim_handle_t h, int type) {
|
|
229
|
+
RIG* rig = (RIG*)h;
|
|
230
|
+
rig->state.pttport.type.ptt = (ptt_type_t)type;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
SHIM_API int shim_rig_get_ptt_type(hamlib_shim_handle_t h) {
|
|
234
|
+
RIG* rig = (RIG*)h;
|
|
235
|
+
return (int)rig->state.pttport.type.ptt;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
SHIM_API void shim_rig_set_dcd_type(hamlib_shim_handle_t h, int type) {
|
|
239
|
+
RIG* rig = (RIG*)h;
|
|
240
|
+
rig->state.dcdport.type.dcd = (dcd_type_t)type;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
SHIM_API int shim_rig_get_dcd_type(hamlib_shim_handle_t h) {
|
|
244
|
+
RIG* rig = (RIG*)h;
|
|
245
|
+
return (int)rig->state.dcdport.type.dcd;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* ===== Frequency control ===== */
|
|
249
|
+
|
|
250
|
+
SHIM_API int shim_rig_set_freq(hamlib_shim_handle_t h, int vfo, double freq) {
|
|
251
|
+
return rig_set_freq((RIG*)h, (vfo_t)vfo, (freq_t)freq);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
SHIM_API int shim_rig_get_freq(hamlib_shim_handle_t h, int vfo, double* freq) {
|
|
255
|
+
freq_t f = 0;
|
|
256
|
+
int ret = rig_get_freq((RIG*)h, (vfo_t)vfo, &f);
|
|
257
|
+
if (freq) *freq = (double)f;
|
|
258
|
+
return ret;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/* ===== VFO control ===== */
|
|
262
|
+
|
|
263
|
+
SHIM_API int shim_rig_set_vfo(hamlib_shim_handle_t h, int vfo) {
|
|
264
|
+
return rig_set_vfo((RIG*)h, (vfo_t)vfo);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
SHIM_API int shim_rig_get_vfo(hamlib_shim_handle_t h, int* vfo) {
|
|
268
|
+
vfo_t v = 0;
|
|
269
|
+
int ret = rig_get_vfo((RIG*)h, &v);
|
|
270
|
+
if (vfo) *vfo = (int)v;
|
|
271
|
+
return ret;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/* ===== Mode control ===== */
|
|
275
|
+
|
|
276
|
+
SHIM_API int shim_rig_set_mode(hamlib_shim_handle_t h, int vfo, int mode, int width) {
|
|
277
|
+
return rig_set_mode((RIG*)h, (vfo_t)vfo, (rmode_t)mode, (pbwidth_t)width);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
SHIM_API int shim_rig_get_mode(hamlib_shim_handle_t h, int vfo, int* mode, int* width) {
|
|
281
|
+
rmode_t m = 0;
|
|
282
|
+
pbwidth_t w = 0;
|
|
283
|
+
int ret = rig_get_mode((RIG*)h, (vfo_t)vfo, &m, &w);
|
|
284
|
+
if (mode) *mode = (int)m;
|
|
285
|
+
if (width) *width = (int)w;
|
|
286
|
+
return ret;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
SHIM_API int shim_rig_parse_mode(const char* mode_str) {
|
|
290
|
+
return (int)rig_parse_mode(mode_str);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
SHIM_API const char* shim_rig_strrmode(int mode) {
|
|
294
|
+
return rig_strrmode((rmode_t)mode);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
SHIM_API int shim_rig_passband_narrow(hamlib_shim_handle_t h, int mode) {
|
|
298
|
+
return (int)rig_passband_narrow((RIG*)h, (rmode_t)mode);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
SHIM_API int shim_rig_passband_wide(hamlib_shim_handle_t h, int mode) {
|
|
302
|
+
return (int)rig_passband_wide((RIG*)h, (rmode_t)mode);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* ===== PTT control ===== */
|
|
306
|
+
|
|
307
|
+
SHIM_API int shim_rig_set_ptt(hamlib_shim_handle_t h, int vfo, int ptt) {
|
|
308
|
+
return rig_set_ptt((RIG*)h, (vfo_t)vfo, (ptt_t)ptt);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
SHIM_API int shim_rig_get_ptt(hamlib_shim_handle_t h, int vfo, int* ptt) {
|
|
312
|
+
ptt_t p = 0;
|
|
313
|
+
int ret = rig_get_ptt((RIG*)h, (vfo_t)vfo, &p);
|
|
314
|
+
if (ptt) *ptt = (int)p;
|
|
315
|
+
return ret;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
SHIM_API int shim_rig_get_dcd(hamlib_shim_handle_t h, int vfo, int* dcd) {
|
|
319
|
+
dcd_t d = 0;
|
|
320
|
+
int ret = rig_get_dcd((RIG*)h, (vfo_t)vfo, &d);
|
|
321
|
+
if (dcd) *dcd = (int)d;
|
|
322
|
+
return ret;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/* ===== Signal strength ===== */
|
|
326
|
+
|
|
327
|
+
SHIM_API int shim_rig_get_strength(hamlib_shim_handle_t h, int vfo, int* strength) {
|
|
328
|
+
int s = 0;
|
|
329
|
+
int ret = rig_get_strength((RIG*)h, (vfo_t)vfo, &s);
|
|
330
|
+
if (strength) *strength = s;
|
|
331
|
+
return ret;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/* ===== Level control ===== */
|
|
335
|
+
|
|
336
|
+
SHIM_API int shim_rig_set_level_f(hamlib_shim_handle_t h, int vfo, uint64_t level, float value) {
|
|
337
|
+
value_t val;
|
|
338
|
+
val.f = value;
|
|
339
|
+
return rig_set_level((RIG*)h, (vfo_t)vfo, (setting_t)level, val);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
SHIM_API int shim_rig_set_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int value) {
|
|
343
|
+
value_t val;
|
|
344
|
+
val.i = value;
|
|
345
|
+
return rig_set_level((RIG*)h, (vfo_t)vfo, (setting_t)level, val);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t level, float* value) {
|
|
349
|
+
value_t val;
|
|
350
|
+
val.f = 0.0f;
|
|
351
|
+
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
352
|
+
if (value) *value = val.f;
|
|
353
|
+
return ret;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
SHIM_API int shim_rig_get_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int* value) {
|
|
357
|
+
value_t val;
|
|
358
|
+
val.i = 0;
|
|
359
|
+
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
360
|
+
if (value) *value = val.i;
|
|
361
|
+
return ret;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/* ===== Function control ===== */
|
|
365
|
+
|
|
366
|
+
SHIM_API int shim_rig_set_func(hamlib_shim_handle_t h, int vfo, uint64_t func, int enable) {
|
|
367
|
+
return rig_set_func((RIG*)h, (vfo_t)vfo, (setting_t)func, enable);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
SHIM_API int shim_rig_get_func(hamlib_shim_handle_t h, int vfo, uint64_t func, int* state) {
|
|
371
|
+
int s = 0;
|
|
372
|
+
int ret = rig_get_func((RIG*)h, (vfo_t)vfo, (setting_t)func, &s);
|
|
373
|
+
if (state) *state = s;
|
|
374
|
+
return ret;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/* ===== Parameter control ===== */
|
|
378
|
+
|
|
379
|
+
SHIM_API int shim_rig_set_parm_f(hamlib_shim_handle_t h, uint64_t parm, float value) {
|
|
380
|
+
value_t val;
|
|
381
|
+
val.f = value;
|
|
382
|
+
return rig_set_parm((RIG*)h, (setting_t)parm, val);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
SHIM_API int shim_rig_set_parm_i(hamlib_shim_handle_t h, uint64_t parm, int value) {
|
|
386
|
+
value_t val;
|
|
387
|
+
val.i = value;
|
|
388
|
+
return rig_set_parm((RIG*)h, (setting_t)parm, val);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
SHIM_API int shim_rig_get_parm_f(hamlib_shim_handle_t h, uint64_t parm, float* value) {
|
|
392
|
+
value_t val;
|
|
393
|
+
val.f = 0.0f;
|
|
394
|
+
int ret = rig_get_parm((RIG*)h, (setting_t)parm, &val);
|
|
395
|
+
if (value) *value = val.f;
|
|
396
|
+
return ret;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
SHIM_API int shim_rig_get_parm_i(hamlib_shim_handle_t h, uint64_t parm, int* value) {
|
|
400
|
+
value_t val;
|
|
401
|
+
val.i = 0;
|
|
402
|
+
int ret = rig_get_parm((RIG*)h, (setting_t)parm, &val);
|
|
403
|
+
if (value) *value = val.i;
|
|
404
|
+
return ret;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
SHIM_API uint64_t shim_rig_parse_parm(const char* parm_str) {
|
|
408
|
+
return (uint64_t)rig_parse_parm(parm_str);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* ===== Split operations ===== */
|
|
412
|
+
|
|
413
|
+
SHIM_API int shim_rig_set_split_freq(hamlib_shim_handle_t h, int vfo, double freq) {
|
|
414
|
+
return rig_set_split_freq((RIG*)h, (vfo_t)vfo, (freq_t)freq);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
SHIM_API int shim_rig_get_split_freq(hamlib_shim_handle_t h, int vfo, double* freq) {
|
|
418
|
+
freq_t f = 0;
|
|
419
|
+
int ret = rig_get_split_freq((RIG*)h, (vfo_t)vfo, &f);
|
|
420
|
+
if (freq) *freq = (double)f;
|
|
421
|
+
return ret;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
SHIM_API int shim_rig_set_split_vfo(hamlib_shim_handle_t h, int rx_vfo, int split, int tx_vfo) {
|
|
425
|
+
return rig_set_split_vfo((RIG*)h, (vfo_t)rx_vfo, (split_t)split, (vfo_t)tx_vfo);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
SHIM_API int shim_rig_get_split_vfo(hamlib_shim_handle_t h, int vfo, int* split, int* tx_vfo) {
|
|
429
|
+
split_t s = 0;
|
|
430
|
+
vfo_t tv = 0;
|
|
431
|
+
int ret = rig_get_split_vfo((RIG*)h, (vfo_t)vfo, &s, &tv);
|
|
432
|
+
if (split) *split = (int)s;
|
|
433
|
+
if (tx_vfo) *tx_vfo = (int)tv;
|
|
434
|
+
return ret;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
SHIM_API int shim_rig_set_split_mode(hamlib_shim_handle_t h, int vfo, int mode, int width) {
|
|
438
|
+
return rig_set_split_mode((RIG*)h, (vfo_t)vfo, (rmode_t)mode, (pbwidth_t)width);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
SHIM_API int shim_rig_get_split_mode(hamlib_shim_handle_t h, int vfo, int* mode, int* width) {
|
|
442
|
+
rmode_t m = 0;
|
|
443
|
+
pbwidth_t w = 0;
|
|
444
|
+
int ret = rig_get_split_mode((RIG*)h, (vfo_t)vfo, &m, &w);
|
|
445
|
+
if (mode) *mode = (int)m;
|
|
446
|
+
if (width) *width = (int)w;
|
|
447
|
+
return ret;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
SHIM_API int shim_rig_set_split_freq_mode(hamlib_shim_handle_t h, int vfo, double freq, int mode, int width) {
|
|
451
|
+
#if HAVE_RIG_SPLIT_FREQ_MODE
|
|
452
|
+
return rig_set_split_freq_mode((RIG*)h, (vfo_t)vfo, (freq_t)freq, (rmode_t)mode, (pbwidth_t)width);
|
|
453
|
+
#else
|
|
454
|
+
/* Fallback: set freq and mode separately */
|
|
455
|
+
int ret = rig_set_split_freq((RIG*)h, (vfo_t)vfo, (freq_t)freq);
|
|
456
|
+
if (ret != RIG_OK) return ret;
|
|
457
|
+
return rig_set_split_mode((RIG*)h, (vfo_t)vfo, (rmode_t)mode, (pbwidth_t)width);
|
|
458
|
+
#endif
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
SHIM_API int shim_rig_get_split_freq_mode(hamlib_shim_handle_t h, int vfo, double* freq, int* mode, int* width) {
|
|
462
|
+
#if HAVE_RIG_SPLIT_FREQ_MODE
|
|
463
|
+
freq_t f = 0;
|
|
464
|
+
rmode_t m = 0;
|
|
465
|
+
pbwidth_t w = 0;
|
|
466
|
+
int ret = rig_get_split_freq_mode((RIG*)h, (vfo_t)vfo, &f, &m, &w);
|
|
467
|
+
if (freq) *freq = (double)f;
|
|
468
|
+
if (mode) *mode = (int)m;
|
|
469
|
+
if (width) *width = (int)w;
|
|
470
|
+
return ret;
|
|
471
|
+
#else
|
|
472
|
+
/* Fallback: get freq and mode separately */
|
|
473
|
+
freq_t f = 0;
|
|
474
|
+
int ret = rig_get_split_freq((RIG*)h, (vfo_t)vfo, &f);
|
|
475
|
+
if (freq) *freq = (double)f;
|
|
476
|
+
if (ret != RIG_OK) return ret;
|
|
477
|
+
rmode_t m = 0;
|
|
478
|
+
pbwidth_t w = 0;
|
|
479
|
+
ret = rig_get_split_mode((RIG*)h, (vfo_t)vfo, &m, &w);
|
|
480
|
+
if (mode) *mode = (int)m;
|
|
481
|
+
if (width) *width = (int)w;
|
|
482
|
+
return ret;
|
|
483
|
+
#endif
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/* ===== RIT/XIT control ===== */
|
|
487
|
+
|
|
488
|
+
SHIM_API int shim_rig_set_rit(hamlib_shim_handle_t h, int vfo, int offset) {
|
|
489
|
+
return rig_set_rit((RIG*)h, (vfo_t)vfo, (shortfreq_t)offset);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
SHIM_API int shim_rig_get_rit(hamlib_shim_handle_t h, int vfo, int* offset) {
|
|
493
|
+
shortfreq_t o = 0;
|
|
494
|
+
int ret = rig_get_rit((RIG*)h, (vfo_t)vfo, &o);
|
|
495
|
+
if (offset) *offset = (int)o;
|
|
496
|
+
return ret;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
SHIM_API int shim_rig_set_xit(hamlib_shim_handle_t h, int vfo, int offset) {
|
|
500
|
+
return rig_set_xit((RIG*)h, (vfo_t)vfo, (shortfreq_t)offset);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
SHIM_API int shim_rig_get_xit(hamlib_shim_handle_t h, int vfo, int* offset) {
|
|
504
|
+
shortfreq_t o = 0;
|
|
505
|
+
int ret = rig_get_xit((RIG*)h, (vfo_t)vfo, &o);
|
|
506
|
+
if (offset) *offset = (int)o;
|
|
507
|
+
return ret;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/* ===== Memory channel operations ===== */
|
|
511
|
+
|
|
512
|
+
SHIM_API int shim_rig_set_channel(hamlib_shim_handle_t h, int vfo, const shim_channel_t* schan) {
|
|
513
|
+
channel_t chan;
|
|
514
|
+
memset(&chan, 0, sizeof(chan));
|
|
515
|
+
chan.channel_num = schan->channel_num;
|
|
516
|
+
chan.freq = (freq_t)schan->freq;
|
|
517
|
+
chan.tx_freq = (freq_t)schan->tx_freq;
|
|
518
|
+
chan.mode = (rmode_t)schan->mode;
|
|
519
|
+
chan.width = (pbwidth_t)schan->width;
|
|
520
|
+
chan.split = (split_t)schan->split;
|
|
521
|
+
chan.ctcss_tone = (tone_t)schan->ctcss_tone;
|
|
522
|
+
chan.vfo = (vfo_t)schan->vfo;
|
|
523
|
+
strncpy(chan.channel_desc, schan->channel_desc, sizeof(chan.channel_desc) - 1);
|
|
524
|
+
chan.channel_desc[sizeof(chan.channel_desc) - 1] = '\0';
|
|
525
|
+
return rig_set_channel((RIG*)h, (vfo_t)vfo, &chan);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
SHIM_API int shim_rig_get_channel(hamlib_shim_handle_t h, int vfo, shim_channel_t* schan, int read_only) {
|
|
529
|
+
channel_t chan;
|
|
530
|
+
memset(&chan, 0, sizeof(chan));
|
|
531
|
+
chan.channel_num = schan->channel_num;
|
|
532
|
+
chan.vfo = (vfo_t)schan->vfo;
|
|
533
|
+
int ret = rig_get_channel((RIG*)h, (vfo_t)vfo, &chan, read_only);
|
|
534
|
+
if (ret == RIG_OK) {
|
|
535
|
+
schan->channel_num = chan.channel_num;
|
|
536
|
+
schan->freq = (double)chan.freq;
|
|
537
|
+
schan->tx_freq = (double)chan.tx_freq;
|
|
538
|
+
schan->mode = (int)chan.mode;
|
|
539
|
+
schan->width = (int)chan.width;
|
|
540
|
+
schan->split = (int)chan.split;
|
|
541
|
+
schan->ctcss_tone = (int)chan.ctcss_tone;
|
|
542
|
+
schan->vfo = (int)chan.vfo;
|
|
543
|
+
strncpy(schan->channel_desc, chan.channel_desc, sizeof(schan->channel_desc) - 1);
|
|
544
|
+
schan->channel_desc[sizeof(schan->channel_desc) - 1] = '\0';
|
|
545
|
+
}
|
|
546
|
+
return ret;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
SHIM_API int shim_rig_set_mem(hamlib_shim_handle_t h, int vfo, int ch) {
|
|
550
|
+
return rig_set_mem((RIG*)h, (vfo_t)vfo, ch);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
SHIM_API int shim_rig_get_mem(hamlib_shim_handle_t h, int vfo, int* ch) {
|
|
554
|
+
return rig_get_mem((RIG*)h, (vfo_t)vfo, ch);
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
SHIM_API int shim_rig_set_bank(hamlib_shim_handle_t h, int vfo, int bank) {
|
|
558
|
+
return rig_set_bank((RIG*)h, (vfo_t)vfo, bank);
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
SHIM_API int shim_rig_mem_count(hamlib_shim_handle_t h) {
|
|
562
|
+
return rig_mem_count((RIG*)h);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/* ===== Scanning ===== */
|
|
566
|
+
|
|
567
|
+
SHIM_API int shim_rig_scan(hamlib_shim_handle_t h, int vfo, int scan_type, int channel) {
|
|
568
|
+
return rig_scan((RIG*)h, (vfo_t)vfo, (scan_t)scan_type, channel);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/* ===== VFO operations ===== */
|
|
572
|
+
|
|
573
|
+
SHIM_API int shim_rig_vfo_op(hamlib_shim_handle_t h, int vfo, int op) {
|
|
574
|
+
return rig_vfo_op((RIG*)h, (vfo_t)vfo, (vfo_op_t)op);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* ===== Antenna control ===== */
|
|
578
|
+
|
|
579
|
+
SHIM_API int shim_rig_set_ant(hamlib_shim_handle_t h, int vfo, int ant, float option) {
|
|
580
|
+
value_t opt;
|
|
581
|
+
opt.f = option;
|
|
582
|
+
return rig_set_ant((RIG*)h, (vfo_t)vfo, (ant_t)ant, opt);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
SHIM_API int shim_rig_get_ant(hamlib_shim_handle_t h, int vfo, int ant, float* option,
|
|
586
|
+
int* ant_curr, int* ant_tx, int* ant_rx) {
|
|
587
|
+
value_t opt = {0};
|
|
588
|
+
ant_t ac = 0, atx = 0, arx = 0;
|
|
589
|
+
int ret = rig_get_ant((RIG*)h, (vfo_t)vfo, (ant_t)ant, &opt, &ac, &atx, &arx);
|
|
590
|
+
if (option) *option = opt.f;
|
|
591
|
+
if (ant_curr) *ant_curr = (int)ac;
|
|
592
|
+
if (ant_tx) *ant_tx = (int)atx;
|
|
593
|
+
if (ant_rx) *ant_rx = (int)arx;
|
|
594
|
+
return ret;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/* ===== Tuning step ===== */
|
|
598
|
+
|
|
599
|
+
SHIM_API int shim_rig_set_ts(hamlib_shim_handle_t h, int vfo, int ts) {
|
|
600
|
+
return rig_set_ts((RIG*)h, (vfo_t)vfo, (shortfreq_t)ts);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
SHIM_API int shim_rig_get_ts(hamlib_shim_handle_t h, int vfo, int* ts) {
|
|
604
|
+
shortfreq_t t = 0;
|
|
605
|
+
int ret = rig_get_ts((RIG*)h, (vfo_t)vfo, &t);
|
|
606
|
+
if (ts) *ts = (int)t;
|
|
607
|
+
return ret;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/* ===== Repeater control ===== */
|
|
611
|
+
|
|
612
|
+
SHIM_API int shim_rig_set_rptr_shift(hamlib_shim_handle_t h, int vfo, int shift) {
|
|
613
|
+
return rig_set_rptr_shift((RIG*)h, (vfo_t)vfo, (rptr_shift_t)shift);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
SHIM_API int shim_rig_get_rptr_shift(hamlib_shim_handle_t h, int vfo, int* shift) {
|
|
617
|
+
rptr_shift_t s = 0;
|
|
618
|
+
int ret = rig_get_rptr_shift((RIG*)h, (vfo_t)vfo, &s);
|
|
619
|
+
if (shift) *shift = (int)s;
|
|
620
|
+
return ret;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
SHIM_API const char* shim_rig_strptrshift(int shift) {
|
|
624
|
+
return rig_strptrshift((rptr_shift_t)shift);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
SHIM_API int shim_rig_set_rptr_offs(hamlib_shim_handle_t h, int vfo, int offset) {
|
|
628
|
+
return rig_set_rptr_offs((RIG*)h, (vfo_t)vfo, (shortfreq_t)offset);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
SHIM_API int shim_rig_get_rptr_offs(hamlib_shim_handle_t h, int vfo, int* offset) {
|
|
632
|
+
shortfreq_t o = 0;
|
|
633
|
+
int ret = rig_get_rptr_offs((RIG*)h, (vfo_t)vfo, &o);
|
|
634
|
+
if (offset) *offset = (int)o;
|
|
635
|
+
return ret;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/* ===== CTCSS/DCS tone control ===== */
|
|
639
|
+
|
|
640
|
+
SHIM_API int shim_rig_set_ctcss_tone(hamlib_shim_handle_t h, int vfo, unsigned int tone) {
|
|
641
|
+
return rig_set_ctcss_tone((RIG*)h, (vfo_t)vfo, (tone_t)tone);
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
SHIM_API int shim_rig_get_ctcss_tone(hamlib_shim_handle_t h, int vfo, unsigned int* tone) {
|
|
645
|
+
tone_t t = 0;
|
|
646
|
+
int ret = rig_get_ctcss_tone((RIG*)h, (vfo_t)vfo, &t);
|
|
647
|
+
if (tone) *tone = (unsigned int)t;
|
|
648
|
+
return ret;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
SHIM_API int shim_rig_set_dcs_code(hamlib_shim_handle_t h, int vfo, unsigned int code) {
|
|
652
|
+
return rig_set_dcs_code((RIG*)h, (vfo_t)vfo, (tone_t)code);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
SHIM_API int shim_rig_get_dcs_code(hamlib_shim_handle_t h, int vfo, unsigned int* code) {
|
|
656
|
+
tone_t c = 0;
|
|
657
|
+
int ret = rig_get_dcs_code((RIG*)h, (vfo_t)vfo, &c);
|
|
658
|
+
if (code) *code = (unsigned int)c;
|
|
659
|
+
return ret;
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
SHIM_API int shim_rig_set_ctcss_sql(hamlib_shim_handle_t h, int vfo, unsigned int tone) {
|
|
663
|
+
return rig_set_ctcss_sql((RIG*)h, (vfo_t)vfo, (tone_t)tone);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
SHIM_API int shim_rig_get_ctcss_sql(hamlib_shim_handle_t h, int vfo, unsigned int* tone) {
|
|
667
|
+
tone_t t = 0;
|
|
668
|
+
int ret = rig_get_ctcss_sql((RIG*)h, (vfo_t)vfo, &t);
|
|
669
|
+
if (tone) *tone = (unsigned int)t;
|
|
670
|
+
return ret;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
SHIM_API int shim_rig_set_dcs_sql(hamlib_shim_handle_t h, int vfo, unsigned int code) {
|
|
674
|
+
return rig_set_dcs_sql((RIG*)h, (vfo_t)vfo, (tone_t)code);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
SHIM_API int shim_rig_get_dcs_sql(hamlib_shim_handle_t h, int vfo, unsigned int* code) {
|
|
678
|
+
tone_t c = 0;
|
|
679
|
+
int ret = rig_get_dcs_sql((RIG*)h, (vfo_t)vfo, &c);
|
|
680
|
+
if (code) *code = (unsigned int)c;
|
|
681
|
+
return ret;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/* ===== DTMF ===== */
|
|
685
|
+
|
|
686
|
+
SHIM_API int shim_rig_send_dtmf(hamlib_shim_handle_t h, int vfo, const char* digits) {
|
|
687
|
+
return rig_send_dtmf((RIG*)h, (vfo_t)vfo, digits);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
SHIM_API int shim_rig_recv_dtmf(hamlib_shim_handle_t h, int vfo, char* digits, int* length) {
|
|
691
|
+
return rig_recv_dtmf((RIG*)h, (vfo_t)vfo, digits, length);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/* ===== Morse code ===== */
|
|
695
|
+
|
|
696
|
+
SHIM_API int shim_rig_send_morse(hamlib_shim_handle_t h, int vfo, const char* msg) {
|
|
697
|
+
return rig_send_morse((RIG*)h, (vfo_t)vfo, msg);
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
SHIM_API int shim_rig_stop_morse(hamlib_shim_handle_t h, int vfo) {
|
|
701
|
+
return rig_stop_morse((RIG*)h, (vfo_t)vfo);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
SHIM_API int shim_rig_wait_morse(hamlib_shim_handle_t h, int vfo) {
|
|
705
|
+
return rig_wait_morse((RIG*)h, (vfo_t)vfo);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
/* ===== Voice memory ===== */
|
|
709
|
+
|
|
710
|
+
SHIM_API int shim_rig_send_voice_mem(hamlib_shim_handle_t h, int vfo, int ch) {
|
|
711
|
+
return rig_send_voice_mem((RIG*)h, (vfo_t)vfo, ch);
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
SHIM_API int shim_rig_stop_voice_mem(hamlib_shim_handle_t h, int vfo) {
|
|
715
|
+
#if HAVE_RIG_STOP_VOICE_MEM
|
|
716
|
+
return rig_stop_voice_mem((RIG*)h, (vfo_t)vfo);
|
|
717
|
+
#else
|
|
718
|
+
(void)h; (void)vfo;
|
|
719
|
+
return -RIG_ENIMPL;
|
|
720
|
+
#endif
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
/* ===== Power control ===== */
|
|
724
|
+
|
|
725
|
+
SHIM_API int shim_rig_set_powerstat(hamlib_shim_handle_t h, int status) {
|
|
726
|
+
return rig_set_powerstat((RIG*)h, (powerstat_t)status);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
SHIM_API int shim_rig_get_powerstat(hamlib_shim_handle_t h, int* status) {
|
|
730
|
+
powerstat_t s = 0;
|
|
731
|
+
int ret = rig_get_powerstat((RIG*)h, &s);
|
|
732
|
+
if (status) *status = (int)s;
|
|
733
|
+
return ret;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/* ===== Power conversion ===== */
|
|
737
|
+
|
|
738
|
+
SHIM_API int shim_rig_power2mW(hamlib_shim_handle_t h, unsigned int* mwpower, float power, double freq, int mode) {
|
|
739
|
+
return rig_power2mW((RIG*)h, mwpower, power, (freq_t)freq, (rmode_t)mode);
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
SHIM_API int shim_rig_mW2power(hamlib_shim_handle_t h, float* power, unsigned int mwpower, double freq, int mode) {
|
|
743
|
+
return rig_mW2power((RIG*)h, power, mwpower, (freq_t)freq, (rmode_t)mode);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
/* ===== Reset ===== */
|
|
747
|
+
|
|
748
|
+
SHIM_API int shim_rig_reset(hamlib_shim_handle_t h, int reset_type) {
|
|
749
|
+
return rig_reset((RIG*)h, (reset_t)reset_type);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/* ===== Callbacks ===== */
|
|
753
|
+
|
|
754
|
+
/* Internal adapter structs for callback forwarding */
|
|
755
|
+
struct shim_freq_cb_adapter {
|
|
756
|
+
shim_freq_cb_t user_cb;
|
|
757
|
+
void* user_arg;
|
|
758
|
+
};
|
|
759
|
+
|
|
760
|
+
struct shim_ptt_cb_adapter {
|
|
761
|
+
shim_ptt_cb_t user_cb;
|
|
762
|
+
void* user_arg;
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
/* We store adapters statically (one per rig handle - simplified) */
|
|
766
|
+
static struct shim_freq_cb_adapter freq_cb_adapter = {NULL, NULL};
|
|
767
|
+
static struct shim_ptt_cb_adapter ptt_cb_adapter = {NULL, NULL};
|
|
768
|
+
|
|
769
|
+
static int shim_freq_cb_thunk(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg) {
|
|
770
|
+
struct shim_freq_cb_adapter *adapter = (struct shim_freq_cb_adapter*)arg;
|
|
771
|
+
if (adapter && adapter->user_cb) {
|
|
772
|
+
return adapter->user_cb((void*)rig, (int)vfo, (double)freq, adapter->user_arg);
|
|
773
|
+
}
|
|
774
|
+
return 0;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
static int shim_ptt_cb_thunk(RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg) {
|
|
778
|
+
struct shim_ptt_cb_adapter *adapter = (struct shim_ptt_cb_adapter*)arg;
|
|
779
|
+
if (adapter && adapter->user_cb) {
|
|
780
|
+
return adapter->user_cb((void*)rig, (int)vfo, (int)ptt, adapter->user_arg);
|
|
781
|
+
}
|
|
782
|
+
return 0;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
SHIM_API int shim_rig_set_freq_callback(hamlib_shim_handle_t h, shim_freq_cb_t cb, void* arg) {
|
|
786
|
+
freq_cb_adapter.user_cb = cb;
|
|
787
|
+
freq_cb_adapter.user_arg = arg;
|
|
788
|
+
return rig_set_freq_callback((RIG*)h, shim_freq_cb_thunk, &freq_cb_adapter);
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
SHIM_API int shim_rig_set_ptt_callback(hamlib_shim_handle_t h, shim_ptt_cb_t cb, void* arg) {
|
|
792
|
+
ptt_cb_adapter.user_cb = cb;
|
|
793
|
+
ptt_cb_adapter.user_arg = arg;
|
|
794
|
+
return rig_set_ptt_callback((RIG*)h, shim_ptt_cb_thunk, &ptt_cb_adapter);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
SHIM_API int shim_rig_set_trn(hamlib_shim_handle_t h, int trn) {
|
|
798
|
+
return rig_set_trn((RIG*)h, trn);
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
/* ===== Capability queries ===== */
|
|
802
|
+
|
|
803
|
+
SHIM_API uint64_t shim_rig_get_mode_list(hamlib_shim_handle_t h) {
|
|
804
|
+
RIG* rig = (RIG*)h;
|
|
805
|
+
return (uint64_t)(rig->state.mode_list);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
SHIM_API uint64_t shim_rig_get_caps_has_get_level(hamlib_shim_handle_t h) {
|
|
809
|
+
RIG* rig = (RIG*)h;
|
|
810
|
+
return (uint64_t)(rig->caps->has_get_level);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
SHIM_API uint64_t shim_rig_get_caps_has_set_level(hamlib_shim_handle_t h) {
|
|
814
|
+
RIG* rig = (RIG*)h;
|
|
815
|
+
return (uint64_t)(rig->caps->has_set_level);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
SHIM_API uint64_t shim_rig_get_caps_has_get_func(hamlib_shim_handle_t h) {
|
|
819
|
+
RIG* rig = (RIG*)h;
|
|
820
|
+
return (uint64_t)(rig->caps->has_get_func);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
SHIM_API uint64_t shim_rig_get_caps_has_set_func(hamlib_shim_handle_t h) {
|
|
824
|
+
RIG* rig = (RIG*)h;
|
|
825
|
+
return (uint64_t)(rig->caps->has_set_func);
|
|
826
|
+
}
|
|
827
|
+
|
|
828
|
+
SHIM_API int shim_rig_sprintf_mode(uint64_t modes, char* buf, int buflen) {
|
|
829
|
+
if (!buf || buflen <= 0) return 0;
|
|
830
|
+
buf[0] = '\0';
|
|
831
|
+
int pos = 0;
|
|
832
|
+
uint64_t mode;
|
|
833
|
+
for (mode = 1; mode != 0 && pos < buflen - 1; mode <<= 1) {
|
|
834
|
+
if (modes & mode) {
|
|
835
|
+
const char* name = rig_strrmode((rmode_t)mode);
|
|
836
|
+
if (name && name[0] != '?') {
|
|
837
|
+
int len = (int)strlen(name);
|
|
838
|
+
if (pos + len + 1 < buflen) {
|
|
839
|
+
if (pos > 0) buf[pos++] = ' ';
|
|
840
|
+
memcpy(buf + pos, name, len);
|
|
841
|
+
pos += len;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
buf[pos] = '\0';
|
|
847
|
+
return pos;
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
/* ===== Rig type to string ===== */
|
|
851
|
+
|
|
852
|
+
SHIM_API const char* shim_rig_type_str(int rig_type) {
|
|
853
|
+
switch (rig_type & RIG_TYPE_MASK) {
|
|
854
|
+
case RIG_TYPE_TRANSCEIVER: return "Transceiver";
|
|
855
|
+
case RIG_TYPE_HANDHELD: return "Handheld";
|
|
856
|
+
case RIG_TYPE_MOBILE: return "Mobile";
|
|
857
|
+
case RIG_TYPE_RECEIVER: return "Receiver";
|
|
858
|
+
case RIG_TYPE_PCRECEIVER: return "PC Receiver";
|
|
859
|
+
case RIG_TYPE_SCANNER: return "Scanner";
|
|
860
|
+
case RIG_TYPE_TRUNKSCANNER: return "Trunk Scanner";
|
|
861
|
+
case RIG_TYPE_COMPUTER: return "Computer";
|
|
862
|
+
case RIG_TYPE_OTHER: return "Other";
|
|
863
|
+
default: return "Unknown";
|
|
864
|
+
}
|
|
865
|
+
}
|