hamlib 0.3.3 → 0.4.1
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 +29 -24
- package/index.d.ts +84 -137
- package/lib/index.js +101 -407
- package/lib/spectrum.d.ts +63 -0
- package/lib/spectrum.js +364 -0
- package/lib/spectrum.mjs +7 -0
- package/package.json +17 -1
- 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 +0 -0
- package/prebuilds/linux-arm64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-arm64/libhamlib.so.4.0.7 +0 -0
- package/prebuilds/linux-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/libhamlib.so +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4 +0 -0
- package/prebuilds/linux-x64/libhamlib.so.4.0.7 +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/prebuilds/win32-x64/hamlib_shim.dll +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/spectrum.d.ts +2 -0
- package/spectrum.js +1 -0
- package/spectrum.mjs +2 -0
- package/src/hamlib.cpp +173 -133
- package/src/shim/hamlib_shim.c +8 -0
- package/src/shim/hamlib_shim.h +3 -1
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ await rig.setMode('USB');
|
|
|
89
89
|
const mode = await rig.getMode();
|
|
90
90
|
|
|
91
91
|
// VFO
|
|
92
|
-
await rig.setVfo('
|
|
92
|
+
await rig.setVfo('VFOA');
|
|
93
93
|
const vfo = await rig.getVfo();
|
|
94
94
|
|
|
95
95
|
// PTT
|
|
@@ -111,7 +111,7 @@ await rig.setMemoryChannel(1, {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
// Recall channel
|
|
114
|
-
const channel = await rig.getMemoryChannel(1);
|
|
114
|
+
const channel = await rig.getMemoryChannel(1, true);
|
|
115
115
|
await rig.selectMemoryChannel(1);
|
|
116
116
|
```
|
|
117
117
|
|
|
@@ -124,7 +124,7 @@ await rig.setXit(-50); // -50 Hz XIT
|
|
|
124
124
|
await rig.clearRitXit(); // Clear both
|
|
125
125
|
|
|
126
126
|
// Scanning
|
|
127
|
-
await rig.startScan('VFO');
|
|
127
|
+
await rig.startScan('VFO', 0); // Start VFO scan
|
|
128
128
|
await rig.stopScan(); // Stop scan
|
|
129
129
|
|
|
130
130
|
// Levels (0.0-1.0)
|
|
@@ -158,15 +158,17 @@ const reply = await rig.sendRaw(
|
|
|
158
158
|
Notes:
|
|
159
159
|
- `sendRaw()` is request/response oriented.
|
|
160
160
|
- Continuous spectrum streaming now uses Hamlib's official spectrum callback APIs instead of a raw serial byte subscription.
|
|
161
|
-
-
|
|
161
|
+
- The main `HamLib` class stays a bridge. High-level spectrum helpers live under the `hamlib/spectrum` subpath.
|
|
162
162
|
|
|
163
163
|
### Official Spectrum Streaming
|
|
164
164
|
|
|
165
165
|
```javascript
|
|
166
166
|
const { HamLib } = require('hamlib');
|
|
167
|
+
const { SpectrumController } = require('hamlib/spectrum');
|
|
167
168
|
|
|
168
169
|
async function monitorSpectrum() {
|
|
169
170
|
const rig = new HamLib(3085, '/dev/tty.usbmodem11201');
|
|
171
|
+
const spectrum = new SpectrumController(rig);
|
|
170
172
|
|
|
171
173
|
await rig.setSerialConfig('rate', '9600');
|
|
172
174
|
await rig.setSerialConfig('data_bits', '8');
|
|
@@ -174,12 +176,12 @@ async function monitorSpectrum() {
|
|
|
174
176
|
await rig.setSerialConfig('serial_parity', 'None');
|
|
175
177
|
await rig.open();
|
|
176
178
|
|
|
177
|
-
const support = await
|
|
179
|
+
const support = await spectrum.getSpectrumSupportSummary();
|
|
178
180
|
if (!support.supported) {
|
|
179
181
|
throw new Error('Official Hamlib spectrum streaming is not supported by this rig/backend');
|
|
180
182
|
}
|
|
181
183
|
|
|
182
|
-
|
|
184
|
+
spectrum.on('spectrumLine', (line) => {
|
|
183
185
|
console.log({
|
|
184
186
|
centerFreq: line.centerFreq,
|
|
185
187
|
spanHz: line.spanHz,
|
|
@@ -187,51 +189,54 @@ async function monitorSpectrum() {
|
|
|
187
189
|
});
|
|
188
190
|
});
|
|
189
191
|
|
|
190
|
-
await
|
|
192
|
+
await spectrum.startManagedSpectrum({
|
|
191
193
|
hold: false,
|
|
192
194
|
spanHz: 10000,
|
|
195
|
+
pumpIntervalMs: 200,
|
|
193
196
|
});
|
|
194
197
|
|
|
195
198
|
await new Promise((resolve) => setTimeout(resolve, 15000));
|
|
196
199
|
|
|
197
|
-
await
|
|
200
|
+
await spectrum.stopManagedSpectrum();
|
|
198
201
|
await rig.close();
|
|
199
202
|
}
|
|
200
203
|
```
|
|
201
204
|
|
|
202
205
|
Spectrum API summary:
|
|
203
206
|
|
|
204
|
-
- `getSpectrumCapabilities()` returns conservative backend metadata exposed by the native addon.
|
|
205
|
-
- `
|
|
206
|
-
- `
|
|
207
|
-
- `
|
|
208
|
-
- `
|
|
209
|
-
- `
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
212
|
-
- `
|
|
213
|
-
- `startManagedSpectrum(config?)` runs the validated startup sequence for Icom/Hamlib async spectrum.
|
|
214
|
-
- `
|
|
207
|
+
- `HamLib.getSpectrumCapabilities()` returns conservative backend metadata exposed by the native addon.
|
|
208
|
+
- `HamLib.startSpectrumStream(callback?)` registers the official Hamlib spectrum callback only.
|
|
209
|
+
- `HamLib.stopSpectrumStream()` unregisters the official spectrum callback.
|
|
210
|
+
- `SpectrumController.getSpectrumSupportSummary()` returns a product-oriented summary of whether official spectrum streaming is usable on the current rig/backend.
|
|
211
|
+
- `SpectrumController.configureSpectrum()` applies supported `SPECTRUM_*` levels and optional `SPECTRUM_HOLD`.
|
|
212
|
+
- `SpectrumController.getSpectrumDisplayState()` returns a normalized display state with `mode/span/fixed edges/edge slot`.
|
|
213
|
+
- `SpectrumController.configureSpectrumDisplay()` applies a normalized display config and reads back the resulting state.
|
|
214
|
+
- `SpectrumController.getSpectrumEdgeSlot()` / `SpectrumController.setSpectrumEdgeSlot()` expose backend edge-slot control when available.
|
|
215
|
+
- `SpectrumController.getSpectrumFixedEdges()` / `SpectrumController.setSpectrumFixedEdges()` expose direct fixed-range control using `SPECTRUM_EDGE_LOW/HIGH`.
|
|
216
|
+
- `SpectrumController.startManagedSpectrum(config?)` runs the validated startup sequence for Icom/Hamlib async spectrum.
|
|
217
|
+
- `pumpIntervalMs` controls a lightweight helper-side CAT pump. Default `200`; set `0` or `false` to disable.
|
|
218
|
+
- `SpectrumController.stopManagedSpectrum()` runs the symmetric shutdown sequence and unregisters the callback.
|
|
215
219
|
|
|
216
220
|
Fixed-range example:
|
|
217
221
|
|
|
218
222
|
```javascript
|
|
219
|
-
await
|
|
223
|
+
await spectrum.configureSpectrumDisplay({
|
|
220
224
|
mode: 'fixed',
|
|
221
225
|
edgeSlot: 1,
|
|
222
226
|
edgeLowHz: 14074000,
|
|
223
227
|
edgeHighHz: 14077000,
|
|
224
228
|
});
|
|
225
229
|
|
|
226
|
-
const displayState = await
|
|
230
|
+
const displayState = await spectrum.getSpectrumDisplayState();
|
|
227
231
|
console.log(displayState);
|
|
228
232
|
```
|
|
229
233
|
|
|
230
234
|
Emitted events:
|
|
231
235
|
|
|
232
|
-
- `
|
|
233
|
-
- `
|
|
234
|
-
- `
|
|
236
|
+
- `HamLib` emits `spectrumLine` when `startSpectrumStream()` is used without an explicit callback.
|
|
237
|
+
- `SpectrumController` emits `spectrumLine` for managed spectrum data.
|
|
238
|
+
- `SpectrumController` emits `spectrumStateChanged` when managed spectrum starts or stops.
|
|
239
|
+
- `SpectrumController` emits `spectrumError` when managed startup fails asynchronously.
|
|
235
240
|
|
|
236
241
|
### Power and Status
|
|
237
242
|
|