hamlib 0.1.2 → 0.1.4

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/Readme.md CHANGED
@@ -1,253 +1,457 @@
1
1
  # node-hamlib
2
2
 
3
- A Node.js wrapper for [Hamlib](https://hamlib.github.io/) - control amateur radio transceivers from JavaScript/TypeScript.
3
+ A comprehensive Node.js wrapper for [Hamlib](https://hamlib.github.io/) - control amateur radio transceivers from JavaScript/TypeScript.
4
4
 
5
5
  ## 🚀 Features
6
6
 
7
- - **Pre-built binaries**: No compilation needed for most platforms
8
- - **Multi-platform support**: Windows x64, Linux x64/ARM64, macOS ARM64
9
- - **CommonJS & ES Modules**: Works with both `require()` and `import`
10
- - **TypeScript support**: Full type definitions included
11
- - **Serial & Network**: Direct serial connection or network via rigctld
12
- - **Comprehensive API**: All essential radio control functions
7
+ - **Built-in Methods**: Complete radio control API including memory channels, RIT/XIT, scanning, levels, functions, and more
8
+ - **303+ Supported Radios**: Works with Yaesu, Icom, Kenwood, Elecraft, FlexRadio, and many more
9
+ - **Multi-platform**: Pre-built binaries for Windows x64, Linux x64/ARM64, macOS ARM64
10
+ - **Connection Types**: Serial ports, network (rigctld), and direct control
11
+ - **TypeScript Support**: Full type definitions and IntelliSense
12
+ - **Modern JavaScript**: CommonJS and ES Modules support
13
13
 
14
- ## 📦 Installation
14
+ ## 📦 Quick Start
15
15
 
16
16
  ```bash
17
17
  npm install node-hamlib
18
18
  ```
19
19
 
20
- The package will automatically:
21
- 1. Try to use pre-built binaries for your platform
22
- 2. Fall back to compiling from source if needed
23
- 3. Provide helpful error messages for missing dependencies
20
+ ```javascript
21
+ const { HamLib } = require('node-hamlib');
24
22
 
25
- ## 🔧 System Requirements
23
+ // Find your radio model
24
+ const rigs = HamLib.getSupportedRigs();
25
+ console.log('Supported radios:', rigs.length);
26
26
 
27
- ### For Pre-built Binaries
28
- - Node.js 12.0.0 or higher
29
- - Supported platforms: Windows x64, Linux x64/ARM64, macOS ARM64
27
+ // Connect to radio
28
+ const rig = new HamLib(1035, '/dev/ttyUSB0'); // FT-991A
29
+ rig.open();
30
30
 
31
- ### For Source Compilation
32
- - All of the above, plus:
33
- - **Linux**: `libhamlib-dev` package
34
- - **macOS**: `hamlib` via Homebrew
35
- - **Windows**: hamlib via vcpkg or manual installation
36
- - **Build tools**: `node-gyp` and platform-specific compilers
31
+ // Basic control
32
+ rig.setFrequency(144390000); // 144.39 MHz
33
+ rig.setMode('FM');
34
+ rig.setPtt(true);
37
35
 
38
- ### Install System Dependencies
36
+ // Get status
37
+ console.log('Frequency:', rig.getFrequency());
38
+ console.log('Mode:', rig.getMode());
39
+ console.log('Signal:', rig.getStrength());
39
40
 
40
- ```bash
41
- # Ubuntu/Debian
42
- sudo apt-get install libhamlib-dev libhamlib-utils
41
+ rig.close();
42
+ ```
43
43
 
44
- # macOS
45
- brew install hamlib
44
+ ## 📡 Complete API Reference
46
45
 
47
- # Windows (using vcpkg)
48
- vcpkg install hamlib:x64-windows
46
+ ### 🔍 Radio Discovery
47
+
48
+ #### `HamLib.getSupportedRigs()`
49
+ Get all supported radio models
50
+ ```javascript
51
+ const rigs = HamLib.getSupportedRigs();
52
+ console.log(`Found ${rigs.length} supported radios`);
53
+
54
+ // Find your radio
55
+ const yaesu = rigs.filter(r => r.mfgName === 'Yaesu');
56
+ const ft991a = rigs.find(r => r.modelName === 'FT-991A');
57
+ console.log('FT-991A Model ID:', ft991a.rigModel);
49
58
  ```
50
59
 
51
- ## 📋 Usage
60
+ ### 🔌 Connection Management
52
61
 
53
- ### CommonJS (Node.js)
62
+ #### `new HamLib(model, port)`
63
+ Create radio instance
54
64
  ```javascript
55
- const { HamLib } = require('node-hamlib');
65
+ // Serial connection
66
+ const rig = new HamLib(1035, '/dev/ttyUSB0'); // Linux
67
+ const rig = new HamLib(1035, '/dev/cu.usbserial-1420'); // macOS
68
+ const rig = new HamLib(1035, 'COM3'); // Windows
56
69
 
57
- // Create instance with radio model and port
58
- const rig = new HamLib(1035, '/dev/ttyUSB0');
70
+ // Network connection
71
+ const rig = new HamLib(1035, 'localhost:4532'); // rigctld
72
+ ```
59
73
 
60
- // Open connection
61
- rig.open();
74
+ #### `open()` / `close()` / `destroy()`
75
+ Connection control
76
+ ```javascript
77
+ rig.open(); // Open connection
78
+ rig.close(); // Close (can reopen)
79
+ rig.destroy(); // Destroy permanently
80
+ ```
62
81
 
63
- // Control your radio
64
- rig.setFrequency(144390000); // 144.39 MHz
82
+ #### `getConnectionInfo()`
83
+ Get connection details
84
+ ```javascript
85
+ const info = rig.getConnectionInfo();
86
+ console.log('Connection type:', info.connectionType);
87
+ console.log('Port:', info.port);
88
+ console.log('Status:', info.status);
89
+ ```
90
+
91
+ ### 📻 Basic Radio Control
92
+
93
+ #### Frequency Control
94
+ ```javascript
95
+ // Set frequency (Hz)
96
+ rig.setFrequency(144390000);
97
+ rig.setFrequency(144390000, 'VFO-A');
98
+
99
+ // Get frequency
100
+ const freq = rig.getFrequency();
101
+ const freqA = rig.getFrequency('VFO-A');
102
+ ```
103
+
104
+ #### Mode Control
105
+ ```javascript
106
+ // Set mode
65
107
  rig.setMode('FM');
66
- rig.setPtt(true);
108
+ rig.setMode('USB', 'wide');
67
109
 
68
- // Get radio status
69
- console.log('Current frequency:', rig.getFrequency());
70
- console.log('Current mode:', rig.getMode());
71
- console.log('Signal strength:', rig.getStrength());
110
+ // Get mode
111
+ const mode = rig.getMode();
112
+ console.log('Mode:', mode.mode);
113
+ console.log('Bandwidth:', mode.bandwidth);
114
+ ```
72
115
 
73
- // Close connection
74
- rig.close();
116
+ #### VFO Control
117
+ ```javascript
118
+ // Set VFO
119
+ rig.setVfo('VFO-A');
120
+ rig.setVfo('VFO-B');
121
+
122
+ // Get current VFO
123
+ const vfo = rig.getVfo();
75
124
  ```
76
125
 
77
- ### ES Modules (ESM)
126
+ #### PTT Control
78
127
  ```javascript
79
- import { HamLib } from 'node-hamlib';
128
+ rig.setPtt(true); // Transmit
129
+ rig.setPtt(false); // Receive
130
+ ```
80
131
 
81
- const rig = new HamLib(1035, '/dev/ttyUSB0');
82
- // ... same API as above
132
+ #### Signal Monitoring
133
+ ```javascript
134
+ const strength = rig.getStrength();
135
+ console.log('Signal strength:', strength);
83
136
  ```
84
137
 
85
- ### TypeScript
86
- ```typescript
87
- import { HamLib, ConnectionInfo, ModeInfo } from 'node-hamlib';
138
+ ### 💾 Memory Channel Management
88
139
 
89
- const rig = new HamLib(1035, '/dev/ttyUSB0');
90
- rig.open();
140
+ #### `setMemoryChannel(channel, data)`
141
+ Store memory channel
142
+ ```javascript
143
+ rig.setMemoryChannel(1, {
144
+ frequency: 144390000,
145
+ mode: 'FM',
146
+ description: 'Local Repeater'
147
+ });
148
+ ```
91
149
 
92
- const info: ConnectionInfo = rig.getConnectionInfo();
93
- const mode: ModeInfo = rig.getMode();
150
+ #### `getMemoryChannel(channel, readOnly)`
151
+ Retrieve memory channel
152
+ ```javascript
153
+ const channel = rig.getMemoryChannel(1);
154
+ console.log('Channel 1:', channel);
94
155
  ```
95
156
 
96
- ## 🔌 Connection Types
157
+ #### `selectMemoryChannel(channel)`
158
+ Select memory channel
159
+ ```javascript
160
+ rig.selectMemoryChannel(1);
161
+ ```
97
162
 
98
- ### Serial Connection
163
+ ### 🎛️ RIT/XIT Control
164
+
165
+ #### RIT (Receiver Incremental Tuning)
99
166
  ```javascript
100
- // Linux/Raspberry Pi
101
- const rig = new HamLib(1035, '/dev/ttyUSB0');
167
+ rig.setRit(100); // +100 Hz offset
168
+ const rit = rig.getRit();
169
+ ```
102
170
 
103
- // macOS
104
- const rig = new HamLib(1035, '/dev/cu.usbserial-1420');
171
+ #### XIT (Transmitter Incremental Tuning)
172
+ ```javascript
173
+ rig.setXit(-50); // -50 Hz offset
174
+ const xit = rig.getXit();
175
+ ```
105
176
 
106
- // Windows
107
- const rig = new HamLib(1035, 'COM3');
177
+ #### Clear RIT/XIT
178
+ ```javascript
179
+ rig.clearRitXit(); // Clear both offsets
108
180
  ```
109
181
 
110
- ### Network Connection (rigctld)
182
+ ### 🔍 Scanning Operations
183
+
184
+ #### `startScan(type, channel)`
185
+ Start scanning
111
186
  ```javascript
112
- // Connect to rigctld daemon
113
- const rig = new HamLib(1035, 'localhost:4532');
114
- const rig = new HamLib(1035, '192.168.1.100:4532');
187
+ rig.startScan('VFO'); // VFO scan
188
+ rig.startScan('MEM'); // Memory scan
189
+ rig.startScan('PROG'); // Program scan
115
190
  ```
116
191
 
117
- Start rigctld daemon:
118
- ```bash
119
- # Basic usage
120
- rigctld -m 1035 -r /dev/ttyUSB0
192
+ #### `stopScan()`
193
+ Stop scanning
194
+ ```javascript
195
+ rig.stopScan();
196
+ ```
197
+
198
+ ### 🎚️ Level Controls
199
+
200
+ #### `getSupportedLevels()`
201
+ Get available level controls
202
+ ```javascript
203
+ const levels = rig.getSupportedLevels();
204
+ console.log('Available levels:', levels);
205
+ // ['AF', 'RF', 'SQL', 'RFPOWER', 'MICGAIN', ...]
206
+ ```
207
+
208
+ #### `setLevel(type, value)` / `getLevel(type)`
209
+ Control audio and RF levels
210
+ ```javascript
211
+ rig.setLevel('AF', 0.7); // Audio gain 70%
212
+ rig.setLevel('RF', 0.5); // RF gain 50%
213
+ rig.setLevel('SQL', 0.3); // Squelch 30%
214
+ rig.setLevel('RFPOWER', 0.5); // TX power 50%
215
+ rig.setLevel('MICGAIN', 0.8); // Mic gain 80%
216
+
217
+ // Get levels
218
+ const audioGain = rig.getLevel('AF');
219
+ const rfGain = rig.getLevel('RF');
220
+ ```
121
221
 
122
- # With custom port
123
- rigctld -m 1035 -r /dev/ttyUSB0 -t 5001
222
+ ### 🔧 Function Controls
124
223
 
125
- # With remote access
126
- rigctld -m 1035 -r /dev/ttyUSB0 -T 0.0.0.0
224
+ #### `getSupportedFunctions()`
225
+ Get available function controls
226
+ ```javascript
227
+ const functions = rig.getSupportedFunctions();
228
+ console.log('Available functions:', functions);
229
+ // ['NB', 'COMP', 'VOX', 'TONE', 'TSQL', 'TUNER', ...]
127
230
  ```
128
231
 
129
- ## 🎛️ API Reference
232
+ #### `setFunction(type, enable)` / `getFunction(type)`
233
+ Control radio functions
234
+ ```javascript
235
+ rig.setFunction('NB', true); // Enable noise blanker
236
+ rig.setFunction('COMP', true); // Enable compressor
237
+ rig.setFunction('VOX', true); // Enable VOX
238
+ rig.setFunction('TUNER', true); // Enable auto tuner
239
+
240
+ // Get function status
241
+ const nbEnabled = rig.getFunction('NB');
242
+ const compEnabled = rig.getFunction('COMP');
243
+ ```
130
244
 
131
- ### Constructor
132
- - `new HamLib(model, port?)`: Create a new instance
133
- - `model`: Radio model number (find yours with `rigctl -l`)
134
- - `port`: Optional serial port or network address
245
+ ### 📡 Split Operations
135
246
 
136
- ### Connection Methods
137
- - `open()`: Open connection to radio
138
- - `close()`: Close connection (can reopen)
139
- - `destroy()`: Destroy connection permanently
247
+ #### Split Frequency
248
+ ```javascript
249
+ rig.setSplitFreq(144340000); // TX frequency
250
+ const txFreq = rig.getSplitFreq();
251
+ ```
140
252
 
141
- ### Control Methods
142
- - `setVfo(vfo)`: Set VFO ('VFO-A' or 'VFO-B')
143
- - `setFrequency(freq, vfo?)`: Set frequency in Hz
144
- - `setMode(mode, bandwidth?)`: Set mode ('USB', 'LSB', 'FM', etc.)
145
- - `setPtt(state)`: Set PTT on/off
253
+ #### Split Mode
254
+ ```javascript
255
+ rig.setSplitMode('FM', 'wide'); // TX mode
256
+ const txMode = rig.getSplitMode();
257
+ ```
146
258
 
147
- ### Query Methods
148
- - `getVfo()`: Get current VFO
149
- - `getFrequency(vfo?)`: Get frequency in Hz
150
- - `getMode()`: Get current mode and bandwidth
151
- - `getStrength()`: Get signal strength
152
- - `getConnectionInfo()`: Get connection details
259
+ #### Split Control
260
+ ```javascript
261
+ rig.setSplit(true, 'VFO-B'); // Enable split
262
+ const splitStatus = rig.getSplit();
263
+ ```
153
264
 
154
- ## 🏗️ Development
265
+ ### 📻 VFO Operations
155
266
 
156
- ### Building from Source
157
- ```bash
158
- # Install dependencies
159
- npm install
267
+ #### `vfoOperation(operation)`
268
+ VFO operations
269
+ ```javascript
270
+ rig.vfoOperation('CPY'); // Copy VFO A to B
271
+ rig.vfoOperation('XCHG'); // Exchange VFO A and B
272
+ rig.vfoOperation('UP'); // Frequency up
273
+ rig.vfoOperation('DOWN'); // Frequency down
274
+ rig.vfoOperation('TOGGLE'); // Toggle VFO A/B
275
+ ```
160
276
 
161
- # Build native module
162
- npm run build
277
+ ### 📶 Antenna Selection
163
278
 
164
- # Run tests
165
- npm test
279
+ #### `setAntenna(antenna)` / `getAntenna()`
280
+ Antenna control
281
+ ```javascript
282
+ rig.setAntenna(1); // Select antenna 1
283
+ rig.setAntenna(2); // Select antenna 2
284
+ const antenna = rig.getAntenna();
166
285
  ```
167
286
 
168
- ### Testing the Module
169
- ```bash
170
- # Test module loading
171
- node test/test_loader.js
287
+ ## 🎯 Complete Example
172
288
 
173
- # Test basic functionality
174
- node test/mod.js
289
+ ```javascript
290
+ const { HamLib } = require('node-hamlib');
175
291
 
176
- # Test network connection
177
- node test/test_network.js
292
+ async function radioControl() {
293
+ // Find radios
294
+ const rigs = HamLib.getSupportedRigs();
295
+ const ft991a = rigs.find(r => r.modelName === 'FT-991A');
296
+
297
+ if (!ft991a) {
298
+ console.log('FT-991A not found');
299
+ return;
300
+ }
301
+
302
+ // Connect
303
+ const rig = new HamLib(ft991a.rigModel, '/dev/ttyUSB0');
304
+
305
+ try {
306
+ rig.open();
307
+ console.log('Connected to', rig.getConnectionInfo().port);
308
+
309
+ // Set up radio
310
+ rig.setFrequency(144390000);
311
+ rig.setMode('FM');
312
+ rig.setLevel('RFPOWER', 0.5);
313
+ rig.setFunction('NB', true);
314
+
315
+ // Store memory channel
316
+ rig.setMemoryChannel(1, {
317
+ frequency: 144390000,
318
+ mode: 'FM',
319
+ description: 'Local Repeater'
320
+ });
321
+
322
+ // Monitor signal
323
+ setInterval(() => {
324
+ const freq = rig.getFrequency();
325
+ const mode = rig.getMode();
326
+ const strength = rig.getStrength();
327
+
328
+ console.log(`${freq/1000000} MHz ${mode.mode} S:${strength}`);
329
+ }, 1000);
330
+
331
+ } catch (error) {
332
+ console.error('Error:', error.message);
333
+ } finally {
334
+ rig.close();
335
+ }
336
+ }
337
+
338
+ radioControl();
178
339
  ```
179
340
 
180
- ## 📂 Project Structure
341
+ ## 📋 Supported Radios
342
+
343
+ This library supports **303+ radio models** from major manufacturers:
344
+
345
+ | Manufacturer | Models | Popular Radios |
346
+ |--------------|--------|----------------|
347
+ | **Yaesu** | 46 | FT-991A, FT-891, FT-857D, FT-817ND |
348
+ | **Icom** | 83 | IC-7300, IC-9700, IC-705, IC-7610 |
349
+ | **Kenwood** | 35 | TS-2000, TS-590SG, TS-890S, TH-D74 |
350
+ | **Elecraft** | 7 | K3, K4, KX3, KX2 |
351
+ | **FlexRadio** | 10 | 6300, 6400, 6500, 6600, 6700 |
352
+ | **Others** | 122 | AOR, JRC, Ten-Tec, Winradio, etc. |
353
+
354
+ ### Finding Your Radio
355
+ ```javascript
356
+ const rigs = HamLib.getSupportedRigs();
181
357
 
358
+ // Search by manufacturer
359
+ const yaesu = rigs.filter(r => r.mfgName === 'Yaesu');
360
+
361
+ // Search by model name
362
+ const ft991a = rigs.find(r => r.modelName.includes('FT-991A'));
363
+
364
+ // List all radios
365
+ rigs.forEach(rig => {
366
+ console.log(`${rig.rigModel}: ${rig.mfgName} ${rig.modelName}`);
367
+ });
182
368
  ```
183
- node-hamlib/
184
- ├── lib/ # JavaScript wrapper code
185
- │ ├── index.js # Main CommonJS entry
186
- │ ├── index.mjs # ES Module entry
187
- │ └── binary-loader.js # Binary loading logic
188
- ├── src/ # C++ source code
189
- ├── prebuilds/ # Pre-built binaries
190
- ├── scripts/ # Build and install scripts
191
- ├── test/ # Test files
192
- ├── index.js # Package entry point
193
- ├── index.d.ts # TypeScript definitions
194
- └── binding.gyp # Build configuration
369
+
370
+ ## 🛠️ Installation & Setup
371
+
372
+ ### System Requirements
373
+ - Node.js 12.0.0 or higher
374
+ - Supported platforms: Windows x64, Linux x64/ARM64, macOS ARM64
375
+
376
+ ### Install Dependencies (if building from source)
377
+ ```bash
378
+ # Ubuntu/Debian
379
+ sudo apt-get install libhamlib-dev
380
+
381
+ # macOS
382
+ brew install hamlib
383
+
384
+ # Windows
385
+ vcpkg install hamlib:x64-windows
195
386
  ```
196
387
 
197
- ## 🤝 Contributing
388
+ ### Building from Source
389
+ ```bash
390
+ npm install
391
+ npm run build
392
+ ```
393
+
394
+ ### Testing
395
+ ```bash
396
+ npm test
397
+ ```
198
398
 
199
- 1. Fork the repository
200
- 2. Create a feature branch
201
- 3. Make your changes
202
- 4. Test thoroughly
203
- 5. Submit a pull request
399
+ ## 🔧 Connection Types
204
400
 
205
- ## 📋 Supported Platforms
401
+ ### Serial Connection
402
+ ```javascript
403
+ // Linux
404
+ const rig = new HamLib(1035, '/dev/ttyUSB0');
206
405
 
207
- | Platform | Architecture | Status |
208
- |----------|-------------|---------|
209
- | Linux | x64 | ✅ Pre-built (native) |
210
- | Linux | ARM64 | ✅ Pre-built (native) |
211
- | macOS | ARM64 | ✅ Pre-built (native) |
212
- | Windows | x64 | ✅ Pre-built (native) |
406
+ // macOS
407
+ const rig = new HamLib(1035, '/dev/cu.usbserial-1420');
213
408
 
214
- ## 🐛 Troubleshooting
409
+ // Windows
410
+ const rig = new HamLib(1035, 'COM3');
411
+ ```
215
412
 
216
- ### Binary Loading Issues
217
- If you see "Failed to load hamlib native module":
413
+ ### Network Connection (rigctld)
414
+ ```javascript
415
+ const rig = new HamLib(1035, 'localhost:4532');
416
+ ```
218
417
 
219
- 1. **Check platform support**: Ensure your platform is supported
220
- 2. **Install system dependencies**: Follow the installation guide above
221
- 3. **Try building from source**: `npm run build`
222
- 4. **Check permissions**: Ensure you have access to the serial port
418
+ Start rigctld:
419
+ ```bash
420
+ rigctld -m 1035 -r /dev/ttyUSB0 -t 4532
421
+ ```
422
+
423
+ ## 🐛 Troubleshooting
223
424
 
224
- ### Serial Port Issues
425
+ ### Permission Issues (Linux)
225
426
  ```bash
226
- # Linux: Add user to dialout group
227
427
  sudo usermod -a -G dialout $USER
428
+ # Log out and back in
429
+ ```
228
430
 
229
- # Check available ports
431
+ ### Finding Serial Ports
432
+ ```bash
433
+ # Linux
230
434
  ls /dev/tty*
231
435
 
232
- # Test with rigctl
233
- rigctl -m 1035 -r /dev/ttyUSB0 f
436
+ # macOS
437
+ ls /dev/cu.*
438
+
439
+ # Windows
440
+ # Use Device Manager
234
441
  ```
235
442
 
236
- ### Network Connection Issues
443
+ ### Testing Connection
237
444
  ```bash
238
- # Test rigctld connection
239
- telnet localhost 4532
240
-
241
- # In telnet session:
242
- f # get frequency
243
- q # quit
445
+ # Test with rigctl
446
+ rigctl -m 1035 -r /dev/ttyUSB0 f
244
447
  ```
245
448
 
246
449
  ## 📄 License
247
450
 
248
- This project is licensed under the LGPL license - see the [COPYING](COPYING) file for details.
451
+ LGPL - see [COPYING](COPYING) file for details.
249
452
 
250
- ## 🔗 Related Projects
453
+ ## 🔗 Links
251
454
 
252
- - [Hamlib](https://hamlib.github.io/) - The underlying radio control library
253
- - [rigctl](https://github.com/Hamlib/Hamlib) - Command-line radio control utility
455
+ - [Hamlib Project](https://hamlib.github.io/)
456
+ - [Supported Radios](https://github.com/Hamlib/Hamlib/wiki/Supported-Radios)
457
+ - [rigctl Documentation](https://hamlib.github.io/manpages/rigctl.html)