hamlib 0.4.2 → 0.4.4

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,18 +77,33 @@ 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
+
69
95
  struct shim_cfg_adapter {
70
96
  RIG* rig;
71
97
  shim_rig_cfg_cb_t user_cb;
72
98
  void* user_data;
73
99
  };
74
100
 
101
+ struct shim_rot_cfg_adapter {
102
+ ROT* rot;
103
+ shim_rig_cfg_cb_t user_cb;
104
+ void* user_data;
105
+ };
106
+
75
107
  static void shim_copy_string(char* dest, size_t dest_size, const char* src) {
76
108
  if (!dest || dest_size == 0) return;
77
109
  if (!src) src = "";
@@ -98,6 +130,25 @@ SHIM_API int shim_rig_list_foreach(shim_rig_list_cb_t cb, void* data) {
98
130
  return rig_list_foreach(shim_list_foreach_adapter, &adapter);
99
131
  }
100
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
+
101
152
  static int shim_cfg_foreach_adapter(const struct confparams* param, rig_ptr_t data) {
102
153
  struct shim_cfg_adapter* adapter = (struct shim_cfg_adapter*)data;
103
154
  const struct confparams* lookup;
@@ -163,6 +214,71 @@ SHIM_API int shim_rig_cfgparams_foreach(hamlib_shim_handle_t h, shim_rig_cfg_cb_
163
214
  return rig_token_foreach(rig, shim_cfg_foreach_adapter, &adapter);
164
215
  }
165
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
+
166
282
  static const char* shim_port_type_name(enum rig_port_e port_type) {
167
283
  switch (port_type) {
168
284
  case RIG_PORT_NONE: return "none";
@@ -233,6 +349,73 @@ SHIM_API const char* shim_rig_strstatus(int status) {
233
349
  return rig_strstatus((enum rig_status_e)status);
234
350
  }
235
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
+
236
419
  /* ===== Port configuration ===== */
237
420
 
238
421
  SHIM_API void shim_rig_set_port_path(hamlib_shim_handle_t h, const char* path) {
@@ -246,6 +429,17 @@ SHIM_API void shim_rig_set_port_type(hamlib_shim_handle_t h, int type) {
246
429
  rig->state.rigport.type.rig = (enum rig_port_e)type;
247
430
  }
248
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
+
249
443
  /* Serial config */
250
444
  SHIM_API void shim_rig_set_serial_rate(hamlib_shim_handle_t h, int rate) {
251
445
  RIG* rig = (RIG*)h;
@@ -986,6 +1180,215 @@ SHIM_API int shim_rig_reset(hamlib_shim_handle_t h, int reset_type) {
986
1180
  return rig_reset((RIG*)h, (reset_t)reset_type);
987
1181
  }
988
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
+
989
1392
  /* ===== Callbacks ===== */
990
1393
 
991
1394
  /* Internal adapter structs for callback forwarding */
@@ -32,7 +32,7 @@ extern "C" {
32
32
  #define SHIM_API
33
33
  #endif
34
34
 
35
- /* Opaque handle type - hides RIG* from the addon */
35
+ /* Opaque handle type - hides RIG* / ROT* from the addon */
36
36
  typedef void* hamlib_shim_handle_t;
37
37
 
38
38
  /* ===== Constants (mirror Hamlib values) ===== */
@@ -70,6 +70,7 @@ typedef void* hamlib_shim_handle_t;
70
70
 
71
71
  /* Passband constants */
72
72
  #define SHIM_RIG_PASSBAND_NORMAL 0
73
+ #define SHIM_RIG_PASSBAND_NOCHANGE (-1)
73
74
 
74
75
  /* Port types (must match hamlib rig_port_e enum) */
75
76
  #define SHIM_RIG_PORT_NONE 0
@@ -147,7 +148,50 @@ typedef void* hamlib_shim_handle_t;
147
148
  #define SHIM_RIG_RESET_MASTER 8
148
149
 
149
150
  /* Antenna */
150
- #define SHIM_RIG_ANT_CURR 0
151
+ #define SHIM_RIG_ANT_CURR ((int)0x80000000u)
152
+
153
+ /* ===== Rotator constants (mirror Hamlib values) ===== */
154
+ #define SHIM_ROT_TYPE_OTHER 0
155
+ #define SHIM_ROT_TYPE_AZIMUTH (1 << 1)
156
+ #define SHIM_ROT_TYPE_ELEVATION (1 << 2)
157
+ #define SHIM_ROT_TYPE_AZEL (SHIM_ROT_TYPE_AZIMUTH | SHIM_ROT_TYPE_ELEVATION)
158
+
159
+ #define SHIM_ROT_MOVE_UP (1 << 1)
160
+ #define SHIM_ROT_MOVE_DOWN (1 << 2)
161
+ #define SHIM_ROT_MOVE_LEFT (1 << 3)
162
+ #define SHIM_ROT_MOVE_CCW SHIM_ROT_MOVE_LEFT
163
+ #define SHIM_ROT_MOVE_RIGHT (1 << 4)
164
+ #define SHIM_ROT_MOVE_CW SHIM_ROT_MOVE_RIGHT
165
+ #define SHIM_ROT_MOVE_UP_LEFT (1 << 5)
166
+ #define SHIM_ROT_MOVE_UP_CCW SHIM_ROT_MOVE_UP_LEFT
167
+ #define SHIM_ROT_MOVE_UP_RIGHT (1 << 6)
168
+ #define SHIM_ROT_MOVE_UP_CW SHIM_ROT_MOVE_UP_RIGHT
169
+ #define SHIM_ROT_MOVE_DOWN_LEFT (1 << 7)
170
+ #define SHIM_ROT_MOVE_DOWN_CCW SHIM_ROT_MOVE_DOWN_LEFT
171
+ #define SHIM_ROT_MOVE_DOWN_RIGHT (1 << 8)
172
+ #define SHIM_ROT_MOVE_DOWN_CW SHIM_ROT_MOVE_DOWN_RIGHT
173
+ #define SHIM_ROT_SPEED_NOCHANGE (-1)
174
+
175
+ #define SHIM_ROT_RESET_ALL 1
176
+ #define SHIM_ROT_LEVEL_SPEED (1ULL << 0)
177
+
178
+ #define SHIM_ROT_STATUS_NONE 0
179
+ #define SHIM_ROT_STATUS_BUSY (1 << 0)
180
+ #define SHIM_ROT_STATUS_MOVING (1 << 1)
181
+ #define SHIM_ROT_STATUS_MOVING_AZ (1 << 2)
182
+ #define SHIM_ROT_STATUS_MOVING_LEFT (1 << 3)
183
+ #define SHIM_ROT_STATUS_MOVING_RIGHT (1 << 4)
184
+ #define SHIM_ROT_STATUS_MOVING_EL (1 << 5)
185
+ #define SHIM_ROT_STATUS_MOVING_UP (1 << 6)
186
+ #define SHIM_ROT_STATUS_MOVING_DOWN (1 << 7)
187
+ #define SHIM_ROT_STATUS_LIMIT_UP (1 << 8)
188
+ #define SHIM_ROT_STATUS_LIMIT_DOWN (1 << 9)
189
+ #define SHIM_ROT_STATUS_LIMIT_LEFT (1 << 10)
190
+ #define SHIM_ROT_STATUS_LIMIT_RIGHT (1 << 11)
191
+ #define SHIM_ROT_STATUS_OVERLAP_UP (1 << 12)
192
+ #define SHIM_ROT_STATUS_OVERLAP_DOWN (1 << 13)
193
+ #define SHIM_ROT_STATUS_OVERLAP_LEFT (1 << 14)
194
+ #define SHIM_ROT_STATUS_OVERLAP_RIGHT (1 << 16)
151
195
 
152
196
  /* Rig type mask and types */
153
197
  #define SHIM_RIG_TYPE_MASK 0x7F000000
@@ -293,6 +337,15 @@ typedef struct {
293
337
  int rig_type;
294
338
  } shim_rig_info_t;
295
339
 
340
+ typedef struct {
341
+ unsigned int rot_model;
342
+ const char* model_name;
343
+ const char* mfg_name;
344
+ const char* version;
345
+ int status;
346
+ int rot_type;
347
+ } shim_rot_info_t;
348
+
296
349
  #define SHIM_CONF_NAME_MAX 64
297
350
  #define SHIM_CONF_LABEL_MAX 128
298
351
  #define SHIM_CONF_TOOLTIP_MAX 256
@@ -331,6 +384,21 @@ typedef struct {
331
384
  int retry;
332
385
  } shim_rig_port_caps_t;
333
386
 
387
+ typedef struct {
388
+ int rot_type;
389
+ double min_az;
390
+ double max_az;
391
+ double min_el;
392
+ double max_el;
393
+ uint64_t has_get_level;
394
+ uint64_t has_set_level;
395
+ uint64_t has_get_func;
396
+ uint64_t has_set_func;
397
+ uint64_t has_get_parm;
398
+ uint64_t has_set_parm;
399
+ int has_status;
400
+ } shim_rot_caps_t;
401
+
334
402
  typedef struct {
335
403
  int id;
336
404
  char name[64];
@@ -369,6 +437,8 @@ typedef int (*shim_spectrum_cb_t)(void* handle, const shim_spectrum_line_t* line
369
437
 
370
438
  /* Rig list callback: (info, data) -> int */
371
439
  typedef int (*shim_rig_list_cb_t)(const shim_rig_info_t* info, void* data);
440
+ /* Rotator list callback: (info, data) -> int */
441
+ typedef int (*shim_rot_list_cb_t)(const shim_rot_info_t* info, void* data);
372
442
  /* Rig config callback: (info, data) -> int */
373
443
  typedef int (*shim_rig_cfg_cb_t)(const shim_confparam_info_t* info, void* data);
374
444
 
@@ -390,11 +460,24 @@ SHIM_API int shim_rig_list_foreach(shim_rig_list_cb_t cb, void* data);
390
460
  SHIM_API int shim_rig_cfgparams_foreach(hamlib_shim_handle_t h, shim_rig_cfg_cb_t cb, void* data);
391
461
  SHIM_API int shim_rig_get_port_caps(hamlib_shim_handle_t h, shim_rig_port_caps_t* out_caps);
392
462
  SHIM_API const char* shim_rig_strstatus(int status);
463
+ SHIM_API hamlib_shim_handle_t shim_rot_init(unsigned int model);
464
+ SHIM_API int shim_rot_open(hamlib_shim_handle_t h);
465
+ SHIM_API int shim_rot_close(hamlib_shim_handle_t h);
466
+ SHIM_API int shim_rot_cleanup(hamlib_shim_handle_t h);
467
+ SHIM_API int shim_rot_load_all_backends(void);
468
+ SHIM_API int shim_rot_list_foreach(shim_rot_list_cb_t cb, void* data);
469
+ SHIM_API int shim_rot_cfgparams_foreach(hamlib_shim_handle_t h, shim_rig_cfg_cb_t cb, void* data);
470
+ SHIM_API int shim_rot_get_port_caps(hamlib_shim_handle_t h, shim_rig_port_caps_t* out_caps);
471
+ SHIM_API int shim_rot_get_caps(hamlib_shim_handle_t h, shim_rot_caps_t* out_caps);
472
+ SHIM_API const char* shim_rot_strstatus(int status);
473
+ SHIM_API const char* shim_rot_type_str(int rot_type);
393
474
 
394
475
  /* ===== Port configuration (before open) ===== */
395
476
 
396
477
  SHIM_API void shim_rig_set_port_path(hamlib_shim_handle_t h, const char* path);
397
478
  SHIM_API void shim_rig_set_port_type(hamlib_shim_handle_t h, int type);
479
+ SHIM_API void shim_rot_set_port_path(hamlib_shim_handle_t h, const char* path);
480
+ SHIM_API void shim_rot_set_port_type(hamlib_shim_handle_t h, int type);
398
481
 
399
482
  /* Serial port configuration */
400
483
  SHIM_API void shim_rig_set_serial_rate(hamlib_shim_handle_t h, int rate);
@@ -592,6 +675,39 @@ SHIM_API int shim_rig_mW2power(hamlib_shim_handle_t h, float* power, unsigned in
592
675
  /* ===== Reset ===== */
593
676
 
594
677
  SHIM_API int shim_rig_reset(hamlib_shim_handle_t h, int reset_type);
678
+ SHIM_API int shim_rot_set_position(hamlib_shim_handle_t h, double azimuth, double elevation);
679
+ SHIM_API int shim_rot_get_position(hamlib_shim_handle_t h, double* azimuth, double* elevation);
680
+ SHIM_API int shim_rot_stop(hamlib_shim_handle_t h);
681
+ SHIM_API int shim_rot_park(hamlib_shim_handle_t h);
682
+ SHIM_API int shim_rot_reset(hamlib_shim_handle_t h, int reset_type);
683
+ SHIM_API int shim_rot_move(hamlib_shim_handle_t h, int direction, int speed);
684
+ SHIM_API const char* shim_rot_get_info(hamlib_shim_handle_t h);
685
+ SHIM_API int shim_rot_get_status(hamlib_shim_handle_t h, int* status);
686
+ SHIM_API int shim_rot_set_conf(hamlib_shim_handle_t h, const char* name, const char* val);
687
+ SHIM_API int shim_rot_get_conf(hamlib_shim_handle_t h, const char* name, char* buf, int buflen);
688
+ SHIM_API uint64_t shim_rot_get_caps_has_get_level(hamlib_shim_handle_t h);
689
+ SHIM_API uint64_t shim_rot_get_caps_has_set_level(hamlib_shim_handle_t h);
690
+ SHIM_API uint64_t shim_rot_get_caps_has_get_func(hamlib_shim_handle_t h);
691
+ SHIM_API uint64_t shim_rot_get_caps_has_set_func(hamlib_shim_handle_t h);
692
+ SHIM_API uint64_t shim_rot_get_caps_has_get_parm(hamlib_shim_handle_t h);
693
+ SHIM_API uint64_t shim_rot_get_caps_has_set_parm(hamlib_shim_handle_t h);
694
+ SHIM_API int shim_rot_set_level_f(hamlib_shim_handle_t h, uint64_t level, float value);
695
+ SHIM_API int shim_rot_set_level_i(hamlib_shim_handle_t h, uint64_t level, int value);
696
+ SHIM_API int shim_rot_get_level_f(hamlib_shim_handle_t h, uint64_t level, float* value);
697
+ SHIM_API int shim_rot_get_level_i(hamlib_shim_handle_t h, uint64_t level, int* value);
698
+ SHIM_API int shim_rot_get_level_auto(hamlib_shim_handle_t h, uint64_t level, double* value);
699
+ SHIM_API int shim_rot_set_func(hamlib_shim_handle_t h, uint64_t func, int enable);
700
+ SHIM_API int shim_rot_get_func(hamlib_shim_handle_t h, uint64_t func, int* state);
701
+ SHIM_API int shim_rot_set_parm_f(hamlib_shim_handle_t h, uint64_t parm, float value);
702
+ SHIM_API int shim_rot_set_parm_i(hamlib_shim_handle_t h, uint64_t parm, int value);
703
+ SHIM_API int shim_rot_get_parm_f(hamlib_shim_handle_t h, uint64_t parm, float* value);
704
+ SHIM_API int shim_rot_get_parm_i(hamlib_shim_handle_t h, uint64_t parm, int* value);
705
+ SHIM_API uint64_t shim_rot_parse_level(const char* level_str);
706
+ SHIM_API uint64_t shim_rot_parse_func(const char* func_str);
707
+ SHIM_API uint64_t shim_rot_parse_parm(const char* parm_str);
708
+ SHIM_API const char* shim_rot_strlevel(uint64_t level);
709
+ SHIM_API const char* shim_rot_strfunc(uint64_t func);
710
+ SHIM_API const char* shim_rot_strparm(uint64_t parm);
595
711
 
596
712
  /* ===== Callbacks ===== */
597
713