hamlib 0.2.4 → 0.2.6
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/package.json +1 -1
- package/prebuilds/darwin-arm64/libhamlib.4.dylib +0 -0
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/libhamlib.4.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.4 +0 -0
- package/prebuilds/linux-arm64/libhamlib.so.4.0.7 +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/libhamlib.so +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4.0.7 +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/hamlib.cpp +5 -3
- package/src/shim/hamlib_shim.c +72 -14
- package/src/shim/hamlib_shim.h +20 -9
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/hamlib.cpp
CHANGED
|
@@ -308,12 +308,14 @@ private:
|
|
|
308
308
|
class GetLevelAsyncWorker : public HamLibAsyncWorker {
|
|
309
309
|
public:
|
|
310
310
|
GetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t level_type, int vfo = SHIM_RIG_VFO_CURR)
|
|
311
|
-
: HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), vfo_(vfo), value_(0.
|
|
311
|
+
: HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), vfo_(vfo), value_(0.0) {}
|
|
312
312
|
|
|
313
313
|
void Execute() override {
|
|
314
314
|
CHECK_RIG_VALID();
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
// Use auto-detect to handle int levels (STRENGTH, RAWSTR) and
|
|
317
|
+
// float levels (SWR, ALC, RFPOWER_METER, etc.) correctly
|
|
318
|
+
result_code_ = shim_rig_get_level_auto(hamlib_instance_->my_rig, vfo_, level_type_, &value_);
|
|
317
319
|
if (result_code_ != SHIM_RIG_OK) {
|
|
318
320
|
error_message_ = shim_rigerror(result_code_);
|
|
319
321
|
}
|
|
@@ -336,7 +338,7 @@ public:
|
|
|
336
338
|
private:
|
|
337
339
|
uint64_t level_type_;
|
|
338
340
|
int vfo_;
|
|
339
|
-
|
|
341
|
+
double value_;
|
|
340
342
|
};
|
|
341
343
|
|
|
342
344
|
class SetFunctionAsyncWorker : public HamLibAsyncWorker {
|
package/src/shim/hamlib_shim.c
CHANGED
|
@@ -346,45 +346,91 @@ SHIM_API int shim_rig_set_level_i(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
/*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
349
|
+
* Ensure RIG_TARGETABLE_LEVEL is set so rig_get_level() skips VFO
|
|
350
|
+
* switching but still performs calibration and type conversion.
|
|
351
|
+
* This fixes ICOM serial rigs where icom_set_vfo fails with
|
|
352
|
+
* "unsupported VFO" during get_level calls.
|
|
353
|
+
*
|
|
354
|
+
* RIG_TARGETABLE_LEVEL = (1<<5) tells Hamlib: "this rig can read
|
|
355
|
+
* levels without needing to switch VFO first".
|
|
354
356
|
*/
|
|
355
|
-
|
|
357
|
+
#ifndef RIG_TARGETABLE_LEVEL
|
|
358
|
+
#define RIG_TARGETABLE_LEVEL (1<<5)
|
|
359
|
+
#endif
|
|
360
|
+
|
|
361
|
+
static void shim_ensure_targetable_level(hamlib_shim_handle_t h) {
|
|
356
362
|
RIG* rig = (RIG*)h;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
/* RIG_EINVAL: VFO switching failed, try direct backend call */
|
|
360
|
-
ret = rig->caps->get_level(rig, (vfo_t)vfo, (setting_t)level, val);
|
|
363
|
+
if (rig && rig->caps && !(rig->caps->targetable_vfo & RIG_TARGETABLE_LEVEL)) {
|
|
364
|
+
rig->caps->targetable_vfo |= RIG_TARGETABLE_LEVEL;
|
|
361
365
|
}
|
|
362
|
-
return ret;
|
|
363
366
|
}
|
|
364
367
|
|
|
365
368
|
SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t level, float* value) {
|
|
369
|
+
shim_ensure_targetable_level(h);
|
|
366
370
|
value_t val;
|
|
367
371
|
val.f = 0.0f;
|
|
368
|
-
int ret =
|
|
372
|
+
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
369
373
|
if (value) *value = val.f;
|
|
370
374
|
return ret;
|
|
371
375
|
}
|
|
372
376
|
|
|
373
377
|
SHIM_API int shim_rig_get_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int* value) {
|
|
378
|
+
shim_ensure_targetable_level(h);
|
|
374
379
|
value_t val;
|
|
375
380
|
val.i = 0;
|
|
376
|
-
int ret =
|
|
381
|
+
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
377
382
|
if (value) *value = val.i;
|
|
378
383
|
return ret;
|
|
379
384
|
}
|
|
380
385
|
|
|
386
|
+
/*
|
|
387
|
+
* Auto-detect int/float level type using RIG_LEVEL_IS_FLOAT macro.
|
|
388
|
+
* Returns the value as double regardless of the underlying type.
|
|
389
|
+
* This avoids the common bug where STRENGTH (int) is read as float.
|
|
390
|
+
*/
|
|
391
|
+
SHIM_API int shim_rig_get_level_auto(hamlib_shim_handle_t h, int vfo, uint64_t level, double* value) {
|
|
392
|
+
shim_ensure_targetable_level(h);
|
|
393
|
+
value_t val;
|
|
394
|
+
memset(&val, 0, sizeof(val));
|
|
395
|
+
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
396
|
+
if (value) {
|
|
397
|
+
if (RIG_LEVEL_IS_FLOAT((setting_t)level)) {
|
|
398
|
+
*value = (double)val.f;
|
|
399
|
+
} else {
|
|
400
|
+
*value = (double)val.i;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
405
|
+
|
|
381
406
|
/* ===== Function control ===== */
|
|
382
407
|
|
|
408
|
+
/*
|
|
409
|
+
* Ensure RIG_TARGETABLE_FUNC is set so rig_get_func()/rig_set_func()
|
|
410
|
+
* skip VFO switching. Same fix as RIG_TARGETABLE_LEVEL for ICOM serial
|
|
411
|
+
* rigs where icom_set_vfo fails with "unsupported VFO".
|
|
412
|
+
*
|
|
413
|
+
* RIG_TARGETABLE_FUNC = (1<<4) tells Hamlib: "this rig can get/set
|
|
414
|
+
* functions without needing to switch VFO first".
|
|
415
|
+
*/
|
|
416
|
+
#ifndef RIG_TARGETABLE_FUNC
|
|
417
|
+
#define RIG_TARGETABLE_FUNC (1<<4)
|
|
418
|
+
#endif
|
|
419
|
+
|
|
420
|
+
static void shim_ensure_targetable_func(hamlib_shim_handle_t h) {
|
|
421
|
+
RIG* rig = (RIG*)h;
|
|
422
|
+
if (rig && rig->caps && !(rig->caps->targetable_vfo & RIG_TARGETABLE_FUNC)) {
|
|
423
|
+
rig->caps->targetable_vfo |= RIG_TARGETABLE_FUNC;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
383
427
|
SHIM_API int shim_rig_set_func(hamlib_shim_handle_t h, int vfo, uint64_t func, int enable) {
|
|
428
|
+
shim_ensure_targetable_func(h);
|
|
384
429
|
return rig_set_func((RIG*)h, (vfo_t)vfo, (setting_t)func, enable);
|
|
385
430
|
}
|
|
386
431
|
|
|
387
432
|
SHIM_API int shim_rig_get_func(hamlib_shim_handle_t h, int vfo, uint64_t func, int* state) {
|
|
433
|
+
shim_ensure_targetable_func(h);
|
|
388
434
|
int s = 0;
|
|
389
435
|
int ret = rig_get_func((RIG*)h, (vfo_t)vfo, (setting_t)func, &s);
|
|
390
436
|
if (state) *state = s;
|
|
@@ -587,8 +633,20 @@ SHIM_API int shim_rig_scan(hamlib_shim_handle_t h, int vfo, int scan_type, int c
|
|
|
587
633
|
|
|
588
634
|
/* ===== VFO operations ===== */
|
|
589
635
|
|
|
636
|
+
/*
|
|
637
|
+
* vfo_op with fallback for rigs with VFO switching issues.
|
|
638
|
+
* There is no RIG_TARGETABLE for vfo_op, so we use the same
|
|
639
|
+
* fallback pattern as the old getLevel fix: try standard call
|
|
640
|
+
* first, then direct backend call if RIG_EINVAL (-1).
|
|
641
|
+
*/
|
|
590
642
|
SHIM_API int shim_rig_vfo_op(hamlib_shim_handle_t h, int vfo, int op) {
|
|
591
|
-
|
|
643
|
+
RIG* rig = (RIG*)h;
|
|
644
|
+
int ret = rig_vfo_op(rig, (vfo_t)vfo, (vfo_op_t)op);
|
|
645
|
+
if (ret == -1 && rig->caps->vfo_op) {
|
|
646
|
+
/* RIG_EINVAL: VFO switching failed, try direct backend call */
|
|
647
|
+
ret = rig->caps->vfo_op(rig, (vfo_t)vfo, (vfo_op_t)op);
|
|
648
|
+
}
|
|
649
|
+
return ret;
|
|
592
650
|
}
|
|
593
651
|
|
|
594
652
|
/* ===== Antenna control ===== */
|
package/src/shim/hamlib_shim.h
CHANGED
|
@@ -182,15 +182,24 @@ typedef void* hamlib_shim_handle_t;
|
|
|
182
182
|
#define SHIM_RIG_LEVEL_METER (1ULL << 20)
|
|
183
183
|
#define SHIM_RIG_LEVEL_VOXGAIN (1ULL << 21)
|
|
184
184
|
#define SHIM_RIG_LEVEL_ANTIVOX (1ULL << 22)
|
|
185
|
-
#define
|
|
186
|
-
#define
|
|
187
|
-
#define
|
|
188
|
-
#define
|
|
189
|
-
|
|
190
|
-
#define
|
|
191
|
-
#define
|
|
192
|
-
#define
|
|
193
|
-
|
|
185
|
+
#define SHIM_RIG_LEVEL_SLOPE_LOW (1ULL << 23)
|
|
186
|
+
#define SHIM_RIG_LEVEL_SLOPE_HIGH (1ULL << 24)
|
|
187
|
+
#define SHIM_RIG_LEVEL_BKIN_DLYMS (1ULL << 25)
|
|
188
|
+
#define SHIM_RIG_LEVEL_RAWSTR (1ULL << 26)
|
|
189
|
+
/* bit 27 reserved (was SQLSTAT, deprecated) */
|
|
190
|
+
#define SHIM_RIG_LEVEL_SWR (1ULL << 28)
|
|
191
|
+
#define SHIM_RIG_LEVEL_ALC (1ULL << 29)
|
|
192
|
+
#define SHIM_RIG_LEVEL_STRENGTH (1ULL << 30)
|
|
193
|
+
/* bit 31 reserved */
|
|
194
|
+
#define SHIM_RIG_LEVEL_RFPOWER_METER (1ULL << 32)
|
|
195
|
+
#define SHIM_RIG_LEVEL_COMP_METER (1ULL << 33)
|
|
196
|
+
#define SHIM_RIG_LEVEL_VD_METER (1ULL << 34)
|
|
197
|
+
#define SHIM_RIG_LEVEL_ID_METER (1ULL << 35)
|
|
198
|
+
#define SHIM_RIG_LEVEL_NOTCHF_RAW (1ULL << 36)
|
|
199
|
+
#define SHIM_RIG_LEVEL_MONITOR_GAIN (1ULL << 37)
|
|
200
|
+
#define SHIM_RIG_LEVEL_NB (1ULL << 38)
|
|
201
|
+
#define SHIM_RIG_LEVEL_RFPOWER_METER_WATTS (1ULL << 39)
|
|
202
|
+
#define SHIM_RIG_LEVEL_TEMP_METER (1ULL << 48)
|
|
194
203
|
|
|
195
204
|
/* ===== Function constants (bit positions for setting_t / uint64_t) ===== */
|
|
196
205
|
#define SHIM_RIG_FUNC_FAGC (1ULL << 0)
|
|
@@ -383,6 +392,8 @@ SHIM_API int shim_rig_set_level_f(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
383
392
|
SHIM_API int shim_rig_set_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int value);
|
|
384
393
|
SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t level, float* value);
|
|
385
394
|
SHIM_API int shim_rig_get_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int* value);
|
|
395
|
+
/* Auto-detect int/float level type, returns value as double */
|
|
396
|
+
SHIM_API int shim_rig_get_level_auto(hamlib_shim_handle_t h, int vfo, uint64_t level, double* value);
|
|
386
397
|
|
|
387
398
|
/* ===== Function control ===== */
|
|
388
399
|
|