hamlib 0.1.26 → 0.1.27
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 +41 -0
- package/lib/index.js +39 -0
- package/package.json +1 -1
- package/prebuilds/BUILD_INFO.txt +2 -2
- 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.4 +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/addon.cpp +4 -0
- package/src/hamlib.cpp +52 -10
- package/src/hamlib.h +4 -0
package/index.d.ts
CHANGED
|
@@ -66,6 +66,12 @@ type VFO = 'VFO-A' | 'VFO-B';
|
|
|
66
66
|
*/
|
|
67
67
|
type RadioMode = 'USB' | 'LSB' | 'FM' | 'PKTFM' | 'AM' | 'CW' | 'RTTY' | 'DIG' | string;
|
|
68
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Hamlib debug level type
|
|
71
|
+
* Controls the verbosity of Hamlib library debug output
|
|
72
|
+
*/
|
|
73
|
+
type RigDebugLevel = 0 | 1 | 2 | 3 | 4 | 5;
|
|
74
|
+
|
|
69
75
|
/**
|
|
70
76
|
* Memory channel data interface
|
|
71
77
|
*/
|
|
@@ -276,6 +282,41 @@ declare class HamLib {
|
|
|
276
282
|
*/
|
|
277
283
|
static getHamlibVersion(): string;
|
|
278
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Set Hamlib debug level (affects all instances globally)
|
|
287
|
+
* Controls the verbosity of Hamlib library debug output.
|
|
288
|
+
* By default, debug level is set to 0 (NONE) to prevent unwanted output.
|
|
289
|
+
*
|
|
290
|
+
* @param level Debug level:
|
|
291
|
+
* - 0 = NONE (no debug output) - default
|
|
292
|
+
* - 1 = BUG (serious bug messages only)
|
|
293
|
+
* - 2 = ERR (error messages)
|
|
294
|
+
* - 3 = WARN (warning messages)
|
|
295
|
+
* - 4 = VERBOSE (verbose messages)
|
|
296
|
+
* - 5 = TRACE (trace messages - very detailed)
|
|
297
|
+
* @static
|
|
298
|
+
* @example
|
|
299
|
+
* // Disable all debug output (default)
|
|
300
|
+
* HamLib.setDebugLevel(0);
|
|
301
|
+
*
|
|
302
|
+
* // Enable verbose debugging for troubleshooting
|
|
303
|
+
* HamLib.setDebugLevel(4);
|
|
304
|
+
*
|
|
305
|
+
* // Enable full trace debugging for development
|
|
306
|
+
* HamLib.setDebugLevel(5);
|
|
307
|
+
*/
|
|
308
|
+
static setDebugLevel(level: RigDebugLevel): void;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get current Hamlib debug level
|
|
312
|
+
* Note: This method is not supported by Hamlib API and will throw an error.
|
|
313
|
+
* Applications should track the debug level they set using setDebugLevel().
|
|
314
|
+
*
|
|
315
|
+
* @static
|
|
316
|
+
* @throws Always throws error as Hamlib doesn't provide API to query debug level
|
|
317
|
+
*/
|
|
318
|
+
static getDebugLevel(): never;
|
|
319
|
+
|
|
279
320
|
/**
|
|
280
321
|
* Open connection to device
|
|
281
322
|
* Must be called before other operations
|
package/lib/index.js
CHANGED
|
@@ -39,6 +39,41 @@ class HamLib {
|
|
|
39
39
|
return nativeModule.HamLib.getHamlibVersion();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Set Hamlib debug level (affects all instances globally)
|
|
44
|
+
* @param {number} level - Debug level:
|
|
45
|
+
* - 0 = NONE (no debug output)
|
|
46
|
+
* - 1 = BUG (serious bug messages)
|
|
47
|
+
* - 2 = ERR (error messages)
|
|
48
|
+
* - 3 = WARN (warning messages)
|
|
49
|
+
* - 4 = VERBOSE (verbose messages)
|
|
50
|
+
* - 5 = TRACE (trace messages - very detailed)
|
|
51
|
+
* @static
|
|
52
|
+
* @example
|
|
53
|
+
* // Disable all debug output (default)
|
|
54
|
+
* HamLib.setDebugLevel(0);
|
|
55
|
+
*
|
|
56
|
+
* // Enable verbose debugging
|
|
57
|
+
* HamLib.setDebugLevel(4);
|
|
58
|
+
*
|
|
59
|
+
* // Enable full trace debugging
|
|
60
|
+
* HamLib.setDebugLevel(5);
|
|
61
|
+
*/
|
|
62
|
+
static setDebugLevel(level) {
|
|
63
|
+
return nativeModule.HamLib.setDebugLevel(level);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get current Hamlib debug level
|
|
68
|
+
* Note: This method is not supported by Hamlib API and will throw an error.
|
|
69
|
+
* Applications should track the debug level they set using setDebugLevel().
|
|
70
|
+
* @static
|
|
71
|
+
* @throws {Error} Always throws error as Hamlib doesn't provide API to query debug level
|
|
72
|
+
*/
|
|
73
|
+
static getDebugLevel() {
|
|
74
|
+
return nativeModule.HamLib.getDebugLevel();
|
|
75
|
+
}
|
|
76
|
+
|
|
42
77
|
/**
|
|
43
78
|
* Open connection to the radio device
|
|
44
79
|
* Must be called before other operations
|
|
@@ -1093,6 +1128,10 @@ class HamLib {
|
|
|
1093
1128
|
}
|
|
1094
1129
|
}
|
|
1095
1130
|
|
|
1131
|
+
// Set debug level to NONE by default to prevent unwanted output
|
|
1132
|
+
// Users can change this using HamLib.setDebugLevel() if needed
|
|
1133
|
+
HamLib.setDebugLevel(0);
|
|
1134
|
+
|
|
1096
1135
|
// Export for CommonJS
|
|
1097
1136
|
module.exports = { HamLib };
|
|
1098
1137
|
module.exports.HamLib = HamLib;
|
package/package.json
CHANGED
package/prebuilds/BUILD_INFO.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Node-HamLib Precompiled Binaries
|
|
2
2
|
================================
|
|
3
|
-
Build Time: Sat Nov
|
|
4
|
-
Git Commit:
|
|
3
|
+
Build Time: Sat Nov 15 13:47:42 UTC 2025
|
|
4
|
+
Git Commit: 422425ac9142d27cc806b014a29066aee25cfcfb
|
|
5
5
|
Git Ref: refs/heads/main
|
|
6
6
|
|
|
7
7
|
Supported Platforms:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/addon.cpp
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
#include <napi.h>
|
|
2
2
|
#include "hamlib.h"
|
|
3
3
|
#include "decoder.h"
|
|
4
|
+
#include <hamlib/rig.h>
|
|
4
5
|
|
|
5
6
|
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
7
|
+
// Set Hamlib debug level to NONE by default to prevent unwanted output
|
|
8
|
+
// Users can change this using HamLib.setDebugLevel() if needed
|
|
9
|
+
rig_set_debug(RIG_DEBUG_NONE);
|
|
6
10
|
|
|
7
11
|
Napi::String name = Napi::String::New(env, "HamLib");
|
|
8
12
|
exports.Set(name, NodeHamLib::GetClass(env));
|
package/src/hamlib.cpp
CHANGED
|
@@ -2214,12 +2214,9 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
|
|
|
2214
2214
|
std::string portStr = info[1].As<Napi::String>().Utf8Value();
|
|
2215
2215
|
strncpy(port_path, portStr.c_str(), HAMLIB_FILPATHLEN - 1);
|
|
2216
2216
|
port_path[HAMLIB_FILPATHLEN - 1] = '\0';
|
|
2217
|
-
} else {
|
|
2218
|
-
// If second argument exists but is not a string, treat it as debug level (backward compatibility)
|
|
2219
|
-
rig_set_debug_level(RIG_DEBUG_NONE);
|
|
2220
2217
|
}
|
|
2221
|
-
|
|
2222
|
-
|
|
2218
|
+
// Note: Debug level is now controlled globally via HamLib.setDebugLevel()
|
|
2219
|
+
// and set to RIG_DEBUG_NONE by default in addon initialization
|
|
2223
2220
|
}
|
|
2224
2221
|
//rig_model_t myrig_model;
|
|
2225
2222
|
// hamlib_port_t myport;
|
|
@@ -2241,19 +2238,21 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
|
|
|
2241
2238
|
|
|
2242
2239
|
// Check if port_path is a network address (contains colon)
|
|
2243
2240
|
is_network_rig = isNetworkAddress(port_path);
|
|
2244
|
-
|
|
2241
|
+
|
|
2245
2242
|
if (is_network_rig) {
|
|
2246
2243
|
// Use NETRIGCTL model for network connections
|
|
2247
2244
|
myrig_model = 2; // RIG_MODEL_NETRIGCTL
|
|
2248
|
-
|
|
2245
|
+
// Network connection will be established on open()
|
|
2249
2246
|
}
|
|
2250
2247
|
|
|
2251
2248
|
my_rig = rig_init(myrig_model);
|
|
2252
2249
|
//int retcode = 0;
|
|
2253
2250
|
if (!my_rig) {
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2251
|
+
// Create detailed error message
|
|
2252
|
+
std::string errorMsg = "Unable to initialize rig (model: " +
|
|
2253
|
+
std::to_string(myrig_model) +
|
|
2254
|
+
"). Please check if the model number is valid.";
|
|
2255
|
+
Napi::TypeError::New(env, errorMsg).ThrowAsJavaScriptException();
|
|
2257
2256
|
}
|
|
2258
2257
|
|
|
2259
2258
|
// Set port path and type based on connection type
|
|
@@ -3724,6 +3723,8 @@ Napi::Function NodeHamLib::GetClass(Napi::Env env) {
|
|
|
3724
3723
|
// Static methods
|
|
3725
3724
|
NodeHamLib::StaticMethod("getSupportedRigs", & NodeHamLib::GetSupportedRigs),
|
|
3726
3725
|
NodeHamLib::StaticMethod("getHamlibVersion", & NodeHamLib::GetHamlibVersion),
|
|
3726
|
+
NodeHamLib::StaticMethod("setDebugLevel", & NodeHamLib::SetDebugLevel),
|
|
3727
|
+
NodeHamLib::StaticMethod("getDebugLevel", & NodeHamLib::GetDebugLevel),
|
|
3727
3728
|
});
|
|
3728
3729
|
constructor = Napi::Persistent(ret);
|
|
3729
3730
|
constructor.SuppressDestruct();
|
|
@@ -3843,6 +3844,47 @@ Napi::Value NodeHamLib::GetHamlibVersion(const Napi::CallbackInfo& info) {
|
|
|
3843
3844
|
return Napi::String::New(env, hamlib_version2);
|
|
3844
3845
|
}
|
|
3845
3846
|
|
|
3847
|
+
// Set Hamlib debug level
|
|
3848
|
+
// Debug levels: 0=NONE, 1=BUG, 2=ERR, 3=WARN, 4=VERBOSE, 5=TRACE
|
|
3849
|
+
Napi::Value NodeHamLib::SetDebugLevel(const Napi::CallbackInfo& info) {
|
|
3850
|
+
Napi::Env env = info.Env();
|
|
3851
|
+
|
|
3852
|
+
if (info.Length() < 1 || !info[0].IsNumber()) {
|
|
3853
|
+
Napi::TypeError::New(env, "Debug level (number) required").ThrowAsJavaScriptException();
|
|
3854
|
+
return env.Undefined();
|
|
3855
|
+
}
|
|
3856
|
+
|
|
3857
|
+
int level = info[0].As<Napi::Number>().Int32Value();
|
|
3858
|
+
|
|
3859
|
+
// Validate debug level (0-5)
|
|
3860
|
+
if (level < 0 || level > 5) {
|
|
3861
|
+
Napi::RangeError::New(env, "Debug level must be between 0 (NONE) and 5 (TRACE)").ThrowAsJavaScriptException();
|
|
3862
|
+
return env.Undefined();
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
rig_set_debug((enum rig_debug_level_e)level);
|
|
3866
|
+
|
|
3867
|
+
return env.Undefined();
|
|
3868
|
+
}
|
|
3869
|
+
|
|
3870
|
+
// Get current Hamlib debug level
|
|
3871
|
+
Napi::Value NodeHamLib::GetDebugLevel(const Napi::CallbackInfo& info) {
|
|
3872
|
+
Napi::Env env = info.Env();
|
|
3873
|
+
|
|
3874
|
+
// hamlib_get_debug() is not available in all versions, so we use a workaround
|
|
3875
|
+
// by calling rig_debug_level which is a global variable in hamlib
|
|
3876
|
+
// However, this is internal implementation, so we use rig_debug with RIG_DEBUG_NONE
|
|
3877
|
+
// to get the current level. For now, we'll just return a note that this is not
|
|
3878
|
+
// directly accessible. In practice, applications should track the level they set.
|
|
3879
|
+
|
|
3880
|
+
// Since there's no public API to query debug level in Hamlib,
|
|
3881
|
+
// we'll document that users should track it themselves
|
|
3882
|
+
Napi::Error::New(env,
|
|
3883
|
+
"Getting debug level is not supported by Hamlib API. "
|
|
3884
|
+
"Please track the debug level you set using setDebugLevel().").ThrowAsJavaScriptException();
|
|
3885
|
+
return env.Undefined();
|
|
3886
|
+
}
|
|
3887
|
+
|
|
3846
3888
|
// Serial Port Configuration Methods
|
|
3847
3889
|
|
|
3848
3890
|
// Set serial configuration parameter (data_bits, stop_bits, parity, handshake, etc.)
|
package/src/hamlib.h
CHANGED
|
@@ -168,6 +168,10 @@ class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
|
168
168
|
// Static method to get Hamlib version
|
|
169
169
|
static Napi::Value GetHamlibVersion(const Napi::CallbackInfo&);
|
|
170
170
|
|
|
171
|
+
// Static methods to control debug level
|
|
172
|
+
static Napi::Value SetDebugLevel(const Napi::CallbackInfo&);
|
|
173
|
+
static Napi::Value GetDebugLevel(const Napi::CallbackInfo&);
|
|
174
|
+
|
|
171
175
|
static Napi::Function GetClass(Napi::Env);
|
|
172
176
|
|
|
173
177
|
static int freq_change_cb(RIG*, vfo_t, freq_t, void*);
|