hamlib 0.4.1 → 0.4.3

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.
@@ -0,0 +1,62 @@
1
+ #pragma once
2
+
3
+ #include <napi.h>
4
+ #include "shim/hamlib_shim.h"
5
+ #include <string>
6
+
7
+ class NodeRotator : public Napi::ObjectWrap<NodeRotator> {
8
+ public:
9
+ NodeRotator(const Napi::CallbackInfo&);
10
+ ~NodeRotator();
11
+
12
+ Napi::Value Open(const Napi::CallbackInfo&);
13
+ Napi::Value Close(const Napi::CallbackInfo&);
14
+ Napi::Value Destroy(const Napi::CallbackInfo&);
15
+ Napi::Value GetConnectionInfo(const Napi::CallbackInfo&);
16
+
17
+ Napi::Value SetPosition(const Napi::CallbackInfo&);
18
+ Napi::Value GetPosition(const Napi::CallbackInfo&);
19
+ Napi::Value Move(const Napi::CallbackInfo&);
20
+ Napi::Value Stop(const Napi::CallbackInfo&);
21
+ Napi::Value Park(const Napi::CallbackInfo&);
22
+ Napi::Value Reset(const Napi::CallbackInfo&);
23
+ Napi::Value GetInfo(const Napi::CallbackInfo&);
24
+ Napi::Value GetStatus(const Napi::CallbackInfo&);
25
+
26
+ Napi::Value SetConf(const Napi::CallbackInfo&);
27
+ Napi::Value GetConf(const Napi::CallbackInfo&);
28
+ Napi::Value GetConfigSchema(const Napi::CallbackInfo&);
29
+ Napi::Value GetPortCaps(const Napi::CallbackInfo&);
30
+ Napi::Value GetRotatorCaps(const Napi::CallbackInfo&);
31
+
32
+ Napi::Value SetLevel(const Napi::CallbackInfo&);
33
+ Napi::Value GetLevel(const Napi::CallbackInfo&);
34
+ Napi::Value GetSupportedLevels(const Napi::CallbackInfo&);
35
+ Napi::Value SetFunction(const Napi::CallbackInfo&);
36
+ Napi::Value GetFunction(const Napi::CallbackInfo&);
37
+ Napi::Value GetSupportedFunctions(const Napi::CallbackInfo&);
38
+ Napi::Value SetParm(const Napi::CallbackInfo&);
39
+ Napi::Value GetParm(const Napi::CallbackInfo&);
40
+ Napi::Value GetSupportedParms(const Napi::CallbackInfo&);
41
+
42
+ static Napi::Value GetSupportedRotators(const Napi::CallbackInfo&);
43
+ static Napi::Value GetHamlibVersion(const Napi::CallbackInfo&);
44
+ static Napi::Value SetDebugLevel(const Napi::CallbackInfo&);
45
+ static Napi::Value GetDebugLevel(const Napi::CallbackInfo&);
46
+ static Napi::Value GetCopyright(const Napi::CallbackInfo&);
47
+ static Napi::Value GetLicense(const Napi::CallbackInfo&);
48
+
49
+ static Napi::Function GetClass(Napi::Env);
50
+
51
+ hamlib_shim_handle_t my_rot;
52
+ bool rot_is_open = false;
53
+ bool is_network_rot = false;
54
+ unsigned int original_model = 0;
55
+ char port_path[SHIM_HAMLIB_FILPATHLEN];
56
+ static Napi::FunctionReference constructor;
57
+
58
+ private:
59
+ bool isNetworkAddress(const char* path);
60
+ static int rot_list_callback(const shim_rot_info_t* info, void* data);
61
+ static int rot_config_callback(const shim_confparam_info_t* info, void* data);
62
+ };
@@ -11,6 +11,7 @@
11
11
  #endif
12
12
  #include "hamlib_shim.h"
13
13
  #include <hamlib/rig.h>
14
+ #include <hamlib/rotator.h>
14
15
  #include <string.h>
15
16
  #include <stdio.h>
16
17
 
@@ -32,6 +33,22 @@ SHIM_API int shim_rig_cleanup(hamlib_shim_handle_t h) {
32
33
  return rig_cleanup((RIG*)h);
33
34
  }
