hamlib 0.2.1 → 0.2.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamlib",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
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
@@ -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, SHIM_RIG_VFO_CURR, level_type_, value_);
283
+ result_code_ = shim_rig_set_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_NONE, level_type_, value_);
284
284
  if (result_code_ != SHIM_RIG_OK) {
285
285
  error_message_ = shim_rigerror(result_code_);
286
286
  }
@@ -313,7 +313,9 @@ public:
313
313
  void Execute() override {
314
314
  CHECK_RIG_VALID();
315
315
 
316
- result_code_ = shim_rig_get_level_f(hamlib_instance_->my_rig, SHIM_RIG_VFO_CURR, level_type_, &value_);
316
+ // Use RIG_VFO_NONE to avoid unnecessary VFO switching that fails on
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_);
317
319
  if (result_code_ != SHIM_RIG_OK) {
318
320
  error_message_ = shim_rigerror(result_code_);
319
321
  }
@@ -2191,19 +2193,17 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
2191
2193
  return;
2192
2194
  }
2193
2195
 
2194
- // Set default port path if not provided
2195
- strncpy(port_path, "/dev/ttyUSB0", SHIM_HAMLIB_FILPATHLEN - 1);
2196
- port_path[SHIM_HAMLIB_FILPATHLEN - 1] = '\0';
2197
-
2198
2196
  // Check if port path is provided as second argument
2199
- if (info.Length() >= 2) {
2200
- if (info[1].IsString()) {
2201
- std::string portStr = info[1].As<Napi::String>().Utf8Value();
2197
+ bool has_port = false;
2198
+ port_path[0] = '\0';
2199
+
2200
+ if (info.Length() >= 2 && info[1].IsString()) {
2201
+ std::string portStr = info[1].As<Napi::String>().Utf8Value();
2202
+ if (!portStr.empty()) {
2202
2203
  strncpy(port_path, portStr.c_str(), SHIM_HAMLIB_FILPATHLEN - 1);
2203
2204
  port_path[SHIM_HAMLIB_FILPATHLEN - 1] = '\0';
2205
+ has_port = true;
2204
2206
  }
2205
- // Note: Debug level is now controlled globally via HamLib.setDebugLevel()
2206
- // and set to RIG_DEBUG_NONE by default in addon initialization
2207
2207
  }
2208
2208
  //unsigned int myrig_model;
2209
2209
  // hamlib_port_t myport;
@@ -2242,13 +2242,16 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
2242
2242
  Napi::TypeError::New(env, errorMsg).ThrowAsJavaScriptException();
2243
2243
  }
2244
2244
 
2245
- // Set port path and type based on connection type
2246
- shim_rig_set_port_path(my_rig, port_path);
2245
+ // Only set port path and type when user explicitly provided a port.
2246
+ // Otherwise, let rig_init() defaults take effect (e.g., dummy rig uses RIG_PORT_NONE).
2247
+ if (has_port) {
2248
+ shim_rig_set_port_path(my_rig, port_path);
2247
2249
 
2248
- if (is_network_rig) {
2249
- shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_NETWORK);
2250
- } else {
2251
- shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_SERIAL);
2250
+ if (is_network_rig) {
2251
+ shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_NETWORK);
2252
+ } else {
2253
+ shim_rig_set_port_type(my_rig, SHIM_RIG_PORT_SERIAL);
2254
+ }
2252
2255
  }
2253
2256
 
2254
2257
  // this->freq_emit_cb = [info](double freq) {
@@ -71,9 +71,10 @@ typedef void* hamlib_shim_handle_t;
71
71
  /* Passband constants */
72
72
  #define SHIM_RIG_PASSBAND_NORMAL 0
73
73
 
74
- /* Port types */
75
- #define SHIM_RIG_PORT_SERIAL 0
76
- #define SHIM_RIG_PORT_NETWORK 4
74
+ /* Port types (must match hamlib rig_port_e enum) */
75
+ #define SHIM_RIG_PORT_NONE 0
76
+ #define SHIM_RIG_PORT_SERIAL 1
77
+ #define SHIM_RIG_PORT_NETWORK 2
77
78
 
78
79
  /* Scan types */
79
80
  #define SHIM_RIG_SCAN_STOP 0