hamlib 0.1.26 → 0.2.0

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/binding.gyp CHANGED
@@ -2,19 +2,20 @@
2
2
  "targets": [
3
3
  {
4
4
  "target_name": "hamlib",
5
- "sources": [
5
+ "sources": [
6
6
  "src/hamlib.cpp",
7
7
  "src/decoder.cpp",
8
8
  "src/addon.cpp"
9
9
  ],
10
10
  "include_dirs": [
11
11
  "include",
12
+ "src/shim",
12
13
  "<!@(node -p \"require('node-addon-api').include\")"
13
14
  ],
14
15
  "dependencies": [
15
16
  "<!(node -p \"require('node-addon-api').gyp\")"
16
17
  ],
17
- "defines": [
18
+ "defines": [
18
19
  "NAPI_DISABLE_CPP_EXCEPTIONS"
19
20
  ],
20
21
  "cflags!": [ "-fno-exceptions" ],
@@ -28,6 +29,7 @@
28
29
  "/usr/local/include"
29
30
  ],
30
31
  "libraries": [
32
+ "<(module_root_dir)/shim-build/libhamlib_shim.a",
31
33
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log('-L' + process.env.HAMLIB_PREFIX + '/lib')\")",
32
34
  "-L/usr/lib",
33
35
  "-L/usr/local/lib",
@@ -49,6 +51,7 @@
49
51
  "/opt/homebrew/opt/libusb/include"
50
52
  ],
51
53
  "libraries": [
54
+ "<(module_root_dir)/shim-build/libhamlib_shim.a",
52
55
  "<!@(node -e \"if(process.env.HAMLIB_PREFIX) console.log('-L' + process.env.HAMLIB_PREFIX + '/lib')\")",
53
56
  "-L/usr/local/lib",
54
57
  "-L/usr/local/opt/hamlib/lib",
@@ -75,89 +78,19 @@
75
78
  ],
76
79
  "conditions": [
77
80
  ["target_arch==\"x64\"", {
78
- "conditions": [
79
- # Check if we're in MinGW environment (HAMLIB_ROOT is set to /mingw64)
80
- ["\"<!(node -e \"console.log(process.env.HAMLIB_ROOT || '')\")\"==\"/mingw64\"", {
81
- "include_dirs": [
82
- "/mingw64/include"
83
- ],
84
- "library_dirs": [
85
- "/mingw64/lib"
86
- ],
87
- "libraries": [
88
- "-lhamlib",
89
- "-lws2_32",
90
- "-lwinmm"
91
- ],
92
- "cflags": [
93
- "-I/mingw64/include"
94
- ],
95
- "ldflags": [
96
- "-L/mingw64/lib",
97
- "-static-libgcc",
98
- "-static-libstdc++"
99
- ]
100
- }, {
101
- # Traditional Windows build with Visual C++
102
- "include_dirs": [
103
- # Try environment variable in different formats
104
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/include')\")",
105
- # Fallback paths
106
- "C:/hamlib/include",
107
- "C:/Program Files/Hamlib/include",
108
- "C:/Program Files (x86)/Hamlib/include"
109
- ],
110
- "library_dirs": [
111
- # Try environment variable paths
112
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/bin')\")",
113
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/lib')\")",
114
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/lib/gcc')\")",
115
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/lib/x64')\")",
116
- "<!(node -e \"console.log((process.env.HAMLIB_ROOT || 'C:/hamlib') + '/lib/msvc')\")",
117
- # Fallback paths
118
- "C:/hamlib/bin",
119
- "C:/hamlib/lib",
120
- "C:/hamlib/lib/gcc",
121
- "C:/hamlib/lib/x64",
122
- "C:/hamlib/lib/Release",
123
- "C:/Program Files/Hamlib/bin",
124
- "C:/Program Files/Hamlib/lib",
125
- "C:/Program Files/Hamlib/lib/gcc",
126
- "C:/Program Files (x86)/Hamlib/bin",
127
- "C:/Program Files (x86)/Hamlib/lib"
128
- ],
129
- "libraries": [
130
- # Link against the import library present in hamlib-w64 zip
131
- "libhamlib-4.lib",
132
- # Common Win32 system libs used by hamlib
133
- "Ws2_32.lib",
134
- "Winmm.lib"
135
- ],
136
- "conditions": [
137
- # Add pthread paths only if PTHREAD_ROOT is set
138
- ["\"<!(node -e \"console.log(process.env.PTHREAD_ROOT || '')\")\"!=\"\"", {
139
- "include_dirs": [
140
- # Headers are placed directly under PTHREAD_ROOT to match this include path
141
- "<!(node -e \"console.log((process.env.PTHREAD_ROOT || 'C:/pthread-win32'))\")"
142
- ],
143
- "library_dirs": [
144
- "<!(node -e \"console.log((process.env.PTHREAD_ROOT || 'C:/pthread-win32') + '/lib/x64')\")",
145
- "<!(node -e \"console.log((process.env.PTHREAD_ROOT || 'C:/pthread-win32') + '/lib')\")"
146
- ],
147
- "libraries": [
148
- # Only link the MSVC import library we download from Sourceware
149
- "pthreadVC2.lib"
150
- ]
151
- }]
152
- ],
153
- "msvs_settings": {
154
- "VCCLCompilerTool": {
155
- "ExceptionHandling": 1,
156
- "AdditionalOptions": ["/std:c++14"]
157
- }
158
- }
159
- }]
160
- ]
81
+ "library_dirs": [
82
+ "<(module_root_dir)/shim-build"
83
+ ],
84
+ "libraries": [
85
+ "hamlib_shim.lib",
86
+ "Ws2_32.lib"
87
+ ],
88
+ "msvs_settings": {
89
+ "VCCLCompilerTool": {
90
+ "ExceptionHandling": 1,
91
+ "AdditionalOptions": ["/std:c++14"]
92
+ }
93
+ }
161
94
  }]
162
95
  ]
163
96
  }]
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hamlib",
3
- "version": "0.1.26",
3
+ "version": "0.2.0",
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
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 "shim/hamlib_shim.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
+ shim_rig_set_debug(0); // 0 = RIG_DEBUG_NONE
6
10
 
7
11
  Napi::String name = Napi::String::New(env, "HamLib");
8
12
  exports.Set(name, NodeHamLib::GetClass(env));