34
35
 
36
+ SHIM_API hamlib_shim_handle_t shim_rot_init(unsigned int model) {
37
+ return (hamlib_shim_handle_t)rot_init((rot_model_t)model);
38
+ }
39
+
40
+ SHIM_API int shim_rot_open(hamlib_shim_handle_t h) {
41
+ return rot_open((ROT*)h);
42
+ }
43
+
44
+ SHIM_API int shim_rot_close(hamlib_shim_handle_t h) {
45
+ return rot_close((ROT*)h);
46
+ }
47
+
48
+ SHIM_API int shim_rot_cleanup(hamlib_shim_handle_t h) {
49
+ return rot_cleanup((ROT*)h);
50
+ }
51
+
35
52
  SHIM_API const char* shim_rigerror(int errcode) {
36
53
  return rigerror(errcode);
37
54
  }
@@ -60,12 +77,40 @@ SHIM_API int shim_rig_load_all_backends(void) {
60
77
  return rig_load_all_backends();
61
78
  }
62
79
 
80
+ SHIM_API int shim_rot_load_all_backends(void) {
81
+ return rot_load_all_backends();
82
+ }
83
+
63
84
  /* Internal callback adapter for rig_list_foreach */
64
85
  struct shim_list_adapter {
65
86
  shim_rig_list_cb_t user_cb;
66
87
  void* user_data;
67
88
  };
68
89
 
