hamlib 0.2.3 → 0.2.5
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 +21 -9
- package/src/shim/hamlib_shim.c +42 -0
- package/src/shim/hamlib_shim.h +20 -9
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,15 @@ 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.
|
|
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.0) {}
|
|
312
312
|
|
|
313
313
|
void Execute() override {
|
|
314
314
|
CHECK_RIG_VALID();
|
|
315
315
|
|
|
316
|
-
// Use
|
|
317
|
-
//
|
|
318
|
-
result_code_ =
|
|
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_);
|
|
319
319
|
if (result_code_ != SHIM_RIG_OK) {
|
|
320
320
|
error_message_ = shim_rigerror(result_code_);
|
|
321
321
|
}
|
|
@@ -337,7 +337,8 @@ public:
|
|
|
337
337
|
|
|
338
338
|
private:
|
|
339
339
|
uint64_t level_type_;
|
|
340
|
-
|
|
340
|
+
int vfo_;
|
|
341
|
+
double value_;
|
|
341
342
|
};
|
|
342
343
|
|
|
343
344
|
class SetFunctionAsyncWorker : public HamLibAsyncWorker {
|
|
@@ -2974,9 +2975,20 @@ Napi::Value NodeHamLib::GetLevel(const Napi::CallbackInfo & info) {
|
|
|
2974
2975
|
return env.Null();
|
|
2975
2976
|
}
|
|
2976
2977
|
|
|
2977
|
-
|
|
2978
|
+
// Optional second parameter: VFO string ('VFO-A', 'VFO-B', 'currVFO')
|
|
2979
|
+
int vfo = SHIM_RIG_VFO_CURR;
|
|
2980
|
+
if (info.Length() >= 2 && info[1].IsString()) {
|
|
2981
|
+
std::string vfoStr = info[1].As<Napi::String>().Utf8Value();
|
|
2982
|
+
if (vfoStr == "VFO-A") {
|
|
2983
|
+
vfo = SHIM_RIG_VFO_A;
|
|
2984
|
+
} else if (vfoStr == "VFO-B") {
|
|
2985
|
+
vfo = SHIM_RIG_VFO_B;
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
|
|
2989
|
+
GetLevelAsyncWorker* worker = new GetLevelAsyncWorker(env, this, levelType, vfo);
|
|
2978
2990
|
worker->Queue();
|
|
2979
|
-
|
|
2991
|
+
|
|
2980
2992
|
return worker->GetPromise();
|
|
2981
2993
|
}
|
|
2982
2994
|
|
package/src/shim/hamlib_shim.c
CHANGED
|
@@ -345,7 +345,28 @@ 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
|
+
* 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".
|
|
356
|
+
*/
|
|
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) {
|
|
362
|
+
RIG* rig = (RIG*)h;
|
|
363
|
+
if (rig && rig->caps && !(rig->caps->targetable_vfo & RIG_TARGETABLE_LEVEL)) {
|
|
364
|
+
rig->caps->targetable_vfo |= RIG_TARGETABLE_LEVEL;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
348
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);
|
|
349
370
|
value_t val;
|
|
350
371
|
val.f = 0.0f;
|
|
351
372
|
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
@@ -354,6 +375,7 @@ SHIM_API int shim_rig_get_level_f(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
354
375
|
}
|
|
355
376
|
|
|
356
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);
|
|
357
379
|
value_t val;
|
|
358
380
|
val.i = 0;
|
|
359
381
|
int ret = rig_get_level((RIG*)h, (vfo_t)vfo, (setting_t)level, &val);
|
|
@@ -361,6 +383,26 @@ SHIM_API int shim_rig_get_level_i(hamlib_shim_handle_t h, int vfo, uint64_t leve
|
|
|
361
383
|
return ret;
|
|
362
384
|
}
|
|
363
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
|
+
|
|
364
406
|
/* ===== Function control ===== */
|
|
365
407
|
|
|
366
408
|
SHIM_API int shim_rig_set_func(hamlib_shim_handle_t h, int vfo, uint64_t func, int enable) {
|
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
|
|