hamlib 0.1.5 → 0.1.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/README.md +273 -0
- package/index.d.ts +540 -74
- package/lib/index.js +653 -68
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/hamlib.node +0 -0
- package/prebuilds/linux-arm64/hamlib.node +0 -0
- package/prebuilds/linux-x64/hamlib.node +0 -0
- package/src/hamlib.cpp +3915 -972
- package/src/hamlib.h +84 -1
- package/src/hamlib_compat.h +44 -0
- package/Readme.md +0 -560
package/src/hamlib.h
CHANGED
|
@@ -2,11 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
#include <napi.h>
|
|
4
4
|
#include <hamlib/rig.h>
|
|
5
|
+
#include <memory>
|
|
5
6
|
//forward declarations
|
|
6
7
|
//typedef struct s_rig RIG;
|
|
7
8
|
//typedef unsigned int vfo_t;
|
|
8
9
|
//typedef double freq_t;
|
|
9
10
|
|
|
11
|
+
// Forward declaration
|
|
12
|
+
class NodeHamLib;
|
|
13
|
+
|
|
14
|
+
// Base AsyncWorker class for hamlib operations with Promise support
|
|
15
|
+
class HamLibAsyncWorker : public Napi::AsyncWorker {
|
|
16
|
+
public:
|
|
17
|
+
HamLibAsyncWorker(Napi::Env env, NodeHamLib* hamlib_instance);
|
|
18
|
+
virtual ~HamLibAsyncWorker() = default;
|
|
19
|
+
|
|
20
|
+
// Get the promise that will be resolved/rejected
|
|
21
|
+
Napi::Promise GetPromise() { return deferred_.Promise(); }
|
|
22
|
+
|
|
23
|
+
protected:
|
|
24
|
+
NodeHamLib* hamlib_instance_;
|
|
25
|
+
int result_code_;
|
|
26
|
+
std::string error_message_;
|
|
27
|
+
Napi::Promise::Deferred deferred_;
|
|
28
|
+
};
|
|
29
|
+
|
|
10
30
|
|
|
11
31
|
class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
12
32
|
public:
|
|
@@ -75,6 +95,69 @@ class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
|
75
95
|
Napi::Value GetDcdType(const Napi::CallbackInfo&);
|
|
76
96
|
Napi::Value GetSupportedSerialConfigs(const Napi::CallbackInfo&);
|
|
77
97
|
|
|
98
|
+
// Power Control
|
|
99
|
+
Napi::Value SetPowerstat(const Napi::CallbackInfo&);
|
|
100
|
+
Napi::Value GetPowerstat(const Napi::CallbackInfo&);
|
|
101
|
+
|
|
102
|
+
// PTT Status Detection
|
|
103
|
+
Napi::Value GetPtt(const Napi::CallbackInfo&);
|
|
104
|
+
|
|
105
|
+
// Data Carrier Detect
|
|
106
|
+
Napi::Value GetDcd(const Napi::CallbackInfo&);
|
|
107
|
+
|
|
108
|
+
// Tuning Step Control
|
|
109
|
+
Napi::Value SetTuningStep(const Napi::CallbackInfo&);
|
|
110
|
+
Napi::Value GetTuningStep(const Napi::CallbackInfo&);
|
|
111
|
+
|
|
112
|
+
// Repeater Control
|
|
113
|
+
Napi::Value SetRepeaterShift(const Napi::CallbackInfo&);
|
|
114
|
+
Napi::Value GetRepeaterShift(const Napi::CallbackInfo&);
|
|
115
|
+
Napi::Value SetRepeaterOffset(const Napi::CallbackInfo&);
|
|
116
|
+
Napi::Value GetRepeaterOffset(const Napi::CallbackInfo&);
|
|
117
|
+
|
|
118
|
+
// CTCSS/DCS Tone Control
|
|
119
|
+
Napi::Value SetCtcssTone(const Napi::CallbackInfo&);
|
|
120
|
+
Napi::Value GetCtcssTone(const Napi::CallbackInfo&);
|
|
121
|
+
Napi::Value SetDcsCode(const Napi::CallbackInfo&);
|
|
122
|
+
Napi::Value GetDcsCode(const Napi::CallbackInfo&);
|
|
123
|
+
Napi::Value SetCtcssSql(const Napi::CallbackInfo&);
|
|
124
|
+
Napi::Value GetCtcssSql(const Napi::CallbackInfo&);
|
|
125
|
+
Napi::Value SetDcsSql(const Napi::CallbackInfo&);
|
|
126
|
+
Napi::Value GetDcsSql(const Napi::CallbackInfo&);
|
|
127
|
+
|
|
128
|
+
// Parameter Control
|
|
129
|
+
Napi::Value SetParm(const Napi::CallbackInfo&);
|
|
130
|
+
Napi::Value GetParm(const Napi::CallbackInfo&);
|
|
131
|
+
|
|
132
|
+
// DTMF Support
|
|
133
|
+
Napi::Value SendDtmf(const Napi::CallbackInfo&);
|
|
134
|
+
Napi::Value RecvDtmf(const Napi::CallbackInfo&);
|
|
135
|
+
|
|
136
|
+
// Memory Channel Advanced Operations
|
|
137
|
+
Napi::Value GetMem(const Napi::CallbackInfo&);
|
|
138
|
+
Napi::Value SetBank(const Napi::CallbackInfo&);
|
|
139
|
+
Napi::Value MemCount(const Napi::CallbackInfo&);
|
|
140
|
+
|
|
141
|
+
// Morse Code Support
|
|
142
|
+
Napi::Value SendMorse(const Napi::CallbackInfo&);
|
|
143
|
+
Napi::Value StopMorse(const Napi::CallbackInfo&);
|
|
144
|
+
Napi::Value WaitMorse(const Napi::CallbackInfo&);
|
|
145
|
+
|
|
146
|
+
// Voice Memory Support
|
|
147
|
+
Napi::Value SendVoiceMem(const Napi::CallbackInfo&);
|
|
148
|
+
Napi::Value StopVoiceMem(const Napi::CallbackInfo&);
|
|
149
|
+
|
|
150
|
+
// Complex Split Frequency/Mode Operations
|
|
151
|
+
Napi::Value SetSplitFreqMode(const Napi::CallbackInfo&);
|
|
152
|
+
Napi::Value GetSplitFreqMode(const Napi::CallbackInfo&);
|
|
153
|
+
|
|
154
|
+
// Power Conversion Functions
|
|
155
|
+
Napi::Value Power2mW(const Napi::CallbackInfo&);
|
|
156
|
+
Napi::Value MW2Power(const Napi::CallbackInfo&);
|
|
157
|
+
|
|
158
|
+
// Reset Function
|
|
159
|
+
Napi::Value Reset(const Napi::CallbackInfo&);
|
|
160
|
+
|
|
78
161
|
// Static method to get supported rig models
|
|
79
162
|
static Napi::Value GetSupportedRigs(const Napi::CallbackInfo&);
|
|
80
163
|
|
|
@@ -82,7 +165,7 @@ class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
|
82
165
|
|
|
83
166
|
static int freq_change_cb(RIG*, vfo_t, freq_t, void*);
|
|
84
167
|
|
|
85
|
-
|
|
168
|
+
public:
|
|
86
169
|
RIG *my_rig;
|
|
87
170
|
bool rig_is_open = false;
|
|
88
171
|
bool is_network_rig = false; // Flag to indicate if using network connection
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* hamlib_compat.h - Hamlib compatibility layer for different versions
|
|
5
|
+
*
|
|
6
|
+
* This header handles compatibility issues between different versions of hamlib
|
|
7
|
+
* Some functions are only available in newer versions and may not be present
|
|
8
|
+
* in older Linux distribution packages.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
#include <hamlib/rig.h>
|
|
12
|
+
|
|
13
|
+
// Check for hamlib version if available
|
|
14
|
+
#ifdef HAMLIB_VERSION
|
|
15
|
+
// Version-specific feature detection
|
|
16
|
+
#if HAMLIB_VERSION >= 0x040500 // Version 4.5.0 and later
|
|
17
|
+
#define HAVE_RIG_STOP_VOICE_MEM 1
|
|
18
|
+
#define HAVE_RIG_SPLIT_FREQ_MODE 1
|
|
19
|
+
#endif
|
|
20
|
+
#else
|
|
21
|
+
// If version is not available, assume older version
|
|
22
|
+
// We'll disable newer functions for maximum compatibility
|
|
23
|
+
#undef HAVE_RIG_STOP_VOICE_MEM
|
|
24
|
+
#undef HAVE_RIG_SPLIT_FREQ_MODE
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
// Manual feature detection based on typical availability
|
|
28
|
+
// These functions were added in recent hamlib versions
|
|
29
|
+
// Comment out these lines if your hamlib version doesn't have them
|
|
30
|
+
|
|
31
|
+
// Uncomment if you have a newer hamlib version with these functions:
|
|
32
|
+
// #define HAVE_RIG_STOP_VOICE_MEM 1
|
|
33
|
+
// #define HAVE_RIG_SPLIT_FREQ_MODE 1
|
|
34
|
+
|
|
35
|
+
// For maximum compatibility with older distributions, keep these disabled
|
|
36
|
+
// Users with newer hamlib can enable them manually
|
|
37
|
+
|
|
38
|
+
#ifndef HAVE_RIG_STOP_VOICE_MEM
|
|
39
|
+
#define HAVE_RIG_STOP_VOICE_MEM 0
|
|
40
|
+
#endif
|
|
41
|
+
|
|
42
|
+
#ifndef HAVE_RIG_SPLIT_FREQ_MODE
|
|
43
|
+
#define HAVE_RIG_SPLIT_FREQ_MODE 0
|
|
44
|
+
#endif
|
package/Readme.md
DELETED
|
@@ -1,560 +0,0 @@
|
|
|
1
|
-
# node-hamlib
|
|
2
|
-
|
|
3
|
-
A comprehensive Node.js wrapper for [Hamlib](https://hamlib.github.io/) - control amateur radio transceivers from JavaScript/TypeScript.
|
|
4
|
-
|
|
5
|
-
## 🚀 Features
|
|
6
|
-
|
|
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
|
-
|
|
14
|
-
## 📦 Quick Start
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install node-hamlib
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
const { HamLib } = require('node-hamlib');
|
|
22
|
-
|
|
23
|
-
// Find your radio model
|
|
24
|
-
const rigs = HamLib.getSupportedRigs();
|
|
25
|
-
console.log('Supported radios:', rigs.length);
|
|
26
|
-
|
|
27
|
-
// Connect to radio
|
|
28
|
-
const rig = new HamLib(1035, '/dev/ttyUSB0'); // FT-991A
|
|
29
|
-
rig.open();
|
|
30
|
-
|
|
31
|
-
// Basic control
|
|
32
|
-
rig.setFrequency(144390000); // 144.39 MHz
|
|
33
|
-
rig.setMode('FM');
|
|
34
|
-
rig.setPtt(true);
|
|
35
|
-
|
|
36
|
-
// Get status
|
|
37
|
-
console.log('Frequency:', rig.getFrequency());
|
|
38
|
-
console.log('Mode:', rig.getMode());
|
|
39
|
-
console.log('Signal:', rig.getStrength());
|
|
40
|
-
|
|
41
|
-
rig.close();
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## 📡 Complete API Reference
|
|
45
|
-
|
|
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);
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### 🔌 Connection Management
|
|
61
|
-
|
|
62
|
-
#### `new HamLib(model, port)`
|
|
63
|
-
Create radio instance
|
|
64
|
-
```javascript
|
|
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
|
|
69
|
-
|
|
70
|
-
// Network connection
|
|
71
|
-
const rig = new HamLib(1035, 'localhost:4532'); // rigctld
|
|
72
|
-
```
|
|
73
|
-
|
|
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
|
-
```
|
|
81
|
-
|
|
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
|
|
107
|
-
rig.setMode('FM');
|
|
108
|
-
rig.setMode('USB', 'wide');
|
|
109
|
-
|
|
110
|
-
// Get mode
|
|
111
|
-
const mode = rig.getMode();
|
|
112
|
-
console.log('Mode:', mode.mode);
|
|
113
|
-
console.log('Bandwidth:', mode.bandwidth);
|
|
114
|
-
```
|
|
115
|
-
|
|
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();
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
#### PTT Control
|
|
127
|
-
```javascript
|
|
128
|
-
rig.setPtt(true); // Transmit
|
|
129
|
-
rig.setPtt(false); // Receive
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
#### Signal Monitoring
|
|
133
|
-
```javascript
|
|
134
|
-
const strength = rig.getStrength();
|
|
135
|
-
console.log('Signal strength:', strength);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### 💾 Memory Channel Management
|
|
139
|
-
|
|
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
|
-
```
|
|
149
|
-
|
|
150
|
-
#### `getMemoryChannel(channel, readOnly)`
|
|
151
|
-
Retrieve memory channel
|
|
152
|
-
```javascript
|
|
153
|
-
const channel = rig.getMemoryChannel(1);
|
|
154
|
-
console.log('Channel 1:', channel);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
#### `selectMemoryChannel(channel)`
|
|
158
|
-
Select memory channel
|
|
159
|
-
```javascript
|
|
160
|
-
rig.selectMemoryChannel(1);
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### 🎛️ RIT/XIT Control
|
|
164
|
-
|
|
165
|
-
#### RIT (Receiver Incremental Tuning)
|
|
166
|
-
```javascript
|
|
167
|
-
rig.setRit(100); // +100 Hz offset
|
|
168
|
-
const rit = rig.getRit();
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
#### XIT (Transmitter Incremental Tuning)
|
|
172
|
-
```javascript
|
|
173
|
-
rig.setXit(-50); // -50 Hz offset
|
|
174
|
-
const xit = rig.getXit();
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
#### Clear RIT/XIT
|
|
178
|
-
```javascript
|
|
179
|
-
rig.clearRitXit(); // Clear both offsets
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### 🔍 Scanning Operations
|
|
183
|
-
|
|
184
|
-
#### `startScan(type, channel)`
|
|
185
|
-
Start scanning
|
|
186
|
-
```javascript
|
|
187
|
-
rig.startScan('VFO'); // VFO scan
|
|
188
|
-
rig.startScan('MEM'); // Memory scan
|
|
189
|
-
rig.startScan('PROG'); // Program scan
|
|
190
|
-
```
|
|
191
|
-
|
|
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
|
-
```
|
|
221
|
-
|
|
222
|
-
### 🔧 Function Controls
|
|
223
|
-
|
|
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', ...]
|
|
230
|
-
```
|
|
231
|
-
|
|
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
|
-
```
|
|
244
|
-
|
|
245
|
-
### 📡 Split Operations
|
|
246
|
-
|
|
247
|
-
#### Split Frequency
|
|
248
|
-
```javascript
|
|
249
|
-
rig.setSplitFreq(144340000); // TX frequency
|
|
250
|
-
const txFreq = rig.getSplitFreq();
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
#### Split Mode
|
|
254
|
-
```javascript
|
|
255
|
-
rig.setSplitMode('FM', 'wide'); // TX mode
|
|
256
|
-
const txMode = rig.getSplitMode();
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
#### Split Control
|
|
260
|
-
```javascript
|
|
261
|
-
rig.setSplit(true, 'VFO-B'); // Enable split
|
|
262
|
-
const splitStatus = rig.getSplit();
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
### 📻 VFO Operations
|
|
266
|
-
|
|
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
|
-
```
|
|
276
|
-
|
|
277
|
-
### 📶 Antenna Selection
|
|
278
|
-
|
|
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();
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
### ⚙️ Serial Port Configuration
|
|
288
|
-
|
|
289
|
-
#### `getSupportedSerialConfigs()`
|
|
290
|
-
Get available serial configuration options
|
|
291
|
-
```javascript
|
|
292
|
-
const configs = rig.getSupportedSerialConfigs();
|
|
293
|
-
console.log('Data bits:', configs.serial.data_bits); // ['5', '6', '7', '8']
|
|
294
|
-
console.log('Stop bits:', configs.serial.stop_bits); // ['1', '2']
|
|
295
|
-
console.log('Parity:', configs.serial.serial_parity); // ['None', 'Even', 'Odd']
|
|
296
|
-
console.log('Handshake:', configs.serial.serial_handshake); // ['None', 'Hardware', 'Software']
|
|
297
|
-
console.log('PTT types:', configs.ptt_type); // ['RIG', 'DTR', 'RTS', 'PARALLEL', ...]
|
|
298
|
-
console.log('DCD types:', configs.dcd_type); // ['RIG', 'DSR', 'CTS', 'CD', ...]
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
#### `setSerialConfig(param, value)` / `getSerialConfig(param)`
|
|
302
|
-
Configure serial port parameters
|
|
303
|
-
```javascript
|
|
304
|
-
// Basic serial configuration (most common)
|
|
305
|
-
rig.setSerialConfig('data_bits', '8'); // 8 data bits
|
|
306
|
-
rig.setSerialConfig('stop_bits', '1'); // 1 stop bit
|
|
307
|
-
rig.setSerialConfig('serial_parity', 'None'); // No parity
|
|
308
|
-
rig.setSerialConfig('serial_handshake', 'None'); // No flow control
|
|
309
|
-
|
|
310
|
-
// Hardware flow control (if supported)
|
|
311
|
-
rig.setSerialConfig('serial_handshake', 'Hardware');
|
|
312
|
-
|
|
313
|
-
// Control line states
|
|
314
|
-
rig.setSerialConfig('rts_state', 'ON'); // Set RTS high
|
|
315
|
-
rig.setSerialConfig('dtr_state', 'OFF'); // Set DTR low
|
|
316
|
-
|
|
317
|
-
// Get current configuration
|
|
318
|
-
const dataBits = rig.getSerialConfig('data_bits');
|
|
319
|
-
const parity = rig.getSerialConfig('serial_parity');
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
#### `setPttType(type)` / `getPttType()`
|
|
323
|
-
Configure PTT (Push-to-Talk) method
|
|
324
|
-
```javascript
|
|
325
|
-
// Use CAT command for PTT (recommended)
|
|
326
|
-
rig.setPttType('RIG');
|
|
327
|
-
|
|
328
|
-
// Use DTR line for PTT (legacy interfaces)
|
|
329
|
-
rig.setPttType('DTR');
|
|
330
|
-
|
|
331
|
-
// Use RTS line for PTT (alternative)
|
|
332
|
-
rig.setPttType('RTS');
|
|
333
|
-
|
|
334
|
-
// Disable PTT control
|
|
335
|
-
rig.setPttType('NONE');
|
|
336
|
-
|
|
337
|
-
// Get current PTT type
|
|
338
|
-
const pttType = rig.getPttType();
|
|
339
|
-
console.log('PTT method:', pttType);
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
#### `setDcdType(type)` / `getDcdType()`
|
|
343
|
-
Configure DCD (Data Carrier Detect) method
|
|
344
|
-
```javascript
|
|
345
|
-
// Use CAT command for DCD (software squelch)
|
|
346
|
-
rig.setDcdType('RIG');
|
|
347
|
-
|
|
348
|
-
// Use DSR line for DCD (hardware squelch)
|
|
349
|
-
rig.setDcdType('DSR');
|
|
350
|
-
|
|
351
|
-
// Use CTS line for DCD (alternative)
|
|
352
|
-
rig.setDcdType('CTS');
|
|
353
|
-
|
|
354
|
-
// Get current DCD type
|
|
355
|
-
const dcdType = rig.getDcdType();
|
|
356
|
-
console.log('DCD method:', dcdType);
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
#### Common Serial Configurations
|
|
360
|
-
|
|
361
|
-
**Yaesu Radios:**
|
|
362
|
-
```javascript
|
|
363
|
-
rig.setSerialConfig('data_bits', '8');
|
|
364
|
-
rig.setSerialConfig('stop_bits', '1');
|
|
365
|
-
rig.setSerialConfig('serial_parity', 'None');
|
|
366
|
-
rig.setSerialConfig('serial_handshake', 'None');
|
|
367
|
-
rig.setPttType('RIG'); // Use CAT command
|
|
368
|
-
// Baud rate: 4800/9600 (set in constructor)
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
**Kenwood Radios:**
|
|
372
|
-
```javascript
|
|
373
|
-
rig.setSerialConfig('data_bits', '8');
|
|
374
|
-
rig.setSerialConfig('stop_bits', '2'); // Note: 2 stop bits
|
|
375
|
-
rig.setSerialConfig('serial_parity', 'None');
|
|
376
|
-
rig.setSerialConfig('serial_handshake', 'None');
|
|
377
|
-
rig.setPttType('RIG');
|
|
378
|
-
// Baud rate: 9600
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
**Legacy Interface (DTR/RTS PTT):**
|
|
382
|
-
```javascript
|
|
383
|
-
rig.setSerialConfig('data_bits', '8');
|
|
384
|
-
rig.setSerialConfig('stop_bits', '1');
|
|
385
|
-
rig.setSerialConfig('serial_parity', 'None');
|
|
386
|
-
rig.setPttType('DTR'); // Use DTR for PTT
|
|
387
|
-
rig.setDcdType('DSR'); // Use DSR for squelch
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
## 🎯 Complete Example
|
|
391
|
-
|
|
392
|
-
```javascript
|
|
393
|
-
const { HamLib } = require('node-hamlib');
|
|
394
|
-
|
|
395
|
-
async function radioControl() {
|
|
396
|
-
// Find radios
|
|
397
|
-
const rigs = HamLib.getSupportedRigs();
|
|
398
|
-
const ft991a = rigs.find(r => r.modelName === 'FT-991A');
|
|
399
|
-
|
|
400
|
-
if (!ft991a) {
|
|
401
|
-
console.log('FT-991A not found');
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Connect
|
|
406
|
-
const rig = new HamLib(ft991a.rigModel, '/dev/ttyUSB0');
|
|
407
|
-
|
|
408
|
-
try {
|
|
409
|
-
rig.open();
|
|
410
|
-
console.log('Connected to', rig.getConnectionInfo().port);
|
|
411
|
-
|
|
412
|
-
// Set up radio
|
|
413
|
-
rig.setFrequency(144390000);
|
|
414
|
-
rig.setMode('FM');
|
|
415
|
-
rig.setLevel('RFPOWER', 0.5);
|
|
416
|
-
rig.setFunction('NB', true);
|
|
417
|
-
|
|
418
|
-
// Store memory channel
|
|
419
|
-
rig.setMemoryChannel(1, {
|
|
420
|
-
frequency: 144390000,
|
|
421
|
-
mode: 'FM',
|
|
422
|
-
description: 'Local Repeater'
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
// Monitor signal
|
|
426
|
-
setInterval(() => {
|
|
427
|
-
const freq = rig.getFrequency();
|
|
428
|
-
const mode = rig.getMode();
|
|
429
|
-
const strength = rig.getStrength();
|
|
430
|
-
|
|
431
|
-
console.log(`${freq/1000000} MHz ${mode.mode} S:${strength}`);
|
|
432
|
-
}, 1000);
|
|
433
|
-
|
|
434
|
-
} catch (error) {
|
|
435
|
-
console.error('Error:', error.message);
|
|
436
|
-
} finally {
|
|
437
|
-
rig.close();
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
radioControl();
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
## 📋 Supported Radios
|
|
445
|
-
|
|
446
|
-
This library supports **303+ radio models** from major manufacturers:
|
|
447
|
-
|
|
448
|
-
| Manufacturer | Models | Popular Radios |
|
|
449
|
-
|--------------|--------|----------------|
|
|
450
|
-
| **Yaesu** | 46 | FT-991A, FT-891, FT-857D, FT-817ND |
|
|
451
|
-
| **Icom** | 83 | IC-7300, IC-9700, IC-705, IC-7610 |
|
|
452
|
-
| **Kenwood** | 35 | TS-2000, TS-590SG, TS-890S, TH-D74 |
|
|
453
|
-
| **Elecraft** | 7 | K3, K4, KX3, KX2 |
|
|
454
|
-
| **FlexRadio** | 10 | 6300, 6400, 6500, 6600, 6700 |
|
|
455
|
-
| **Others** | 122 | AOR, JRC, Ten-Tec, Winradio, etc. |
|
|
456
|
-
|
|
457
|
-
### Finding Your Radio
|
|
458
|
-
```javascript
|
|
459
|
-
const rigs = HamLib.getSupportedRigs();
|
|
460
|
-
|
|
461
|
-
// Search by manufacturer
|
|
462
|
-
const yaesu = rigs.filter(r => r.mfgName === 'Yaesu');
|
|
463
|
-
|
|
464
|
-
// Search by model name
|
|
465
|
-
const ft991a = rigs.find(r => r.modelName.includes('FT-991A'));
|
|
466
|
-
|
|
467
|
-
// List all radios
|
|
468
|
-
rigs.forEach(rig => {
|
|
469
|
-
console.log(`${rig.rigModel}: ${rig.mfgName} ${rig.modelName}`);
|
|
470
|
-
});
|
|
471
|
-
```
|
|
472
|
-
|
|
473
|
-
## 🛠️ Installation & Setup
|
|
474
|
-
|
|
475
|
-
### System Requirements
|
|
476
|
-
- Node.js 12.0.0 or higher
|
|
477
|
-
- Supported platforms: Windows x64, Linux x64/ARM64, macOS ARM64
|
|
478
|
-
|
|
479
|
-
### Install Dependencies (if building from source)
|
|
480
|
-
```bash
|
|
481
|
-
# Ubuntu/Debian
|
|
482
|
-
sudo apt-get install libhamlib-dev
|
|
483
|
-
|
|
484
|
-
# macOS
|
|
485
|
-
brew install hamlib
|
|
486
|
-
|
|
487
|
-
# Windows
|
|
488
|
-
vcpkg install hamlib:x64-windows
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
### Building from Source
|
|
492
|
-
```bash
|
|
493
|
-
npm install
|
|
494
|
-
npm run build
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
### Testing
|
|
498
|
-
```bash
|
|
499
|
-
npm test
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
## 🔧 Connection Types
|
|
503
|
-
|
|
504
|
-
### Serial Connection
|
|
505
|
-
```javascript
|
|
506
|
-
// Linux
|
|
507
|
-
const rig = new HamLib(1035, '/dev/ttyUSB0');
|
|
508
|
-
|
|
509
|
-
// macOS
|
|
510
|
-
const rig = new HamLib(1035, '/dev/cu.usbserial-1420');
|
|
511
|
-
|
|
512
|
-
// Windows
|
|
513
|
-
const rig = new HamLib(1035, 'COM3');
|
|
514
|
-
```
|
|
515
|
-
|
|
516
|
-
### Network Connection (rigctld)
|
|
517
|
-
```javascript
|
|
518
|
-
const rig = new HamLib(1035, 'localhost:4532');
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
Start rigctld:
|
|
522
|
-
```bash
|
|
523
|
-
rigctld -m 1035 -r /dev/ttyUSB0 -t 4532
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
## 🐛 Troubleshooting
|
|
527
|
-
|
|
528
|
-
### Permission Issues (Linux)
|
|
529
|
-
```bash
|
|
530
|
-
sudo usermod -a -G dialout $USER
|
|
531
|
-
# Log out and back in
|
|
532
|
-
```
|
|
533
|
-
|
|
534
|
-
### Finding Serial Ports
|
|
535
|
-
```bash
|
|
536
|
-
# Linux
|
|
537
|
-
ls /dev/tty*
|
|
538
|
-
|
|
539
|
-
# macOS
|
|
540
|
-
ls /dev/cu.*
|
|
541
|
-
|
|
542
|
-
# Windows
|
|
543
|
-
# Use Device Manager
|
|
544
|
-
```
|
|
545
|
-
|
|
546
|
-
### Testing Connection
|
|
547
|
-
```bash
|
|
548
|
-
# Test with rigctl
|
|
549
|
-
rigctl -m 1035 -r /dev/ttyUSB0 f
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
## 📄 License
|
|
553
|
-
|
|
554
|
-
LGPL - see [COPYING](COPYING) file for details.
|
|
555
|
-
|
|
556
|
-
## 🔗 Links
|
|
557
|
-
|
|
558
|
-
- [Hamlib Project](https://hamlib.github.io/)
|
|
559
|
-
- [Supported Radios](https://github.com/Hamlib/Hamlib/wiki/Supported-Radios)
|
|
560
|
-
- [rigctl Documentation](https://hamlib.github.io/manpages/rigctl.html)
|