90
+ struct shim_rot_list_adapter {
91
+ shim_rot_list_cb_t user_cb;
92
+ void* user_data;
93
+ };
94
+
95
+ struct shim_cfg_adapter {
96
+ RIG* rig;
97
+ shim_rig_cfg_cb_t user_cb;
98
+ void* user_data;
99
+ };
100
+
101
+ struct shim_rot_cfg_adapter {
102
+ ROT* rot;
103
+ shim_rig_cfg_cb_t user_cb;
104
+ void* user_data;
105
+ };
106
+
107
+ static void shim_copy_string(char* dest, size_t dest_size, const char* src) {
108
+ if (!dest || dest_size == 0) return;
109
+ if (!src) src = "";
110
+ strncpy(dest, src, dest_size - 1);
111
+ dest[dest_size - 1] = '\0';
112
+ }
113
+
69
114
  static int shim_list_foreach_adapter(const struct rig_caps *caps, void *data) {
70
115
  struct shim_list_adapter *adapter = (struct shim_list_adapter*)data;
71
116
  shim_rig_info_t info;
@@ -85,10 +130,292 @@ SHIM_API int shim_rig_list_foreach(shim_rig_list_cb_t cb, void* data) {
85
130
  return rig_list_foreach(shim_list_foreach_adapter, &adapter);
86
131
  }
87
132
 
133
+ static int shim_rot_list_foreach_adapter(const struct rot_caps *caps, void *data) {
134
+ struct shim_rot_list_adapter *adapter = (struct shim_rot_list_adapter*)data;
135
+ shim_rot_info_t info;
136
+ info.rot_model = caps->rot_model;
137
+ info.model_name = caps->model_name ? caps->model_name : "";
138
+ info.mfg_name = caps->mfg_name ? caps->mfg_name : "";
139
+ info.version = caps->version ? caps->version : "";
140
+ info.status = (int)caps->status;
141
+ info.rot_type = caps->rot_type;
142
+ return adapter->user_cb(&info, adapter->user_data);
143
+ }
144
+
145
+ SHIM_API int shim_rot_list_foreach(shim_rot_list_cb_t cb, void* data) {
146
+ struct shim_rot_list_adapter adapter;
147
+ adapter.user_cb = cb;
148
+ adapter.user_data = data;
149
+ return rot_list_foreach(shim_rot_list_foreach_adapter, &adapter);
150
+ }
151
+
152
+ static int shim_cfg_foreach_adapter(const struct confparams* param, rig_ptr_t data) {
153
+ struct shim_cfg_adapter* adapter = (struct shim_cfg_adapter*)data;
154
+ const struct confparams* lookup;
155
+ shim_confparam_info_t info;
156
+ int i;
157
+
158
+ if (!adapter || !adapter->user_cb || !param) {
159
+ return 0;
160
+ }
161
+
162
+ if (!adapter->rig || !param->name) {
163
+ return 1;
164
+ }
165
+
166
+ lookup = rig_confparam_lookup(adapter->rig, param->name);
167
+ if (!lookup || lookup->token != param->token) {
168
+ return 1;
169
+ }
170
+
171
+ memset(&info, 0, sizeof(info));
172
+ info.token = (int)param->token;
173
+ info.type = (int)param->type;
174
+
175
+ shim_copy_string(info.name, sizeof(info.name), param->name);
176
+ shim_copy_string(info.label, sizeof(info.label), param->label);
177
+ shim_copy_string(info.tooltip, sizeof(info.tooltip), param->tooltip);
178
+ shim_copy_string(info.dflt, sizeof(info.dflt), param->dflt);
179
+
180
+ if (param->type == RIG_CONF_NUMERIC || param->type == RIG_CONF_INT) {
181
+ info.numeric_min = param->u.n.min;
182
+ info.numeric_max = param->u.n.max;
183
+ info.numeric_step = param->u.n.step;
184
+ } else if (param->type == RIG_CONF_COMBO) {
185
+ for (i = 0; i < RIG_COMBO_MAX && i < SHIM_CONF_COMBO_MAX; ++i) {
186
+ if (!param->u.c.combostr[i] || !*param->u.c.combostr[i]) {
187
+ break;
188
+ }
189
+
190
+ shim_copy_string(
191
+ info.combo_options[i],
192
+ sizeof(info.combo_options[i]),
193
+ param->u.c.combostr[i]
194
+ );
195
+ info.combo_count++;
196
+ }
197
+ }
198
+
199
+ return adapter->user_cb(&info, adapter->user_data);
200
+ }
201
+
202
+ SHIM_API int shim_rig_cfgparams_foreach(hamlib_shim_handle_t h, shim_rig_cfg_cb_t cb, void* data) {
203
+ RIG* rig = (RIG*)h;
204
+ struct shim_cfg_adapter adapter;
205
+
206
+ if (!rig || !cb) {
207
+ return -RIG_EINVAL;
208
+ }
209
+
210
+ adapter.rig = rig;
211
+ adapter.user_cb = cb;
212
+ adapter.user_data = data;
213
+
214
+ return rig_token_foreach(rig, shim_cfg_foreach_adapter, &adapter);
215
+ }
216
+
217
+ static int shim_rot_cfg_foreach_adapter(const struct confparams* param, rig_ptr_t data) {
218
+ struct shim_rot_cfg_adapter* adapter = (struct shim_rot_cfg_adapter*)data;
219
+ const struct confparams* lookup;
220
+ shim_confparam_info_t info;
221
+ int i;
222
+
223
+ if (!adapter || !adapter->user_cb || !param) {
224
+ return 0;
225
+ }
226
+
227
+ if (!adapter->rot || !param->name) {
228
+ return 1;
229
+ }
230
+
231
+ lookup = rot_confparam_lookup(adapter->rot, param->name);
232
+ if (!lookup || lookup->token != param->token) {
233
+ return 1;
234
+ }
235
+
236
+ memset(&info, 0, sizeof(info));
237
+ info.token = (int)param->token;
238
+ info.type = (int)param->type;
239
+
240
+ shim_copy_string(info.name, sizeof(info.name), param->name);
241
+ shim_copy_string(info.label, sizeof(info.label), param->label);
242
+ shim_copy_string(info.tooltip, sizeof(info.tooltip), param->tooltip);
243
+ shim_copy_string(info.dflt, sizeof(info.dflt), param->dflt);
244
+
245
+ if (param->type == RIG_CONF_NUMERIC || param->type == RIG_CONF_INT) {
246
+ info.numeric_min = param->u.n.min;
247
+ info.numeric_max = param->u.n.max;
248
+ info.numeric_step = param->u.n.step;
249
+ } else if (param->type == RIG_CONF_COMBO) {
250
+ for (i = 0; i < RIG_COMBO_MAX && i < SHIM_CONF_COMBO_MAX; ++i) {
251
+ if (!param->u.c.combostr[i] || !*param->u.c.combostr[i]) {
252
+ break;
253
+ }
254
+
255
+ shim_copy_string(
256
+ info.combo_options[i],
257
+ sizeof(info.combo_options[i]),
258
+ param->u.c.combostr[i]
259
+ );
260
+ info.combo_count++;
261
+ }
262
+ }
263
+
264
+ return adapter->user_cb(&info, adapter->user_data);
265
+ }
266
+
267
+ SHIM_API int shim_rot_cfgparams_foreach(hamlib_shim_handle_t h, shim_rig_cfg_cb_t cb, void* data) {
268
+ ROT* rot = (ROT*)h;
269
+ struct shim_rot_cfg_adapter adapter;
270
+
271
+ if (!rot || !cb) {
272
+ return -RIG_EINVAL;
273
+ }
274
+
275
+ adapter.rot = rot;
276
+ adapter.user_cb = cb;
277
+ adapter.user_data = data;
278
+
279
+ return rot_token_foreach(rot, shim_rot_cfg_foreach_adapter, &adapter);
280
+ }
281
+
282
+ static const char* shim_port_type_name(enum rig_port_e port_type) {
283
+ switch (port_type) {
284
+ case RIG_PORT_NONE: return "none";
285
+ case RIG_PORT_SERIAL: return "serial";
286
+ case RIG_PORT_NETWORK: return "network";
287
+ case RIG_PORT_DEVICE: return "device";
288
+ case RIG_PORT_PACKET: return "packet";
289
+ case RIG_PORT_DTMF: return "dtmf";
290
+ case RIG_PORT_ULTRA: return "ultra";
291
+ case RIG_PORT_RPC: return "rpc";
292
+ case RIG_PORT_PARALLEL: return "parallel";
293
+ case RIG_PORT_USB: return "usb";
294
+ case RIG_PORT_UDP_NETWORK: return "udp-network";
295
+ case RIG_PORT_CM108: return "cm108";
296
+ case RIG_PORT_GPIO: return "gpio";
297
+ case RIG_PORT_GPION: return "gpion";
298
+ default: return "other";
299
+ }
300
+ }
301
+
302
+ static const char* shim_serial_parity_name(enum serial_parity_e parity) {
303
+ switch (parity) {
304
+ case RIG_PARITY_NONE: return "None";
305
+ case RIG_PARITY_ODD: return "Odd";
306
+ case RIG_PARITY_EVEN: return "Even";
307
+ case RIG_PARITY_MARK: return "Mark";
308
+ case RIG_PARITY_SPACE: return "Space";
309
+ default: return "Unknown";
310
+ }
311
+ }
312
+
313
+ static const char* shim_serial_handshake_name(enum serial_handshake_e handshake) {
314
+ switch (handshake) {
315
+ case RIG_HANDSHAKE_NONE: return "None";
316
+ case RIG_HANDSHAKE_XONXOFF: return "XONXOFF";
317
+ case RIG_HANDSHAKE_HARDWARE: return "Hardware";
318
+ default: return "Unknown";
319
+ }
320
+ }
321
+
322
+ SHIM_API int shim_rig_get_port_caps(hamlib_shim_handle_t h, shim_rig_port_caps_t* out_caps) {
323
+ RIG* rig = (RIG*)h;
324
+ const struct rig_caps* caps;
325
+
326
+ if (!rig || !out_caps || !rig->caps) {
327
+ return -RIG_EINVAL;
328
+ }
329
+
330
+ caps = rig->caps;
331
+ memset(out_caps, 0, sizeof(*out_caps));
332
+
333
+ shim_copy_string(out_caps->port_type, sizeof(out_caps->port_type), shim_port_type_name(caps->port_type));
334
+ out_caps->serial_rate_min = caps->serial_rate_min;
335
+ out_caps->serial_rate_max = caps->serial_rate_max;
336
+ out_caps->serial_data_bits = caps->serial_data_bits;
337
+ out_caps->serial_stop_bits = caps->serial_stop_bits;
338
+ shim_copy_string(out_caps->serial_parity, sizeof(out_caps->serial_parity), shim_serial_parity_name(caps->serial_parity));
339
+ shim_copy_string(out_caps->serial_handshake, sizeof(out_caps->serial_handshake), shim_serial_handshake_name(caps->serial_handshake));
340
+ out_caps->write_delay = caps->write_delay;
341
+ out_caps->post_write_delay = caps->post_write_delay;
342
+ out_caps->timeout = caps->timeout;
343
+ out_caps->retry = caps->retry;
344
+
345
+ return RIG_OK;
346
+ }
347
+
88
348
  SHIM_API const char* shim_rig_strstatus(int status) {
89
349
  return rig_strstatus((enum rig_status_e)status);
90
350
  }
91
351
 
352
+ SHIM_API int shim_rot_get_port_caps(hamlib_shim_handle_t h, shim_rig_port_caps_t* out_caps) {
353
+ ROT* rot = (ROT*)h;
354
+ const struct rot_caps* caps;
355
+
356
+ if (!rot || !out_caps || !rot->caps) {
357
+ return -RIG_EINVAL;
358
+ }
359
+
360
+ caps = rot->caps;
361
+ memset(out_caps, 0, sizeof(*out_caps));
362
+
363
+ shim_copy_string(out_caps->port_type, sizeof(out_caps->port_type), shim_port_type_name(caps->port_type));
364
+ out_caps->serial_rate_min = caps->serial_rate_min;
365
+ out_caps->serial_rate_max = caps->serial_rate_max;
366
+ out_caps->serial_data_bits = caps->serial_data_bits;
367
+ out_caps->serial_stop_bits = caps->serial_stop_bits;
368
+ shim_copy_string(out_caps->serial_parity, sizeof(out_caps->serial_parity), shim_serial_parity_name(caps->serial_parity));
369
+ shim_copy_string(out_caps->serial_handshake, sizeof(out_caps->serial_handshake), shim_serial_handshake_name(caps->serial_handshake));
370
+ out_caps->write_delay = caps->write_delay;
371
+ out_caps->post_write_delay = caps->post_write_delay;
372
+ out_caps->timeout = caps->timeout;
373
+ out_caps->retry = caps->retry;
374
+
375
+ return RIG_OK;
376
+ }
377
+
378
+ SHIM_API int shim_rot_get_caps(hamlib_shim_handle_t h, shim_rot_caps_t* out_caps) {
379
+ ROT* rot = (ROT*)h;
380
+ const struct rot_caps* caps;
381
+
382
+ if (!rot || !out_caps || !rot->caps) {
383
+ return -RIG_EINVAL;
384
+ }
385
+
386
+ caps = rot->caps;
387
+ memset(out_caps, 0, sizeof(*out_caps));
388
+ out_caps->rot_type = caps->rot_type;
389
+ out_caps->min_az = caps->min_az;
390
+ out_caps->max_az = caps->max_az;
391
+ out_caps->min_el = caps->min_el;
392
+ out_caps->max_el = caps->max_el;
393
+ out_caps->has_get_level = (uint64_t)caps->has_get_level;
394
+ out_caps->has_set_level = (uint64_t)caps->has_set_level;
395
+ out_caps->has_get_func = (uint64_t)caps->has_get_func;
396
+ out_caps->has_set_func = (uint64_t)caps->has_set_func;
397
+ out_caps->has_get_parm = (uint64_t)caps->has_get_parm;
398
+ out_caps->has_set_parm = (uint64_t)caps->has_set_parm;
399
+ out_caps->has_status = (int)caps->has_status;
400
+
401
+ return RIG_OK;
402
+ }
403
+
404
+ SHIM_API const char* shim_rot_strstatus(int status) {
405
+ return rot_strstatus((rot_status_t)status);
406
+ }
407
+
408
+ SHIM_API const char* shim_rot_type_str(int rot_type) {
409
+ switch (rot_type) {
410
+ case ROT_TYPE_AZIMUTH: return "azimuth";
411
+ case ROT_TYPE_ELEVATION: return "elevation";
412
+ case ROT_TYPE_AZEL: return "azel";
413
+ case ROT_TYPE_OTHER:
414
+ default:
415
+ return "other";
416
+ }
417
+ }
418
+
92
419
  /* ===== Port configuration ===== */
93
420
 
94
421
  SHIM_API void shim_rig_set_port_path(hamlib_shim_handle_t h, const char* path) {
@@ -102,6 +429,17 @@ SHIM_API void shim_rig_set_port_type(hamlib_shim_handle_t h, int type) {
102
429
  rig->state.rigport.type.rig = (enum rig_port_e)type;
103
430
  }
104
431
 
432
+ SHIM_API void shim_rot_set_port_path(hamlib_shim_handle_t h, const char* path) {
433
+ ROT* rot = (ROT*)h;
434
+ strncpy(rot->state.rotport.pathname, path, HAMLIB_FILPATHLEN - 1);
435
+ rot->state.rotport.pathname[HAMLIB_FILPATHLEN - 1] = '\0';
436
+ }
437
+
438
+ SHIM_API void shim_rot_set_port_type(hamlib_shim_handle_t h, int type) {
439
+ ROT* rot = (ROT*)h;
440
+ rot->state.rotport.type.rig = (enum rig_port_e)type;
441
+ }
442
+
105
443
  /* Serial config */
106
444
  SHIM_API void shim_rig_set_serial_rate(hamlib_shim_handle_t h, int rate) {
107
445
  RIG* rig = (RIG*)h;
@@ -842,6 +1180,215 @@ SHIM_API int shim_rig_reset(hamlib_shim_handle_t h, int reset_type) {
842
1180
  return rig_reset((RIG*)h, (reset_t)reset_type);
843
1181
  }
844
1182
 
1183
+ /* ===== Rotator control ===== */
1184
+
1185
+ SHIM_API int shim_rot_set_position(hamlib_shim_handle_t h, double azimuth, double elevation) {
1186
+ return rot_set_position((ROT*)h, (azimuth_t)azimuth, (elevation_t)elevation);
1187
+ }
1188
+
1189
+ SHIM_API int shim_rot_get_position(hamlib_shim_handle_t h, double* azimuth, double* elevation) {
1190
+ azimuth_t az = 0;
1191
+ elevation_t el = 0;
1192
+ int ret = rot_get_position((ROT*)h, &az, &el);
1193
+ if (azimuth) *azimuth = (double)az;
1194
+ if (elevation) *elevation = (double)el;
1195
+ return ret;
1196
+ }
1197
+
1198
+ SHIM_API int shim_rot_stop(hamlib_shim_handle_t h) {
1199
+ return rot_stop((ROT*)h);
1200
+ }
1201
+
1202
+ SHIM_API int shim_rot_park(hamlib_shim_handle_t h) {
1203
+ return rot_park((ROT*)h);
1204
+ }
1205
+
1206
+ SHIM_API int shim_rot_reset(hamlib_shim_handle_t h, int reset_type) {
1207
+ return rot_reset((ROT*)h, (rot_reset_t)reset_type);
1208
+ }
1209
+
1210
+ SHIM_API int shim_rot_move(hamlib_shim_handle_t h, int direction, int speed) {
1211
+ return rot_move((ROT*)h, direction, speed);
1212
+ }
1213
+
1214
+ SHIM_API const char* shim_rot_get_info(hamlib_shim_handle_t h) {
1215
+ ROT *rot = (ROT *)h;
1216
+ if (!rot) return "";
1217
+ {
1218
+ const char *info = rot_get_info(rot);
1219
+ return info ? info : "";
1220
+ }
1221
+ }
1222
+
1223
+ SHIM_API int shim_rot_get_status(hamlib_shim_handle_t h, int* status) {
1224
+ rot_status_t s = 0;
1225
+ int ret = rot_get_status((ROT*)h, &s);
1226
+ if (status) *status = (int)s;
1227
+ return ret;
1228
+ }
1229
+
1230
+ SHIM_API int shim_rot_set_conf(hamlib_shim_handle_t h, const char* name, const char* val) {
1231
+ ROT *rot = (ROT *)h;
1232
+ hamlib_token_t token;
1233
+ if (!rot || !name || !val) return -RIG_EINVAL;
1234
+ token = rot_token_lookup(rot, name);
1235
+ if (token == 0) return -RIG_EINVAL;
1236
+ return rot_set_conf(rot, token, val);
1237
+ }
1238
+
1239
+ SHIM_API int shim_rot_get_conf(hamlib_shim_handle_t h, const char* name, char* buf, int buflen) {
1240
+ ROT *rot = (ROT *)h;
1241
+ hamlib_token_t token;
1242
+ if (!rot || !name || !buf || buflen <= 0) return -RIG_EINVAL;
1243
+ token = rot_token_lookup(rot, name);
1244
+ if (token == 0) return -RIG_EINVAL;
1245
+ return rot_get_conf2(rot, token, buf, buflen);
1246
+ }
1247
+
1248
+ SHIM_API uint64_t shim_rot_get_caps_has_get_level(hamlib_shim_handle_t h) {
1249
+ ROT *rot = (ROT *)h;
1250
+ return rot && rot->caps ? (uint64_t)rot->caps->has_get_level : 0;
1251
+ }
1252
+
1253
+ SHIM_API uint64_t shim_rot_get_caps_has_set_level(hamlib_shim_handle_t h) {
1254
+ ROT *rot = (ROT *)h;
1255
+ return rot && rot->caps ? (uint64_t)rot->caps->has_set_level : 0;
1256
+ }
1257
+
1258
+ SHIM_API uint64_t shim_rot_get_caps_has_get_func(hamlib_shim_handle_t h) {
1259
+ ROT *rot = (ROT *)h;
1260
+ return rot && rot->caps ? (uint64_t)rot->caps->has_get_func : 0;
1261
+ }
1262
+
1263
+ SHIM_API uint64_t shim_rot_get_caps_has_set_func(hamlib_shim_handle_t h) {
1264
+ ROT *rot = (ROT *)h;
1265
+ return rot && rot->caps ? (uint64_t)rot->caps->has_set_func : 0;
1266
+ }
1267
+
1268
+ SHIM_API uint64_t shim_rot_get_caps_has_get_parm(hamlib_shim_handle_t h) {
1269
+ ROT *rot = (ROT *)h;
1270
+ return rot && rot->caps ? (uint64_t)rot->caps->has_get_parm : 0;
1271
+ }
1272
+
1273
+ SHIM_API uint64_t shim_rot_get_caps_has_set_parm(hamlib_shim_handle_t h) {
1274
+ ROT *rot = (ROT *)h;
1275
+ return rot && rot->caps ? (uint64_t)rot->caps->has_set_parm : 0;
1276
+ }
1277
+
1278
+ SHIM_API int shim_rot_set_level_f(hamlib_shim_handle_t h, uint64_t level, float value) {
1279
+ value_t val;
1280
+ memset(&val, 0, sizeof(val));
1281
+ val.f = value;
1282
+ return rot_set_level((ROT*)h, (setting_t)level, val);
1283
+ }
1284
+
1285
+ SHIM_API int shim_rot_set_level_i(hamlib_shim_handle_t h, uint64_t level, int value) {
1286
+ value_t val;
1287
+ memset(&val, 0, sizeof(val));
1288
+ val.i = value;
1289
+ return rot_set_level((ROT*)h, (setting_t)level, val);
1290
+ }
1291
+
1292
+ SHIM_API int shim_rot_get_level_f(hamlib_shim_handle_t h, uint64_t level, float* value) {
1293
+ value_t val;
1294
+ memset(&val, 0, sizeof(val));
1295
+ {
1296
+ int ret = rot_get_level((ROT*)h, (setting_t)level, &val);
1297
+ if (value) *value = val.f;
1298
+ return ret;
1299
+ }
1300
+ }
1301
+
1302
+ SHIM_API int shim_rot_get_level_i(hamlib_shim_handle_t h, uint64_t level, int* value) {
1303
+ value_t val;
1304
+ memset(&val, 0, sizeof(val));
1305
+ {
1306
+ int ret = rot_get_level((ROT*)h, (setting_t)level, &val);
1307
+ if (value) *value = val.i;
1308
+ return ret;
1309
+ }
1310
+ }
1311
+
1312
+ SHIM_API int shim_rot_get_level_auto(hamlib_shim_handle_t h, uint64_t level, double* value) {
1313
+ value_t val;
1314
+ memset(&val, 0, sizeof(val));
1315
+ {
1316
+ int ret = rot_get_level((ROT*)h, (setting_t)level, &val);
1317
+ if (ret != RIG_OK) return ret;
1318
+ if (value) {
1319
+ if (ROT_LEVEL_IS_FLOAT((setting_t)level)) *value = (double)val.f;
1320
+ else *value = (double)val.i;
1321
+ }
1322
+ return ret;
1323
+ }
1324
+ }
1325
+
1326
+ SHIM_API int shim_rot_set_func(hamlib_shim_handle_t h, uint64_t func, int enable) {
1327
+ return rot_set_func((ROT*)h, (setting_t)func, enable);
1328
+ }
1329
+
1330
+ SHIM_API int shim_rot_get_func(hamlib_shim_handle_t h, uint64_t func, int* state) {
1331
+ return rot_get_func((ROT*)h, (setting_t)func, state);
1332
+ }
1333
+
1334
+ SHIM_API int shim_rot_set_parm_f(hamlib_shim_handle_t h, uint64_t parm, float value) {
1335
+ value_t val;
1336
+ memset(&val, 0, sizeof(val));
1337
+ val.f = value;
1338
+ return rot_set_parm((ROT*)h, (setting_t)parm, val);
1339
+ }
1340
+
1341
+ SHIM_API int shim_rot_set_parm_i(hamlib_shim_handle_t h, uint64_t parm, int value) {
1342
+ value_t val;
1343
+ memset(&val, 0, sizeof(val));
1344
+ val.i = value;
1345
+ return rot_set_parm((ROT*)h, (setting_t)parm, val);
1346
+ }
1347
+
1348
+ SHIM_API int shim_rot_get_parm_f(hamlib_shim_handle_t h, uint64_t parm, float* value) {
1349
+ value_t val;
1350
+ memset(&val, 0, sizeof(val));
1351
+ {
1352
+ int ret = rot_get_parm((ROT*)h, (setting_t)parm, &val);
1353
+ if (value) *value = val.f;
1354
+ return ret;
1355
+ }
1356
+ }
1357
+
1358
+ SHIM_API int shim_rot_get_parm_i(hamlib_shim_handle_t h, uint64_t parm, int* value) {
1359
+ value_t val;
1360
+ memset(&val, 0, sizeof(val));
1361
+ {
1362
+ int ret = rot_get_parm((ROT*)h, (setting_t)parm, &val);
1363
+ if (value) *value = val.i;
1364
+ return ret;
1365
+ }
1366
+ }
1367
+
1368
+ SHIM_API uint64_t shim_rot_parse_level(const char* level_str) {
1369
+ return (uint64_t)rot_parse_level(level_str);
1370
+ }
1371
+
1372
+ SHIM_API uint64_t shim_rot_parse_func(const char* func_str) {
1373
+ return (uint64_t)rot_parse_func(func_str);
1374
+ }
1375
+
1376
+ SHIM_API uint64_t shim_rot_parse_parm(const char* parm_str) {
1377
+ return (uint64_t)rot_parse_parm(parm_str);
1378
+ }
1379
+
1380
+ SHIM_API const char* shim_rot_strlevel(uint64_t level) {
1381
+ return rot_strlevel((setting_t)level);
1382
+ }
1383
+
1384
+ SHIM_API const char* shim_rot_strfunc(uint64_t func) {
1385
+ return rot_strfunc((setting_t)func);
1386
+ }
1387
+
1388
+ SHIM_API const char* shim_rot_strparm(uint64_t parm) {
1389
+ return rot_strparm((setting_t)parm);
1390
+ }
1391
+
845
1392
  /* ===== Callbacks ===== */
846
1393
 
847
1394
  /* Internal adapter structs for callback forwarding */