hamlib 0.2.3 → 0.2.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.
- package/index.d.ts +2 -1
- 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 +18 -8
- package/src/shim/hamlib_shim.c +19 -2
package/index.d.ts
CHANGED
|
@@ -542,9 +542,10 @@ declare class HamLib {
|
|
|
542
542
|
/**
|
|
543
543
|
* Get radio level
|
|
544
544
|
* @param levelType Level type ('AF', 'RF', 'SQL', 'STRENGTH', etc.)
|
|
545
|
+
* @param vfo Optional VFO ('VFO-A', 'VFO-B', 'currVFO'). Defaults to currVFO.
|
|
545
546
|
* @returns Level value
|
|
546
547
|
*/
|
|
547
|
-
getLevel(levelType: LevelType): Promise<number>;
|
|
548
|
+
getLevel(levelType: LevelType, vfo?: string): Promise<number>;
|
|
548
549
|
|
|
549
550
|
/**
|
|
550
551
|
* Get list of supported level types
|
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
|
@@ -280,7 +280,7 @@ public:
|
|
|
280
280
|
void Execute() override {
|
|
281
281
|
CHECK_RIG_VALID();
|
|
282
282
|
|
|
283
|
-
result_code_ = shim_rig_set_level_f(hamlib_instance_->my_rig,
|
|
283
|
+
result_code_ = shim_rig_set_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, level_type_, value_);
|
|
284
284
|
if (result_code_ != SHIM_RIG_OK) {
|
|
285
285
|
error_message_ = shim_rigerror(result_code_);
|
|
286
286
|
}
|
|
@@ -307,15 +307,13 @@ private:
|
|
|
307
307
|
|
|
308
308
|
class GetLevelAsyncWorker : public HamLibAsyncWorker {
|
|
309
309
|
public:
|
|
310
|
-
GetLevelAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance, uint64_t level_type)
|
|
311
|
-
: HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), value_(0.0f) {}
|
|
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.0f) {}
|
|
312
312
|
|
|
313
313
|
void Execute() override {
|
|
314
314
|
CHECK_RIG_VALID();
|
|
315
315
|
|
|
316
|
-
|
|
317
|
-
// ICOM rigs (e.g. IC-705) where icom_set_vfo returns "unsupported VFO"
|
|
318
|
-
result_code_ = shim_rig_get_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_NONE, level_type_, &value_);
|
|
316
|
+
result_code_ = shim_rig_get_level_f(hamlib_instance_->my_rig, vfo_, level_type_, &value_);
|
|
319
317
|
if (result_code_ != SHIM_RIG_OK) {
|
|
320
318
|
error_message_ = shim_rigerror(result_code_);
|
|
321
319
|
}
|
|
@@ -337,6 +335,7 @@ public:
|
|
|
337
335
|
|
|
338
336
|
private:
|
|
339
337
|
uint64_t level_type_;
|
|
338
|
+
int vfo_;
|
|
340
339
|
float value_;
|
|
341
340
|
};
|
|
342
341
|
|
|
@@ -2974,9 +2973,20 @@ Napi::Value NodeHamLib::GetLevel(const Napi::CallbackInfo & info) {
|
|
|
2974
2973
|
return env.Null();
|
|
2975
2974
|
}
|
|
2976
2975
|
|
|
2977
|
-
|
|
2976
|
+
// Optional second parameter: VFO string ('VFO-A', 'VFO-B', 'currVFO')
|
|
2977
|
+
int vfo = SHIM_RIG_VFO_CURR;
|
|
2978
|
+
if (info.Length() >= 2 && info[1].IsString()) {
|
|
2979
|
+
std::string vfoStr = info[1].As<Napi::String>().Utf8Value();
|
|
2980
|
+
if (vfoStr == "VFO-A") {
|
|
2981
|
+
vfo = SHIM_RIG_VFO_A;
|
|
2982
|
+
} else if (vfoStr == "VFO-B") {
|
|
2983
|
+
vfo = SHIM_RIG_VFO_B;
|
|
2984
|
+
}
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
GetLevelAsyncWorker* worker = new GetLevelAsyncWorker(env, this, levelType, vfo);
|
|
2978
2988
|
worker->Queue();
|
|
2979
|
-
|
|
2989
|
+
|
|
2980
2990
|
return worker->GetPromise();
|
|
2981
2991
|
}
|
|
2982
2992
|
|
package/src/shim/hamlib_shim.c
CHANGED
|
@@ -345,10 +345,27 @@ SHIM_API int shim_rig_set_level_i(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
345
345
|
return rig_set_level((RIG*)h, (vfo_t)vfo, (setting_t)level, val);
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
+
/*
|
|
349
|
+
* get_level with automatic fallback:
|
|
350
|
+
* 1. Try standard rig_get_level() (with VFO handling, locking, caching)
|
|
351
|
+
* 2. If it fails with RIG_EINVAL (-1), fall back to direct backend call
|
|
352
|
+
* to bypass VFO switching issues (e.g. ICOM serial rigs where
|
|
353
|
+
* icom_set_vfo fails with "unsupported VFO")
|
|
354
|
+
*/
|
|
355
|
+
static int shim_get_level_with_fallback(hamlib_shim_handle_t h, int vfo, uint64_t level, value_t* val) {
|
|
356
|
+
RIG* rig = (RIG*)h;
|
|
357
|
+
int ret = rig_get_level(rig, (vfo_t)vfo, (setting_t)level, val);
|
|
358
|
+
if (ret == -1 && rig->caps->get_level) {
|
|
359
|
+
/* RIG_EINVAL: VFO switching failed, try direct backend call */
|
|
360
|
+
ret = rig->caps->get_level(rig, (vfo_t)vfo, (setting_t)level, val);
|
|
361
|
+
}
|
|
362
|
+
return ret;
|
|
363
|
+
}
|
|
364
|
+
|
|
348
365
|
SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t level, float* value) {
|
|
349
366
|
value_t val;
|
|
350
367
|
val.f = 0.0f;
|
|
351
|
-
int ret =
|
|
368
|
+
int ret = shim_get_level_with_fallback(h, vfo, level, &val);
|
|
352
369
|
if (value) *value = val.f;
|
|
353
370
|
return ret;
|
|
354
371
|
}
|
|
@@ -356,7 +373,7 @@ SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
356
373
|
SHIM_API int shim_rig_get_level_i(hamlib_shim_handle_t h, int vfo, uint64_t level, int* value) {
|
|
357
374
|
value_t val;
|
|
358
375
|
val.i = 0;
|
|
359
|
-
int ret =
|
|
376
|
+
int ret = shim_get_level_with_fallback(h, vfo, level, &val);
|
|
360
377
|
if (value) *value = val.i;
|
|
361
378
|
return ret;
|
|
362
379
|
}
|