hamlib 0.2.5 → 0.2.7

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 CHANGED
@@ -178,7 +178,7 @@ interface SplitStatusInfo {
178
178
  type LevelType = 'AF' | 'RF' | 'SQL' | 'RFPOWER' | 'MICGAIN' | 'IF' | 'APF' | 'NR' |
179
179
  'PBT_IN' | 'PBT_OUT' | 'CWPITCH' | 'KEYSPD' | 'NOTCHF' | 'COMP' |
180
180
  'AGC' | 'BKINDL' | 'BALANCE' | 'VOXGAIN' | 'VOXDELAY' | 'ANTIVOX' |
181
- 'STRENGTH' | 'RAWSTR' | 'SWR' | 'ALC' | 'RFPOWER_METER' |
181
+ 'STRENGTH' | 'RAWSTR' | 'SWR' | 'ALC' | 'RFPOWER_METER' | 'RFPOWER_METER_WATTS' |
182
182
  'COMP_METER' | 'VD_METER' | 'ID_METER' | 'TEMP_METER' | string;
183
183
 
184
184
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamlib",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Node.js wrapper for hamlib radio control library",
5
5
  "main": "index.js",
6
6
  "module": "lib/index.mjs",
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/src/hamlib.cpp CHANGED
@@ -2962,6 +2962,8 @@ Napi::Value NodeHamLib::GetLevel(const Napi::CallbackInfo & info) {
2962
2962
  levelType = SHIM_RIG_LEVEL_RAWSTR;
2963
2963
  } else if (levelTypeStr == "RFPOWER_METER") {
2964
2964
  levelType = SHIM_RIG_LEVEL_RFPOWER_METER;
2965
+ } else if (levelTypeStr == "RFPOWER_METER_WATTS") {
2966
+ levelType = SHIM_RIG_LEVEL_RFPOWER_METER_WATTS;
2965
2967
  } else if (levelTypeStr == "COMP_METER") {
2966
2968
  levelType = SHIM_RIG_LEVEL_COMP_METER;
2967
2969
  } else if (levelTypeStr == "VD_METER") {
@@ -3026,6 +3028,7 @@ Napi::Value NodeHamLib::GetSupportedLevels(const Napi::CallbackInfo & info) {
3026
3028
  if (levels & SHIM_RIG_LEVEL_SWR) levelArray[index++] = Napi::String::New(env, "SWR");
3027
3029
  if (levels & SHIM_RIG_LEVEL_ALC) levelArray[index++] = Napi::String::New(env, "ALC");
3028
3030
  if (levels & SHIM_RIG_LEVEL_RFPOWER_METER) levelArray[index++] = Napi::String::New(env, "RFPOWER_METER");
3031
+ if (levels & SHIM_RIG_LEVEL_RFPOWER_METER_WATTS) levelArray[index++] = Napi::String::New(env, "RFPOWER_METER_WATTS");
3029
3032
  if (levels & SHIM_RIG_LEVEL_COMP_METER) levelArray[index++] = Napi::String::New(env, "COMP_METER");
3030
3033
  if (levels & SHIM_RIG_LEVEL_VD_METER) levelArray[index++] = Napi::String::New(env, "VD_METER");
3031
3034
  if (levels & SHIM_RIG_LEVEL_ID_METER) levelArray[index++] = Napi::String::New(env, "ID_METER");
@@ -405,11 +405,32 @@ SHIM_API int shim_rig_get_level_auto(hamlib_shim_handle_t h, int vfo, uint64_t l
405
405
 
406
406
  /* ===== Function control ===== */
407
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
+
408
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);
409
429
  return rig_set_func((RIG*)h, (vfo_t)vfo, (setting_t)func, enable);
410
430
  }
411
431
 
412
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);
413
434
  int s = 0;
414
435
  int ret = rig_get_func((RIG*)h, (vfo_t)vfo, (setting_t)func, &s);
415
436
  if (state) *state = s;
@@ -612,8 +633,20 @@ SHIM_API int shim_rig_scan(hamlib_shim_handle_t h, int vfo, int scan_type, int c
612
633
 
613
634
  /* ===== VFO operations ===== */
614
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
+ */
615
642
  SHIM_API int shim_rig_vfo_op(hamlib_shim_handle_t h, int vfo, int op) {
616
- return rig_vfo_op((RIG*)h, (vfo_t)vfo, (vfo_op_t)op);
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;
617
650
  }
618
651
 
619
652
  /* ===== Antenna control ===== */