hamlib 0.1.9 → 0.1.11
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/src/hamlib.cpp
CHANGED
|
@@ -15,6 +15,16 @@
|
|
|
15
15
|
#endif
|
|
16
16
|
#endif
|
|
17
17
|
|
|
18
|
+
// 安全宏 - 检查RIG指针有效性,防止空指针解引用和已销毁对象访问
|
|
19
|
+
#define CHECK_RIG_VALID() \
|
|
20
|
+
do { \
|
|
21
|
+
if (!hamlib_instance_ || !hamlib_instance_->my_rig) { \
|
|
22
|
+
result_code_ = -RIG_EINVAL; \
|
|
23
|
+
error_message_ = "RIG is not initialized or has been destroyed"; \
|
|
24
|
+
return; \
|
|
25
|
+
} \
|
|
26
|
+
} while(0)
|
|
27
|
+
|
|
18
28
|
// Structure to hold rig information for the callback
|
|
19
29
|
struct RigListData {
|
|
20
30
|
std::vector<Napi::Object> rigList;
|
|
@@ -37,6 +47,8 @@ public:
|
|
|
37
47
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
38
48
|
|
|
39
49
|
void Execute() override {
|
|
50
|
+
CHECK_RIG_VALID();
|
|
51
|
+
|
|
40
52
|
result_code_ = rig_open(hamlib_instance_->my_rig);
|
|
41
53
|
if (result_code_ != RIG_OK) {
|
|
42
54
|
error_message_ = rigerror(result_code_);
|
|
@@ -54,7 +66,11 @@ public:
|
|
|
54
66
|
|
|
55
67
|
void OnOK() override {
|
|
56
68
|
Napi::Env env = Env();
|
|
57
|
-
|
|
69
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
70
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
71
|
+
} else {
|
|
72
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
73
|
+
}
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
void OnError(const Napi::Error& e) override {
|
|
@@ -69,6 +85,8 @@ public:
|
|
|
69
85
|
: HamLibAsyncWorker(env, hamlib_instance), freq_(freq), vfo_(vfo) {}
|
|
70
86
|
|
|
71
87
|
void Execute() override {
|
|
88
|
+
CHECK_RIG_VALID();
|
|
89
|
+
|
|
72
90
|
result_code_ = rig_set_freq(hamlib_instance_->my_rig, vfo_, freq_);
|
|
73
91
|
if (result_code_ != RIG_OK) {
|
|
74
92
|
error_message_ = rigerror(result_code_);
|
|
@@ -77,7 +95,11 @@ public:
|
|
|
77
95
|
|
|
78
96
|
void OnOK() override {
|
|
79
97
|
Napi::Env env = Env();
|
|
80
|
-
|
|
98
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
99
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
100
|
+
} else {
|
|
101
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
102
|
+
}
|
|
81
103
|
}
|
|
82
104
|
|
|
83
105
|
void OnError(const Napi::Error& e) override {
|
|
@@ -96,6 +118,8 @@ public:
|
|
|
96
118
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), freq_(0) {}
|
|
97
119
|
|
|
98
120
|
void Execute() override {
|
|
121
|
+
CHECK_RIG_VALID();
|
|
122
|
+
|
|
99
123
|
result_code_ = rig_get_freq(hamlib_instance_->my_rig, vfo_, &freq_);
|
|
100
124
|
if (result_code_ != RIG_OK) {
|
|
101
125
|
error_message_ = rigerror(result_code_);
|
|
@@ -104,7 +128,11 @@ public:
|
|
|
104
128
|
|
|
105
129
|
void OnOK() override {
|
|
106
130
|
Napi::Env env = Env();
|
|
107
|
-
|
|
131
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
132
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
133
|
+
} else {
|
|
134
|
+
deferred_.Resolve(Napi::Number::New(env, freq_));
|
|
135
|
+
}
|
|
108
136
|
}
|
|
109
137
|
|
|
110
138
|
void OnError(const Napi::Error& e) override {
|
|
@@ -123,6 +151,8 @@ public:
|
|
|
123
151
|
: HamLibAsyncWorker(env, hamlib_instance), mode_(mode), width_(width), vfo_(vfo) {}
|
|
124
152
|
|
|
125
153
|
void Execute() override {
|
|
154
|
+
CHECK_RIG_VALID();
|
|
155
|
+
|
|
126
156
|
result_code_ = rig_set_mode(hamlib_instance_->my_rig, vfo_, mode_, width_);
|
|
127
157
|
if (result_code_ != RIG_OK) {
|
|
128
158
|
error_message_ = rigerror(result_code_);
|
|
@@ -131,7 +161,11 @@ public:
|
|
|
131
161
|
|
|
132
162
|
void OnOK() override {
|
|
133
163
|
Napi::Env env = Env();
|
|
134
|
-
|
|
164
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
165
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
166
|
+
} else {
|
|
167
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
168
|
+
}
|
|
135
169
|
}
|
|
136
170
|
|
|
137
171
|
void OnError(const Napi::Error& e) override {
|
|
@@ -151,6 +185,8 @@ public:
|
|
|
151
185
|
: HamLibAsyncWorker(env, hamlib_instance), mode_(0), width_(0) {}
|
|
152
186
|
|
|
153
187
|
void Execute() override {
|
|
188
|
+
CHECK_RIG_VALID();
|
|
189
|
+
|
|
154
190
|
result_code_ = rig_get_mode(hamlib_instance_->my_rig, RIG_VFO_CURR, &mode_, &width_);
|
|
155
191
|
if (result_code_ != RIG_OK) {
|
|
156
192
|
error_message_ = rigerror(result_code_);
|
|
@@ -159,12 +195,16 @@ public:
|
|
|
159
195
|
|
|
160
196
|
void OnOK() override {
|
|
161
197
|
Napi::Env env = Env();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
198
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
199
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
200
|
+
} else {
|
|
201
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
202
|
+
// Convert mode to string using rig_strrmode
|
|
203
|
+
const char* mode_str = rig_strrmode(mode_);
|
|
204
|
+
obj.Set(Napi::String::New(env, "mode"), Napi::String::New(env, mode_str));
|
|
205
|
+
obj.Set(Napi::String::New(env, "bandwidth"), width_);
|
|
206
|
+
deferred_.Resolve(obj);
|
|
207
|
+
}
|
|
168
208
|
}
|
|
169
209
|
|
|
170
210
|
void OnError(const Napi::Error& e) override {
|
|
@@ -183,6 +223,8 @@ public:
|
|
|
183
223
|
: HamLibAsyncWorker(env, hamlib_instance), ptt_(ptt) {}
|
|
184
224
|
|
|
185
225
|
void Execute() override {
|
|
226
|
+
CHECK_RIG_VALID();
|
|
227
|
+
|
|
186
228
|
result_code_ = rig_set_ptt(hamlib_instance_->my_rig, RIG_VFO_CURR, ptt_);
|
|
187
229
|
if (result_code_ != RIG_OK) {
|
|
188
230
|
error_message_ = rigerror(result_code_);
|
|
@@ -191,7 +233,11 @@ public:
|
|
|
191
233
|
|
|
192
234
|
void OnOK() override {
|
|
193
235
|
Napi::Env env = Env();
|
|
194
|
-
|
|
236
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
237
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
238
|
+
} else {
|
|
239
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
240
|
+
}
|
|
195
241
|
}
|
|
196
242
|
|
|
197
243
|
void OnError(const Napi::Error& e) override {
|
|
@@ -209,6 +255,8 @@ public:
|
|
|
209
255
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), strength_(0) {}
|
|
210
256
|
|
|
211
257
|
void Execute() override {
|
|
258
|
+
CHECK_RIG_VALID();
|
|
259
|
+
|
|
212
260
|
result_code_ = rig_get_strength(hamlib_instance_->my_rig, vfo_, &strength_);
|
|
213
261
|
if (result_code_ != RIG_OK) {
|
|
214
262
|
error_message_ = rigerror(result_code_);
|
|
@@ -217,7 +265,11 @@ public:
|
|
|
217
265
|
|
|
218
266
|
void OnOK() override {
|
|
219
267
|
Napi::Env env = Env();
|
|
220
|
-
|
|
268
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
269
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
270
|
+
} else {
|
|
271
|
+
deferred_.Resolve(Napi::Number::New(env, strength_));
|
|
272
|
+
}
|
|
221
273
|
}
|
|
222
274
|
|
|
223
275
|
void OnError(const Napi::Error& e) override {
|
|
@@ -236,6 +288,8 @@ public:
|
|
|
236
288
|
: HamLibAsyncWorker(env, hamlib_instance), level_type_(level_type), value_(value) {}
|
|
237
289
|
|
|
238
290
|
void Execute() override {
|
|
291
|
+
CHECK_RIG_VALID();
|
|
292
|
+
|
|
239
293
|
result_code_ = rig_set_level(hamlib_instance_->my_rig, RIG_VFO_CURR, level_type_, value_);
|
|
240
294
|
if (result_code_ != RIG_OK) {
|
|
241
295
|
error_message_ = rigerror(result_code_);
|
|
@@ -244,7 +298,11 @@ public:
|
|
|
244
298
|
|
|
245
299
|
void OnOK() override {
|
|
246
300
|
Napi::Env env = Env();
|
|
247
|
-
|
|
301
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
302
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
303
|
+
} else {
|
|
304
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
305
|
+
}
|
|
248
306
|
}
|
|
249
307
|
|
|
250
308
|
void OnError(const Napi::Error& e) override {
|
|
@@ -265,6 +323,8 @@ public:
|
|
|
265
323
|
}
|
|
266
324
|
|
|
267
325
|
void Execute() override {
|
|
326
|
+
CHECK_RIG_VALID();
|
|
327
|
+
|
|
268
328
|
result_code_ = rig_get_level(hamlib_instance_->my_rig, RIG_VFO_CURR, level_type_, &value_);
|
|
269
329
|
if (result_code_ != RIG_OK) {
|
|
270
330
|
error_message_ = rigerror(result_code_);
|
|
@@ -273,7 +333,11 @@ public:
|
|
|
273
333
|
|
|
274
334
|
void OnOK() override {
|
|
275
335
|
Napi::Env env = Env();
|
|
276
|
-
|
|
336
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
337
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
338
|
+
} else {
|
|
339
|
+
deferred_.Resolve(Napi::Number::New(env, value_.f));
|
|
340
|
+
}
|
|
277
341
|
}
|
|
278
342
|
|
|
279
343
|
void OnError(const Napi::Error& e) override {
|
|
@@ -292,6 +356,8 @@ public:
|
|
|
292
356
|
: HamLibAsyncWorker(env, hamlib_instance), func_type_(func_type), enable_(enable) {}
|
|
293
357
|
|
|
294
358
|
void Execute() override {
|
|
359
|
+
CHECK_RIG_VALID();
|
|
360
|
+
|
|
295
361
|
result_code_ = rig_set_func(hamlib_instance_->my_rig, RIG_VFO_CURR, func_type_, enable_);
|
|
296
362
|
if (result_code_ != RIG_OK) {
|
|
297
363
|
error_message_ = rigerror(result_code_);
|
|
@@ -300,7 +366,11 @@ public:
|
|
|
300
366
|
|
|
301
367
|
void OnOK() override {
|
|
302
368
|
Napi::Env env = Env();
|
|
303
|
-
|
|
369
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
370
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
371
|
+
} else {
|
|
372
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
373
|
+
}
|
|
304
374
|
}
|
|
305
375
|
|
|
306
376
|
void OnError(const Napi::Error& e) override {
|
|
@@ -319,6 +389,8 @@ public:
|
|
|
319
389
|
: HamLibAsyncWorker(env, hamlib_instance), func_type_(func_type), state_(0) {}
|
|
320
390
|
|
|
321
391
|
void Execute() override {
|
|
392
|
+
CHECK_RIG_VALID();
|
|
393
|
+
|
|
322
394
|
result_code_ = rig_get_func(hamlib_instance_->my_rig, RIG_VFO_CURR, func_type_, &state_);
|
|
323
395
|
if (result_code_ != RIG_OK) {
|
|
324
396
|
error_message_ = rigerror(result_code_);
|
|
@@ -327,7 +399,11 @@ public:
|
|
|
327
399
|
|
|
328
400
|
void OnOK() override {
|
|
329
401
|
Napi::Env env = Env();
|
|
330
|
-
|
|
402
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
403
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
404
|
+
} else {
|
|
405
|
+
deferred_.Resolve(Napi::Boolean::New(env, state_ != 0));
|
|
406
|
+
}
|
|
331
407
|
}
|
|
332
408
|
|
|
333
409
|
void OnError(const Napi::Error& e) override {
|
|
@@ -346,6 +422,8 @@ public:
|
|
|
346
422
|
: HamLibAsyncWorker(env, hamlib_instance), chan_(chan) {}
|
|
347
423
|
|
|
348
424
|
void Execute() override {
|
|
425
|
+
CHECK_RIG_VALID();
|
|
426
|
+
|
|
349
427
|
result_code_ = rig_set_channel(hamlib_instance_->my_rig, RIG_VFO_MEM, &chan_);
|
|
350
428
|
if (result_code_ != RIG_OK) {
|
|
351
429
|
error_message_ = rigerror(result_code_);
|
|
@@ -354,7 +432,11 @@ public:
|
|
|
354
432
|
|
|
355
433
|
void OnOK() override {
|
|
356
434
|
Napi::Env env = Env();
|
|
357
|
-
|
|
435
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
436
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
437
|
+
} else {
|
|
438
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
439
|
+
}
|
|
358
440
|
}
|
|
359
441
|
|
|
360
442
|
void OnError(const Napi::Error& e) override {
|
|
@@ -374,6 +456,8 @@ public:
|
|
|
374
456
|
}
|
|
375
457
|
|
|
376
458
|
void Execute() override {
|
|
459
|
+
CHECK_RIG_VALID();
|
|
460
|
+
|
|
377
461
|
chan_.channel_num = channel_num_;
|
|
378
462
|
chan_.vfo = RIG_VFO_MEM;
|
|
379
463
|
result_code_ = rig_get_channel(hamlib_instance_->my_rig, RIG_VFO_MEM, &chan_, read_only_);
|
|
@@ -428,6 +512,8 @@ public:
|
|
|
428
512
|
: HamLibAsyncWorker(env, hamlib_instance), channel_num_(channel_num) {}
|
|
429
513
|
|
|
430
514
|
void Execute() override {
|
|
515
|
+
CHECK_RIG_VALID();
|
|
516
|
+
|
|
431
517
|
result_code_ = rig_set_mem(hamlib_instance_->my_rig, RIG_VFO_CURR, channel_num_);
|
|
432
518
|
if (result_code_ != RIG_OK) {
|
|
433
519
|
error_message_ = rigerror(result_code_);
|
|
@@ -436,7 +522,11 @@ public:
|
|
|
436
522
|
|
|
437
523
|
void OnOK() override {
|
|
438
524
|
Napi::Env env = Env();
|
|
439
|
-
|
|
525
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
526
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
527
|
+
} else {
|
|
528
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
529
|
+
}
|
|
440
530
|
}
|
|
441
531
|
|
|
442
532
|
void OnError(const Napi::Error& e) override {
|
|
@@ -454,6 +544,8 @@ public:
|
|
|
454
544
|
: HamLibAsyncWorker(env, hamlib_instance), rit_offset_(rit_offset) {}
|
|
455
545
|
|
|
456
546
|
void Execute() override {
|
|
547
|
+
CHECK_RIG_VALID();
|
|
548
|
+
|
|
457
549
|
result_code_ = rig_set_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, rit_offset_);
|
|
458
550
|
if (result_code_ != RIG_OK) {
|
|
459
551
|
error_message_ = rigerror(result_code_);
|
|
@@ -462,7 +554,11 @@ public:
|
|
|
462
554
|
|
|
463
555
|
void OnOK() override {
|
|
464
556
|
Napi::Env env = Env();
|
|
465
|
-
|
|
557
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
558
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
559
|
+
} else {
|
|
560
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
561
|
+
}
|
|
466
562
|
}
|
|
467
563
|
|
|
468
564
|
void OnError(const Napi::Error& e) override {
|
|
@@ -480,6 +576,8 @@ public:
|
|
|
480
576
|
: HamLibAsyncWorker(env, hamlib_instance), rit_offset_(0) {}
|
|
481
577
|
|
|
482
578
|
void Execute() override {
|
|
579
|
+
CHECK_RIG_VALID();
|
|
580
|
+
|
|
483
581
|
result_code_ = rig_get_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, &rit_offset_);
|
|
484
582
|
if (result_code_ != RIG_OK) {
|
|
485
583
|
error_message_ = rigerror(result_code_);
|
|
@@ -488,7 +586,11 @@ public:
|
|
|
488
586
|
|
|
489
587
|
void OnOK() override {
|
|
490
588
|
Napi::Env env = Env();
|
|
491
|
-
|
|
589
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
590
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
591
|
+
} else {
|
|
592
|
+
deferred_.Resolve(Napi::Number::New(env, rit_offset_));
|
|
593
|
+
}
|
|
492
594
|
}
|
|
493
595
|
|
|
494
596
|
void OnError(const Napi::Error& e) override {
|
|
@@ -506,6 +608,8 @@ public:
|
|
|
506
608
|
: HamLibAsyncWorker(env, hamlib_instance), xit_offset_(xit_offset) {}
|
|
507
609
|
|
|
508
610
|
void Execute() override {
|
|
611
|
+
CHECK_RIG_VALID();
|
|
612
|
+
|
|
509
613
|
result_code_ = rig_set_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, xit_offset_);
|
|
510
614
|
if (result_code_ != RIG_OK) {
|
|
511
615
|
error_message_ = rigerror(result_code_);
|
|
@@ -514,7 +618,11 @@ public:
|
|
|
514
618
|
|
|
515
619
|
void OnOK() override {
|
|
516
620
|
Napi::Env env = Env();
|
|
517
|
-
|
|
621
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
622
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
623
|
+
} else {
|
|
624
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
625
|
+
}
|
|
518
626
|
}
|
|
519
627
|
|
|
520
628
|
void OnError(const Napi::Error& e) override {
|
|
@@ -532,6 +640,8 @@ public:
|
|
|
532
640
|
: HamLibAsyncWorker(env, hamlib_instance), xit_offset_(0) {}
|
|
533
641
|
|
|
534
642
|
void Execute() override {
|
|
643
|
+
CHECK_RIG_VALID();
|
|
644
|
+
|
|
535
645
|
result_code_ = rig_get_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, &xit_offset_);
|
|
536
646
|
if (result_code_ != RIG_OK) {
|
|
537
647
|
error_message_ = rigerror(result_code_);
|
|
@@ -540,7 +650,11 @@ public:
|
|
|
540
650
|
|
|
541
651
|
void OnOK() override {
|
|
542
652
|
Napi::Env env = Env();
|
|
543
|
-
|
|
653
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
654
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
655
|
+
} else {
|
|
656
|
+
deferred_.Resolve(Napi::Number::New(env, xit_offset_));
|
|
657
|
+
}
|
|
544
658
|
}
|
|
545
659
|
|
|
546
660
|
void OnError(const Napi::Error& e) override {
|
|
@@ -558,6 +672,8 @@ public:
|
|
|
558
672
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
559
673
|
|
|
560
674
|
void Execute() override {
|
|
675
|
+
CHECK_RIG_VALID();
|
|
676
|
+
|
|
561
677
|
int ritCode = rig_set_rit(hamlib_instance_->my_rig, RIG_VFO_CURR, 0);
|
|
562
678
|
int xitCode = rig_set_xit(hamlib_instance_->my_rig, RIG_VFO_CURR, 0);
|
|
563
679
|
|
|
@@ -574,7 +690,11 @@ public:
|
|
|
574
690
|
|
|
575
691
|
void OnOK() override {
|
|
576
692
|
Napi::Env env = Env();
|
|
577
|
-
|
|
693
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
694
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
695
|
+
} else {
|
|
696
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
697
|
+
}
|
|
578
698
|
}
|
|
579
699
|
|
|
580
700
|
void OnError(const Napi::Error& e) override {
|
|
@@ -589,6 +709,8 @@ public:
|
|
|
589
709
|
: HamLibAsyncWorker(env, hamlib_instance), tx_freq_(tx_freq), vfo_(vfo) {}
|
|
590
710
|
|
|
591
711
|
void Execute() override {
|
|
712
|
+
CHECK_RIG_VALID();
|
|
713
|
+
|
|
592
714
|
result_code_ = rig_set_split_freq(hamlib_instance_->my_rig, vfo_, tx_freq_);
|
|
593
715
|
if (result_code_ != RIG_OK) {
|
|
594
716
|
error_message_ = rigerror(result_code_);
|
|
@@ -597,7 +719,11 @@ public:
|
|
|
597
719
|
|
|
598
720
|
void OnOK() override {
|
|
599
721
|
Napi::Env env = Env();
|
|
600
|
-
|
|
722
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
723
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
724
|
+
} else {
|
|
725
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
726
|
+
}
|
|
601
727
|
}
|
|
602
728
|
|
|
603
729
|
void OnError(const Napi::Error& e) override {
|
|
@@ -616,6 +742,8 @@ public:
|
|
|
616
742
|
: HamLibAsyncWorker(env, hamlib_instance), tx_freq_(0), vfo_(vfo) {}
|
|
617
743
|
|
|
618
744
|
void Execute() override {
|
|
745
|
+
CHECK_RIG_VALID();
|
|
746
|
+
|
|
619
747
|
result_code_ = rig_get_split_freq(hamlib_instance_->my_rig, vfo_, &tx_freq_);
|
|
620
748
|
if (result_code_ != RIG_OK) {
|
|
621
749
|
error_message_ = rigerror(result_code_);
|
|
@@ -624,7 +752,11 @@ public:
|
|
|
624
752
|
|
|
625
753
|
void OnOK() override {
|
|
626
754
|
Napi::Env env = Env();
|
|
627
|
-
|
|
755
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
756
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
757
|
+
} else {
|
|
758
|
+
deferred_.Resolve(Napi::Number::New(env, tx_freq_));
|
|
759
|
+
}
|
|
628
760
|
}
|
|
629
761
|
|
|
630
762
|
void OnError(const Napi::Error& e) override {
|
|
@@ -643,6 +775,8 @@ public:
|
|
|
643
775
|
: HamLibAsyncWorker(env, hamlib_instance), rx_vfo_(rx_vfo), split_(split), tx_vfo_(tx_vfo) {}
|
|
644
776
|
|
|
645
777
|
void Execute() override {
|
|
778
|
+
CHECK_RIG_VALID();
|
|
779
|
+
|
|
646
780
|
result_code_ = rig_set_split_vfo(hamlib_instance_->my_rig, rx_vfo_, split_, tx_vfo_);
|
|
647
781
|
if (result_code_ != RIG_OK) {
|
|
648
782
|
error_message_ = rigerror(result_code_);
|
|
@@ -651,7 +785,11 @@ public:
|
|
|
651
785
|
|
|
652
786
|
void OnOK() override {
|
|
653
787
|
Napi::Env env = Env();
|
|
654
|
-
|
|
788
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
789
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
790
|
+
} else {
|
|
791
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
792
|
+
}
|
|
655
793
|
}
|
|
656
794
|
|
|
657
795
|
void OnError(const Napi::Error& e) override {
|
|
@@ -671,6 +809,8 @@ public:
|
|
|
671
809
|
: HamLibAsyncWorker(env, hamlib_instance), split_(RIG_SPLIT_OFF), tx_vfo_(RIG_VFO_B), vfo_(vfo) {}
|
|
672
810
|
|
|
673
811
|
void Execute() override {
|
|
812
|
+
CHECK_RIG_VALID();
|
|
813
|
+
|
|
674
814
|
result_code_ = rig_get_split_vfo(hamlib_instance_->my_rig, vfo_, &split_, &tx_vfo_);
|
|
675
815
|
if (result_code_ != RIG_OK) {
|
|
676
816
|
error_message_ = rigerror(result_code_);
|
|
@@ -679,16 +819,20 @@ public:
|
|
|
679
819
|
|
|
680
820
|
void OnOK() override {
|
|
681
821
|
Napi::Env env = Env();
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
822
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
823
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
824
|
+
} else {
|
|
825
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
826
|
+
obj.Set(Napi::String::New(env, "enabled"), Napi::Boolean::New(env, split_ == RIG_SPLIT_ON));
|
|
827
|
+
|
|
828
|
+
const char* vfo_str = "VFO-B";
|
|
829
|
+
if (tx_vfo_ == RIG_VFO_A) {
|
|
830
|
+
vfo_str = "VFO-A";
|
|
831
|
+
}
|
|
832
|
+
obj.Set(Napi::String::New(env, "txVfo"), Napi::String::New(env, vfo_str));
|
|
833
|
+
|
|
834
|
+
deferred_.Resolve(obj);
|
|
688
835
|
}
|
|
689
|
-
obj.Set(Napi::String::New(env, "txVfo"), Napi::String::New(env, vfo_str));
|
|
690
|
-
|
|
691
|
-
deferred_.Resolve(obj);
|
|
692
836
|
}
|
|
693
837
|
|
|
694
838
|
void OnError(const Napi::Error& e) override {
|
|
@@ -708,6 +852,8 @@ public:
|
|
|
708
852
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
|
|
709
853
|
|
|
710
854
|
void Execute() override {
|
|
855
|
+
CHECK_RIG_VALID();
|
|
856
|
+
|
|
711
857
|
result_code_ = rig_set_vfo(hamlib_instance_->my_rig, vfo_);
|
|
712
858
|
if (result_code_ != RIG_OK) {
|
|
713
859
|
error_message_ = rigerror(result_code_);
|
|
@@ -716,7 +862,11 @@ public:
|
|
|
716
862
|
|
|
717
863
|
void OnOK() override {
|
|
718
864
|
Napi::Env env = Env();
|
|
719
|
-
|
|
865
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
866
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
867
|
+
} else {
|
|
868
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
869
|
+
}
|
|
720
870
|
}
|
|
721
871
|
|
|
722
872
|
void OnError(const Napi::Error& e) override {
|
|
@@ -734,6 +884,8 @@ public:
|
|
|
734
884
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(0) {}
|
|
735
885
|
|
|
736
886
|
void Execute() override {
|
|
887
|
+
CHECK_RIG_VALID();
|
|
888
|
+
|
|
737
889
|
result_code_ = rig_get_vfo(hamlib_instance_->my_rig, &vfo_);
|
|
738
890
|
if (result_code_ != RIG_OK) {
|
|
739
891
|
// 提供更清晰的错误信息
|
|
@@ -795,6 +947,14 @@ public:
|
|
|
795
947
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
796
948
|
|
|
797
949
|
void Execute() override {
|
|
950
|
+
CHECK_RIG_VALID();
|
|
951
|
+
|
|
952
|
+
// 检查rig是否已经关闭
|
|
953
|
+
if (!hamlib_instance_->rig_is_open) {
|
|
954
|
+
result_code_ = RIG_OK; // 已经关闭,返回成功
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
|
|
798
958
|
result_code_ = rig_close(hamlib_instance_->my_rig);
|
|
799
959
|
if (result_code_ != RIG_OK) {
|
|
800
960
|
error_message_ = rigerror(result_code_);
|
|
@@ -805,7 +965,11 @@ public:
|
|
|
805
965
|
|
|
806
966
|
void OnOK() override {
|
|
807
967
|
Napi::Env env = Env();
|
|
808
|
-
|
|
968
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
969
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
970
|
+
} else {
|
|
971
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
972
|
+
}
|
|
809
973
|
}
|
|
810
974
|
|
|
811
975
|
void OnError(const Napi::Error& e) override {
|
|
@@ -820,20 +984,25 @@ public:
|
|
|
820
984
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
821
985
|
|
|
822
986
|
void Execute() override {
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
987
|
+
CHECK_RIG_VALID();
|
|
988
|
+
|
|
989
|
+
// rig_cleanup会自动调用rig_close,所以我们不需要重复调用
|
|
826
990
|
result_code_ = rig_cleanup(hamlib_instance_->my_rig);
|
|
827
991
|
if (result_code_ != RIG_OK) {
|
|
828
992
|
error_message_ = rigerror(result_code_);
|
|
829
993
|
} else {
|
|
830
994
|
hamlib_instance_->rig_is_open = false;
|
|
995
|
+
hamlib_instance_->my_rig = nullptr; // 重要:清空指针防止重复释放
|
|
831
996
|
}
|
|
832
997
|
}
|
|
833
998
|
|
|
834
999
|
void OnOK() override {
|
|
835
1000
|
Napi::Env env = Env();
|
|
836
|
-
|
|
1001
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1002
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1003
|
+
} else {
|
|
1004
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1005
|
+
}
|
|
837
1006
|
}
|
|
838
1007
|
|
|
839
1008
|
void OnError(const Napi::Error& e) override {
|
|
@@ -849,6 +1018,8 @@ public:
|
|
|
849
1018
|
: HamLibAsyncWorker(env, hamlib_instance), scan_type_(scan_type), channel_(channel) {}
|
|
850
1019
|
|
|
851
1020
|
void Execute() override {
|
|
1021
|
+
CHECK_RIG_VALID();
|
|
1022
|
+
|
|
852
1023
|
result_code_ = rig_scan(hamlib_instance_->my_rig, RIG_VFO_CURR, scan_type_, channel_);
|
|
853
1024
|
if (result_code_ != RIG_OK) {
|
|
854
1025
|
error_message_ = rigerror(result_code_);
|
|
@@ -857,7 +1028,11 @@ public:
|
|
|
857
1028
|
|
|
858
1029
|
void OnOK() override {
|
|
859
1030
|
Napi::Env env = Env();
|
|
860
|
-
|
|
1031
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1032
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1033
|
+
} else {
|
|
1034
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1035
|
+
}
|
|
861
1036
|
}
|
|
862
1037
|
|
|
863
1038
|
void OnError(const Napi::Error& e) override {
|
|
@@ -877,6 +1052,8 @@ public:
|
|
|
877
1052
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
878
1053
|
|
|
879
1054
|
void Execute() override {
|
|
1055
|
+
CHECK_RIG_VALID();
|
|
1056
|
+
|
|
880
1057
|
result_code_ = rig_scan(hamlib_instance_->my_rig, RIG_VFO_CURR, RIG_SCAN_STOP, 0);
|
|
881
1058
|
if (result_code_ != RIG_OK) {
|
|
882
1059
|
error_message_ = rigerror(result_code_);
|
|
@@ -885,7 +1062,11 @@ public:
|
|
|
885
1062
|
|
|
886
1063
|
void OnOK() override {
|
|
887
1064
|
Napi::Env env = Env();
|
|
888
|
-
|
|
1065
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1066
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1067
|
+
} else {
|
|
1068
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1069
|
+
}
|
|
889
1070
|
}
|
|
890
1071
|
|
|
891
1072
|
void OnError(const Napi::Error& e) override {
|
|
@@ -901,6 +1082,8 @@ public:
|
|
|
901
1082
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_op_(vfo_op) {}
|
|
902
1083
|
|
|
903
1084
|
void Execute() override {
|
|
1085
|
+
CHECK_RIG_VALID();
|
|
1086
|
+
|
|
904
1087
|
result_code_ = rig_vfo_op(hamlib_instance_->my_rig, RIG_VFO_CURR, vfo_op_);
|
|
905
1088
|
if (result_code_ != RIG_OK) {
|
|
906
1089
|
error_message_ = rigerror(result_code_);
|
|
@@ -909,7 +1092,11 @@ public:
|
|
|
909
1092
|
|
|
910
1093
|
void OnOK() override {
|
|
911
1094
|
Napi::Env env = Env();
|
|
912
|
-
|
|
1095
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1096
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1097
|
+
} else {
|
|
1098
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1099
|
+
}
|
|
913
1100
|
}
|
|
914
1101
|
|
|
915
1102
|
void OnError(const Napi::Error& e) override {
|
|
@@ -928,6 +1115,8 @@ public:
|
|
|
928
1115
|
: HamLibAsyncWorker(env, hamlib_instance), antenna_(antenna), vfo_(vfo), option_(option) {}
|
|
929
1116
|
|
|
930
1117
|
void Execute() override {
|
|
1118
|
+
CHECK_RIG_VALID();
|
|
1119
|
+
|
|
931
1120
|
result_code_ = rig_set_ant(hamlib_instance_->my_rig, vfo_, antenna_, option_);
|
|
932
1121
|
if (result_code_ != RIG_OK) {
|
|
933
1122
|
error_message_ = rigerror(result_code_);
|
|
@@ -936,7 +1125,11 @@ public:
|
|
|
936
1125
|
|
|
937
1126
|
void OnOK() override {
|
|
938
1127
|
Napi::Env env = Env();
|
|
939
|
-
|
|
1128
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1129
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1130
|
+
} else {
|
|
1131
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1132
|
+
}
|
|
940
1133
|
}
|
|
941
1134
|
|
|
942
1135
|
void OnError(const Napi::Error& e) override {
|
|
@@ -957,6 +1150,8 @@ public:
|
|
|
957
1150
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), antenna_(antenna), antenna_curr_(0), antenna_tx_(0), antenna_rx_(0) {}
|
|
958
1151
|
|
|
959
1152
|
void Execute() override {
|
|
1153
|
+
CHECK_RIG_VALID();
|
|
1154
|
+
|
|
960
1155
|
option_ = {0};
|
|
961
1156
|
|
|
962
1157
|
result_code_ = rig_get_ant(hamlib_instance_->my_rig, vfo_, antenna_, &option_, &antenna_curr_, &antenna_tx_, &antenna_rx_);
|
|
@@ -967,14 +1162,18 @@ public:
|
|
|
967
1162
|
|
|
968
1163
|
void OnOK() override {
|
|
969
1164
|
Napi::Env env = Env();
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1165
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1166
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1167
|
+
} else {
|
|
1168
|
+
Napi::Object result = Napi::Object::New(env);
|
|
1169
|
+
|
|
1170
|
+
result.Set("currentAntenna", Napi::Number::New(env, antenna_curr_));
|
|
1171
|
+
result.Set("txAntenna", Napi::Number::New(env, antenna_tx_));
|
|
1172
|
+
result.Set("rxAntenna", Napi::Number::New(env, antenna_rx_));
|
|
1173
|
+
result.Set("option", Napi::Number::New(env, option_.f));
|
|
1174
|
+
|
|
1175
|
+
deferred_.Resolve(result);
|
|
1176
|
+
}
|
|
978
1177
|
}
|
|
979
1178
|
|
|
980
1179
|
void OnError(const Napi::Error& e) override {
|
|
@@ -998,6 +1197,8 @@ public:
|
|
|
998
1197
|
: HamLibAsyncWorker(env, hamlib_instance), power_(power), freq_(freq), mode_(mode), mwpower_(0) {}
|
|
999
1198
|
|
|
1000
1199
|
void Execute() override {
|
|
1200
|
+
CHECK_RIG_VALID();
|
|
1201
|
+
|
|
1001
1202
|
result_code_ = rig_power2mW(hamlib_instance_->my_rig, &mwpower_, power_, freq_, mode_);
|
|
1002
1203
|
if (result_code_ != RIG_OK) {
|
|
1003
1204
|
error_message_ = rigerror(result_code_);
|
|
@@ -1006,7 +1207,11 @@ public:
|
|
|
1006
1207
|
|
|
1007
1208
|
void OnOK() override {
|
|
1008
1209
|
Napi::Env env = Env();
|
|
1009
|
-
|
|
1210
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1211
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1212
|
+
} else {
|
|
1213
|
+
deferred_.Resolve(Napi::Number::New(env, mwpower_));
|
|
1214
|
+
}
|
|
1010
1215
|
}
|
|
1011
1216
|
|
|
1012
1217
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1028,6 +1233,8 @@ public:
|
|
|
1028
1233
|
: HamLibAsyncWorker(env, hamlib_instance), mwpower_(mwpower), freq_(freq), mode_(mode), power_(0.0) {}
|
|
1029
1234
|
|
|
1030
1235
|
void Execute() override {
|
|
1236
|
+
CHECK_RIG_VALID();
|
|
1237
|
+
|
|
1031
1238
|
result_code_ = rig_mW2power(hamlib_instance_->my_rig, &power_, mwpower_, freq_, mode_);
|
|
1032
1239
|
if (result_code_ != RIG_OK) {
|
|
1033
1240
|
error_message_ = rigerror(result_code_);
|
|
@@ -1036,7 +1243,11 @@ public:
|
|
|
1036
1243
|
|
|
1037
1244
|
void OnOK() override {
|
|
1038
1245
|
Napi::Env env = Env();
|
|
1039
|
-
|
|
1246
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1247
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1248
|
+
} else {
|
|
1249
|
+
deferred_.Resolve(Napi::Number::New(env, power_));
|
|
1250
|
+
}
|
|
1040
1251
|
}
|
|
1041
1252
|
|
|
1042
1253
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1058,6 +1269,8 @@ public:
|
|
|
1058
1269
|
: HamLibAsyncWorker(env, hamlib_instance), tx_mode_(tx_mode), tx_width_(tx_width), vfo_(vfo) {}
|
|
1059
1270
|
|
|
1060
1271
|
void Execute() override {
|
|
1272
|
+
CHECK_RIG_VALID();
|
|
1273
|
+
|
|
1061
1274
|
result_code_ = rig_set_split_mode(hamlib_instance_->my_rig, vfo_, tx_mode_, tx_width_);
|
|
1062
1275
|
if (result_code_ != RIG_OK) {
|
|
1063
1276
|
error_message_ = rigerror(result_code_);
|
|
@@ -1066,7 +1279,11 @@ public:
|
|
|
1066
1279
|
|
|
1067
1280
|
void OnOK() override {
|
|
1068
1281
|
Napi::Env env = Env();
|
|
1069
|
-
|
|
1282
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1283
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1284
|
+
} else {
|
|
1285
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1286
|
+
}
|
|
1070
1287
|
}
|
|
1071
1288
|
|
|
1072
1289
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1087,6 +1304,8 @@ public:
|
|
|
1087
1304
|
: HamLibAsyncWorker(env, hamlib_instance), tx_mode_(0), tx_width_(0), vfo_(vfo) {}
|
|
1088
1305
|
|
|
1089
1306
|
void Execute() override {
|
|
1307
|
+
CHECK_RIG_VALID();
|
|
1308
|
+
|
|
1090
1309
|
result_code_ = rig_get_split_mode(hamlib_instance_->my_rig, vfo_, &tx_mode_, &tx_width_);
|
|
1091
1310
|
if (result_code_ != RIG_OK) {
|
|
1092
1311
|
error_message_ = rigerror(result_code_);
|
|
@@ -1095,12 +1314,16 @@ public:
|
|
|
1095
1314
|
|
|
1096
1315
|
void OnOK() override {
|
|
1097
1316
|
Napi::Env env = Env();
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1317
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1318
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1319
|
+
} else {
|
|
1320
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
1321
|
+
// Convert mode to string using rig_strrmode
|
|
1322
|
+
const char* mode_str = rig_strrmode(tx_mode_);
|
|
1323
|
+
obj.Set(Napi::String::New(env, "mode"), Napi::String::New(env, mode_str));
|
|
1324
|
+
obj.Set(Napi::String::New(env, "width"), tx_width_);
|
|
1325
|
+
deferred_.Resolve(obj);
|
|
1326
|
+
}
|
|
1104
1327
|
}
|
|
1105
1328
|
|
|
1106
1329
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1121,6 +1344,8 @@ public:
|
|
|
1121
1344
|
: HamLibAsyncWorker(env, hamlib_instance), param_name_(param_name), param_value_(param_value) {}
|
|
1122
1345
|
|
|
1123
1346
|
void Execute() override {
|
|
1347
|
+
CHECK_RIG_VALID();
|
|
1348
|
+
|
|
1124
1349
|
// Apply serial configuration parameter
|
|
1125
1350
|
if (param_name_ == "data_bits") {
|
|
1126
1351
|
int data_bits = std::stoi(param_value_);
|
|
@@ -1254,7 +1479,11 @@ public:
|
|
|
1254
1479
|
|
|
1255
1480
|
void OnOK() override {
|
|
1256
1481
|
Napi::Env env = Env();
|
|
1257
|
-
|
|
1482
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1483
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1484
|
+
} else {
|
|
1485
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1486
|
+
}
|
|
1258
1487
|
}
|
|
1259
1488
|
|
|
1260
1489
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1274,6 +1503,8 @@ public:
|
|
|
1274
1503
|
: HamLibAsyncWorker(env, hamlib_instance), param_name_(param_name) {}
|
|
1275
1504
|
|
|
1276
1505
|
void Execute() override {
|
|
1506
|
+
CHECK_RIG_VALID();
|
|
1507
|
+
|
|
1277
1508
|
// Get serial configuration parameter
|
|
1278
1509
|
if (param_name_ == "data_bits") {
|
|
1279
1510
|
param_value_ = std::to_string(hamlib_instance_->my_rig->state.rigport.parm.serial.data_bits);
|
|
@@ -1365,7 +1596,11 @@ public:
|
|
|
1365
1596
|
|
|
1366
1597
|
void OnOK() override {
|
|
1367
1598
|
Napi::Env env = Env();
|
|
1368
|
-
|
|
1599
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1600
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1601
|
+
} else {
|
|
1602
|
+
deferred_.Resolve(Napi::String::New(env, param_value_));
|
|
1603
|
+
}
|
|
1369
1604
|
}
|
|
1370
1605
|
|
|
1371
1606
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1385,6 +1620,8 @@ public:
|
|
|
1385
1620
|
: HamLibAsyncWorker(env, hamlib_instance), ptt_type_(ptt_type) {}
|
|
1386
1621
|
|
|
1387
1622
|
void Execute() override {
|
|
1623
|
+
CHECK_RIG_VALID();
|
|
1624
|
+
|
|
1388
1625
|
ptt_type_t ptt_type;
|
|
1389
1626
|
if (ptt_type_ == "RIG") {
|
|
1390
1627
|
ptt_type = RIG_PTT_RIG;
|
|
@@ -1414,7 +1651,11 @@ public:
|
|
|
1414
1651
|
|
|
1415
1652
|
void OnOK() override {
|
|
1416
1653
|
Napi::Env env = Env();
|
|
1417
|
-
|
|
1654
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1655
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1656
|
+
} else {
|
|
1657
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1658
|
+
}
|
|
1418
1659
|
}
|
|
1419
1660
|
|
|
1420
1661
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1433,6 +1674,8 @@ public:
|
|
|
1433
1674
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
1434
1675
|
|
|
1435
1676
|
void Execute() override {
|
|
1677
|
+
CHECK_RIG_VALID();
|
|
1678
|
+
|
|
1436
1679
|
ptt_type_t ptt_type = hamlib_instance_->my_rig->state.pttport.type.ptt;
|
|
1437
1680
|
|
|
1438
1681
|
switch (ptt_type) {
|
|
@@ -1469,7 +1712,11 @@ public:
|
|
|
1469
1712
|
|
|
1470
1713
|
void OnOK() override {
|
|
1471
1714
|
Napi::Env env = Env();
|
|
1472
|
-
|
|
1715
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1716
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1717
|
+
} else {
|
|
1718
|
+
deferred_.Resolve(Napi::String::New(env, ptt_type_str_));
|
|
1719
|
+
}
|
|
1473
1720
|
}
|
|
1474
1721
|
|
|
1475
1722
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1488,6 +1735,8 @@ public:
|
|
|
1488
1735
|
: HamLibAsyncWorker(env, hamlib_instance), dcd_type_(dcd_type) {}
|
|
1489
1736
|
|
|
1490
1737
|
void Execute() override {
|
|
1738
|
+
CHECK_RIG_VALID();
|
|
1739
|
+
|
|
1491
1740
|
dcd_type_t dcd_type;
|
|
1492
1741
|
if (dcd_type_ == "RIG") {
|
|
1493
1742
|
dcd_type = RIG_DCD_RIG;
|
|
@@ -1519,7 +1768,11 @@ public:
|
|
|
1519
1768
|
|
|
1520
1769
|
void OnOK() override {
|
|
1521
1770
|
Napi::Env env = Env();
|
|
1522
|
-
|
|
1771
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1772
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1773
|
+
} else {
|
|
1774
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1775
|
+
}
|
|
1523
1776
|
}
|
|
1524
1777
|
|
|
1525
1778
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1538,6 +1791,8 @@ public:
|
|
|
1538
1791
|
: HamLibAsyncWorker(env, hamlib_instance) {}
|
|
1539
1792
|
|
|
1540
1793
|
void Execute() override {
|
|
1794
|
+
CHECK_RIG_VALID();
|
|
1795
|
+
|
|
1541
1796
|
dcd_type_t dcd_type = hamlib_instance_->my_rig->state.dcdport.type.dcd;
|
|
1542
1797
|
|
|
1543
1798
|
switch (dcd_type) {
|
|
@@ -1577,7 +1832,11 @@ public:
|
|
|
1577
1832
|
|
|
1578
1833
|
void OnOK() override {
|
|
1579
1834
|
Napi::Env env = Env();
|
|
1580
|
-
|
|
1835
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1836
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1837
|
+
} else {
|
|
1838
|
+
deferred_.Resolve(Napi::String::New(env, dcd_type_str_));
|
|
1839
|
+
}
|
|
1581
1840
|
}
|
|
1582
1841
|
|
|
1583
1842
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1596,6 +1855,8 @@ public:
|
|
|
1596
1855
|
: HamLibAsyncWorker(env, hamlib_instance), status_(status) {}
|
|
1597
1856
|
|
|
1598
1857
|
void Execute() override {
|
|
1858
|
+
CHECK_RIG_VALID();
|
|
1859
|
+
|
|
1599
1860
|
result_code_ = rig_set_powerstat(hamlib_instance_->my_rig, status_);
|
|
1600
1861
|
if (result_code_ != RIG_OK) {
|
|
1601
1862
|
error_message_ = rigerror(result_code_);
|
|
@@ -1604,7 +1865,11 @@ public:
|
|
|
1604
1865
|
|
|
1605
1866
|
void OnOK() override {
|
|
1606
1867
|
Napi::Env env = Env();
|
|
1607
|
-
|
|
1868
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1869
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1870
|
+
} else {
|
|
1871
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
1872
|
+
}
|
|
1608
1873
|
}
|
|
1609
1874
|
|
|
1610
1875
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1622,6 +1887,8 @@ public:
|
|
|
1622
1887
|
: HamLibAsyncWorker(env, hamlib_instance), status_(RIG_POWER_UNKNOWN) {}
|
|
1623
1888
|
|
|
1624
1889
|
void Execute() override {
|
|
1890
|
+
CHECK_RIG_VALID();
|
|
1891
|
+
|
|
1625
1892
|
result_code_ = rig_get_powerstat(hamlib_instance_->my_rig, &status_);
|
|
1626
1893
|
if (result_code_ != RIG_OK) {
|
|
1627
1894
|
error_message_ = rigerror(result_code_);
|
|
@@ -1630,7 +1897,11 @@ public:
|
|
|
1630
1897
|
|
|
1631
1898
|
void OnOK() override {
|
|
1632
1899
|
Napi::Env env = Env();
|
|
1633
|
-
|
|
1900
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1901
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1902
|
+
} else {
|
|
1903
|
+
deferred_.Resolve(Napi::Number::New(env, static_cast<int>(status_)));
|
|
1904
|
+
}
|
|
1634
1905
|
}
|
|
1635
1906
|
|
|
1636
1907
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1649,6 +1920,8 @@ public:
|
|
|
1649
1920
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ptt_(RIG_PTT_OFF) {}
|
|
1650
1921
|
|
|
1651
1922
|
void Execute() override {
|
|
1923
|
+
CHECK_RIG_VALID();
|
|
1924
|
+
|
|
1652
1925
|
result_code_ = rig_get_ptt(hamlib_instance_->my_rig, vfo_, &ptt_);
|
|
1653
1926
|
if (result_code_ != RIG_OK) {
|
|
1654
1927
|
error_message_ = rigerror(result_code_);
|
|
@@ -1657,7 +1930,11 @@ public:
|
|
|
1657
1930
|
|
|
1658
1931
|
void OnOK() override {
|
|
1659
1932
|
Napi::Env env = Env();
|
|
1660
|
-
|
|
1933
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1934
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1935
|
+
} else {
|
|
1936
|
+
deferred_.Resolve(Napi::Boolean::New(env, ptt_ == RIG_PTT_ON));
|
|
1937
|
+
}
|
|
1661
1938
|
}
|
|
1662
1939
|
|
|
1663
1940
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1677,6 +1954,8 @@ public:
|
|
|
1677
1954
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), dcd_(RIG_DCD_OFF) {}
|
|
1678
1955
|
|
|
1679
1956
|
void Execute() override {
|
|
1957
|
+
CHECK_RIG_VALID();
|
|
1958
|
+
|
|
1680
1959
|
result_code_ = rig_get_dcd(hamlib_instance_->my_rig, vfo_, &dcd_);
|
|
1681
1960
|
if (result_code_ != RIG_OK) {
|
|
1682
1961
|
error_message_ = rigerror(result_code_);
|
|
@@ -1685,7 +1964,11 @@ public:
|
|
|
1685
1964
|
|
|
1686
1965
|
void OnOK() override {
|
|
1687
1966
|
Napi::Env env = Env();
|
|
1688
|
-
|
|
1967
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
1968
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
1969
|
+
} else {
|
|
1970
|
+
deferred_.Resolve(Napi::Boolean::New(env, dcd_ == RIG_DCD_ON));
|
|
1971
|
+
}
|
|
1689
1972
|
}
|
|
1690
1973
|
|
|
1691
1974
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1705,6 +1988,8 @@ public:
|
|
|
1705
1988
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ts_(ts) {}
|
|
1706
1989
|
|
|
1707
1990
|
void Execute() override {
|
|
1991
|
+
CHECK_RIG_VALID();
|
|
1992
|
+
|
|
1708
1993
|
result_code_ = rig_set_ts(hamlib_instance_->my_rig, vfo_, ts_);
|
|
1709
1994
|
if (result_code_ != RIG_OK) {
|
|
1710
1995
|
error_message_ = rigerror(result_code_);
|
|
@@ -1713,7 +1998,11 @@ public:
|
|
|
1713
1998
|
|
|
1714
1999
|
void OnOK() override {
|
|
1715
2000
|
Napi::Env env = Env();
|
|
1716
|
-
|
|
2001
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
2002
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
2003
|
+
} else {
|
|
2004
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
2005
|
+
}
|
|
1717
2006
|
}
|
|
1718
2007
|
|
|
1719
2008
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1732,6 +2021,8 @@ public:
|
|
|
1732
2021
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ts_(0) {}
|
|
1733
2022
|
|
|
1734
2023
|
void Execute() override {
|
|
2024
|
+
CHECK_RIG_VALID();
|
|
2025
|
+
|
|
1735
2026
|
result_code_ = rig_get_ts(hamlib_instance_->my_rig, vfo_, &ts_);
|
|
1736
2027
|
if (result_code_ != RIG_OK) {
|
|
1737
2028
|
error_message_ = rigerror(result_code_);
|
|
@@ -1740,7 +2031,11 @@ public:
|
|
|
1740
2031
|
|
|
1741
2032
|
void OnOK() override {
|
|
1742
2033
|
Napi::Env env = Env();
|
|
1743
|
-
|
|
2034
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
2035
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
2036
|
+
} else {
|
|
2037
|
+
deferred_.Resolve(Napi::Number::New(env, ts_));
|
|
2038
|
+
}
|
|
1744
2039
|
}
|
|
1745
2040
|
|
|
1746
2041
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1760,6 +2055,8 @@ public:
|
|
|
1760
2055
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), shift_(shift) {}
|
|
1761
2056
|
|
|
1762
2057
|
void Execute() override {
|
|
2058
|
+
CHECK_RIG_VALID();
|
|
2059
|
+
|
|
1763
2060
|
result_code_ = rig_set_rptr_shift(hamlib_instance_->my_rig, vfo_, shift_);
|
|
1764
2061
|
if (result_code_ != RIG_OK) {
|
|
1765
2062
|
error_message_ = rigerror(result_code_);
|
|
@@ -1768,7 +2065,11 @@ public:
|
|
|
1768
2065
|
|
|
1769
2066
|
void OnOK() override {
|
|
1770
2067
|
Napi::Env env = Env();
|
|
1771
|
-
|
|
2068
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
2069
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
2070
|
+
} else {
|
|
2071
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
2072
|
+
}
|
|
1772
2073
|
}
|
|
1773
2074
|
|
|
1774
2075
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1787,6 +2088,8 @@ public:
|
|
|
1787
2088
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), shift_(RIG_RPT_SHIFT_NONE) {}
|
|
1788
2089
|
|
|
1789
2090
|
void Execute() override {
|
|
2091
|
+
CHECK_RIG_VALID();
|
|
2092
|
+
|
|
1790
2093
|
result_code_ = rig_get_rptr_shift(hamlib_instance_->my_rig, vfo_, &shift_);
|
|
1791
2094
|
if (result_code_ != RIG_OK) {
|
|
1792
2095
|
error_message_ = rigerror(result_code_);
|
|
@@ -1815,6 +2118,8 @@ public:
|
|
|
1815
2118
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), offset_(offset) {}
|
|
1816
2119
|
|
|
1817
2120
|
void Execute() override {
|
|
2121
|
+
CHECK_RIG_VALID();
|
|
2122
|
+
|
|
1818
2123
|
result_code_ = rig_set_rptr_offs(hamlib_instance_->my_rig, vfo_, offset_);
|
|
1819
2124
|
if (result_code_ != RIG_OK) {
|
|
1820
2125
|
error_message_ = rigerror(result_code_);
|
|
@@ -1823,7 +2128,11 @@ public:
|
|
|
1823
2128
|
|
|
1824
2129
|
void OnOK() override {
|
|
1825
2130
|
Napi::Env env = Env();
|
|
1826
|
-
|
|
2131
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
2132
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
2133
|
+
} else {
|
|
2134
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
2135
|
+
}
|
|
1827
2136
|
}
|
|
1828
2137
|
|
|
1829
2138
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1842,6 +2151,8 @@ public:
|
|
|
1842
2151
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), offset_(0) {}
|
|
1843
2152
|
|
|
1844
2153
|
void Execute() override {
|
|
2154
|
+
CHECK_RIG_VALID();
|
|
2155
|
+
|
|
1845
2156
|
result_code_ = rig_get_rptr_offs(hamlib_instance_->my_rig, vfo_, &offset_);
|
|
1846
2157
|
if (result_code_ != RIG_OK) {
|
|
1847
2158
|
error_message_ = rigerror(result_code_);
|
|
@@ -1850,7 +2161,11 @@ public:
|
|
|
1850
2161
|
|
|
1851
2162
|
void OnOK() override {
|
|
1852
2163
|
Napi::Env env = Env();
|
|
1853
|
-
|
|
2164
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
2165
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
2166
|
+
} else {
|
|
2167
|
+
deferred_.Resolve(Napi::Number::New(env, offset_));
|
|
2168
|
+
}
|
|
1854
2169
|
}
|
|
1855
2170
|
|
|
1856
2171
|
void OnError(const Napi::Error& e) override {
|
|
@@ -1961,6 +2276,21 @@ NodeHamLib::NodeHamLib(const Napi::CallbackInfo & info): ObjectWrap(info) {
|
|
|
1961
2276
|
rig_is_open = false;
|
|
1962
2277
|
}
|
|
1963
2278
|
|
|
2279
|
+
// 析构函数 - 确保资源正确清理
|
|
2280
|
+
NodeHamLib::~NodeHamLib() {
|
|
2281
|
+
// 如果rig指针存在,执行清理
|
|
2282
|
+
if (my_rig) {
|
|
2283
|
+
// 如果rig是打开状态,先关闭
|
|
2284
|
+
if (rig_is_open) {
|
|
2285
|
+
rig_close(my_rig);
|
|
2286
|
+
rig_is_open = false;
|
|
2287
|
+
}
|
|
2288
|
+
// 清理rig资源
|
|
2289
|
+
rig_cleanup(my_rig);
|
|
2290
|
+
my_rig = nullptr;
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
|
|
1964
2294
|
int NodeHamLib::freq_change_cb(RIG *rig, vfo_t vfo, freq_t freq, void* arg) {
|
|
1965
2295
|
auto instance = static_cast<NodeHamLib*>(arg);
|
|
1966
2296
|
printf("Rig changed freq to %0.7f Hz\n", freq);
|
|
@@ -3780,6 +4110,8 @@ public:
|
|
|
3780
4110
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(tone) {}
|
|
3781
4111
|
|
|
3782
4112
|
void Execute() override {
|
|
4113
|
+
CHECK_RIG_VALID();
|
|
4114
|
+
|
|
3783
4115
|
result_code_ = rig_set_ctcss_tone(hamlib_instance_->my_rig, vfo_, tone_);
|
|
3784
4116
|
if (result_code_ != RIG_OK) {
|
|
3785
4117
|
error_message_ = rigerror(result_code_);
|
|
@@ -3788,7 +4120,11 @@ public:
|
|
|
3788
4120
|
|
|
3789
4121
|
void OnOK() override {
|
|
3790
4122
|
Napi::Env env = Env();
|
|
3791
|
-
|
|
4123
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4124
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4125
|
+
} else {
|
|
4126
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4127
|
+
}
|
|
3792
4128
|
}
|
|
3793
4129
|
|
|
3794
4130
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3807,6 +4143,8 @@ public:
|
|
|
3807
4143
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(0) {}
|
|
3808
4144
|
|
|
3809
4145
|
void Execute() override {
|
|
4146
|
+
CHECK_RIG_VALID();
|
|
4147
|
+
|
|
3810
4148
|
result_code_ = rig_get_ctcss_tone(hamlib_instance_->my_rig, vfo_, &tone_);
|
|
3811
4149
|
if (result_code_ != RIG_OK) {
|
|
3812
4150
|
error_message_ = rigerror(result_code_);
|
|
@@ -3815,7 +4153,11 @@ public:
|
|
|
3815
4153
|
|
|
3816
4154
|
void OnOK() override {
|
|
3817
4155
|
Napi::Env env = Env();
|
|
3818
|
-
|
|
4156
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4157
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4158
|
+
} else {
|
|
4159
|
+
deferred_.Resolve(Napi::Number::New(env, tone_));
|
|
4160
|
+
}
|
|
3819
4161
|
}
|
|
3820
4162
|
|
|
3821
4163
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3834,6 +4176,8 @@ public:
|
|
|
3834
4176
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(code) {}
|
|
3835
4177
|
|
|
3836
4178
|
void Execute() override {
|
|
4179
|
+
CHECK_RIG_VALID();
|
|
4180
|
+
|
|
3837
4181
|
result_code_ = rig_set_dcs_code(hamlib_instance_->my_rig, vfo_, code_);
|
|
3838
4182
|
if (result_code_ != RIG_OK) {
|
|
3839
4183
|
error_message_ = rigerror(result_code_);
|
|
@@ -3842,7 +4186,11 @@ public:
|
|
|
3842
4186
|
|
|
3843
4187
|
void OnOK() override {
|
|
3844
4188
|
Napi::Env env = Env();
|
|
3845
|
-
|
|
4189
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4190
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4191
|
+
} else {
|
|
4192
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4193
|
+
}
|
|
3846
4194
|
}
|
|
3847
4195
|
|
|
3848
4196
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3861,6 +4209,8 @@ public:
|
|
|
3861
4209
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(0) {}
|
|
3862
4210
|
|
|
3863
4211
|
void Execute() override {
|
|
4212
|
+
CHECK_RIG_VALID();
|
|
4213
|
+
|
|
3864
4214
|
result_code_ = rig_get_dcs_code(hamlib_instance_->my_rig, vfo_, &code_);
|
|
3865
4215
|
if (result_code_ != RIG_OK) {
|
|
3866
4216
|
error_message_ = rigerror(result_code_);
|
|
@@ -3869,7 +4219,11 @@ public:
|
|
|
3869
4219
|
|
|
3870
4220
|
void OnOK() override {
|
|
3871
4221
|
Napi::Env env = Env();
|
|
3872
|
-
|
|
4222
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4223
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4224
|
+
} else {
|
|
4225
|
+
deferred_.Resolve(Napi::Number::New(env, code_));
|
|
4226
|
+
}
|
|
3873
4227
|
}
|
|
3874
4228
|
|
|
3875
4229
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3888,6 +4242,8 @@ public:
|
|
|
3888
4242
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(tone) {}
|
|
3889
4243
|
|
|
3890
4244
|
void Execute() override {
|
|
4245
|
+
CHECK_RIG_VALID();
|
|
4246
|
+
|
|
3891
4247
|
result_code_ = rig_set_ctcss_sql(hamlib_instance_->my_rig, vfo_, tone_);
|
|
3892
4248
|
if (result_code_ != RIG_OK) {
|
|
3893
4249
|
error_message_ = rigerror(result_code_);
|
|
@@ -3896,7 +4252,11 @@ public:
|
|
|
3896
4252
|
|
|
3897
4253
|
void OnOK() override {
|
|
3898
4254
|
Napi::Env env = Env();
|
|
3899
|
-
|
|
4255
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4256
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4257
|
+
} else {
|
|
4258
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4259
|
+
}
|
|
3900
4260
|
}
|
|
3901
4261
|
|
|
3902
4262
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3915,6 +4275,8 @@ public:
|
|
|
3915
4275
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tone_(0) {}
|
|
3916
4276
|
|
|
3917
4277
|
void Execute() override {
|
|
4278
|
+
CHECK_RIG_VALID();
|
|
4279
|
+
|
|
3918
4280
|
result_code_ = rig_get_ctcss_sql(hamlib_instance_->my_rig, vfo_, &tone_);
|
|
3919
4281
|
if (result_code_ != RIG_OK) {
|
|
3920
4282
|
error_message_ = rigerror(result_code_);
|
|
@@ -3923,7 +4285,11 @@ public:
|
|
|
3923
4285
|
|
|
3924
4286
|
void OnOK() override {
|
|
3925
4287
|
Napi::Env env = Env();
|
|
3926
|
-
|
|
4288
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4289
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4290
|
+
} else {
|
|
4291
|
+
deferred_.Resolve(Napi::Number::New(env, tone_));
|
|
4292
|
+
}
|
|
3927
4293
|
}
|
|
3928
4294
|
|
|
3929
4295
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3942,6 +4308,8 @@ public:
|
|
|
3942
4308
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(code) {}
|
|
3943
4309
|
|
|
3944
4310
|
void Execute() override {
|
|
4311
|
+
CHECK_RIG_VALID();
|
|
4312
|
+
|
|
3945
4313
|
result_code_ = rig_set_dcs_sql(hamlib_instance_->my_rig, vfo_, code_);
|
|
3946
4314
|
if (result_code_ != RIG_OK) {
|
|
3947
4315
|
error_message_ = rigerror(result_code_);
|
|
@@ -3950,7 +4318,11 @@ public:
|
|
|
3950
4318
|
|
|
3951
4319
|
void OnOK() override {
|
|
3952
4320
|
Napi::Env env = Env();
|
|
3953
|
-
|
|
4321
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4322
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4323
|
+
} else {
|
|
4324
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4325
|
+
}
|
|
3954
4326
|
}
|
|
3955
4327
|
|
|
3956
4328
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3969,6 +4341,8 @@ public:
|
|
|
3969
4341
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), code_(0) {}
|
|
3970
4342
|
|
|
3971
4343
|
void Execute() override {
|
|
4344
|
+
CHECK_RIG_VALID();
|
|
4345
|
+
|
|
3972
4346
|
result_code_ = rig_get_dcs_sql(hamlib_instance_->my_rig, vfo_, &code_);
|
|
3973
4347
|
if (result_code_ != RIG_OK) {
|
|
3974
4348
|
error_message_ = rigerror(result_code_);
|
|
@@ -3977,7 +4351,11 @@ public:
|
|
|
3977
4351
|
|
|
3978
4352
|
void OnOK() override {
|
|
3979
4353
|
Napi::Env env = Env();
|
|
3980
|
-
|
|
4354
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4355
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4356
|
+
} else {
|
|
4357
|
+
deferred_.Resolve(Napi::Number::New(env, code_));
|
|
4358
|
+
}
|
|
3981
4359
|
}
|
|
3982
4360
|
|
|
3983
4361
|
void OnError(const Napi::Error& e) override {
|
|
@@ -3997,6 +4375,8 @@ public:
|
|
|
3997
4375
|
: HamLibAsyncWorker(env, hamlib_instance), parm_(parm), value_(value) {}
|
|
3998
4376
|
|
|
3999
4377
|
void Execute() override {
|
|
4378
|
+
CHECK_RIG_VALID();
|
|
4379
|
+
|
|
4000
4380
|
result_code_ = rig_set_parm(hamlib_instance_->my_rig, parm_, value_);
|
|
4001
4381
|
if (result_code_ != RIG_OK) {
|
|
4002
4382
|
error_message_ = rigerror(result_code_);
|
|
@@ -4005,7 +4385,11 @@ public:
|
|
|
4005
4385
|
|
|
4006
4386
|
void OnOK() override {
|
|
4007
4387
|
Napi::Env env = Env();
|
|
4008
|
-
|
|
4388
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4389
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4390
|
+
} else {
|
|
4391
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4392
|
+
}
|
|
4009
4393
|
}
|
|
4010
4394
|
|
|
4011
4395
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4026,6 +4410,8 @@ public:
|
|
|
4026
4410
|
}
|
|
4027
4411
|
|
|
4028
4412
|
void Execute() override {
|
|
4413
|
+
CHECK_RIG_VALID();
|
|
4414
|
+
|
|
4029
4415
|
result_code_ = rig_get_parm(hamlib_instance_->my_rig, parm_, &value_);
|
|
4030
4416
|
if (result_code_ != RIG_OK) {
|
|
4031
4417
|
error_message_ = rigerror(result_code_);
|
|
@@ -4034,7 +4420,11 @@ public:
|
|
|
4034
4420
|
|
|
4035
4421
|
void OnOK() override {
|
|
4036
4422
|
Napi::Env env = Env();
|
|
4037
|
-
|
|
4423
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4424
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4425
|
+
} else {
|
|
4426
|
+
deferred_.Resolve(Napi::Number::New(env, value_.f));
|
|
4427
|
+
}
|
|
4038
4428
|
}
|
|
4039
4429
|
|
|
4040
4430
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4054,6 +4444,8 @@ public:
|
|
|
4054
4444
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), digits_(digits) {}
|
|
4055
4445
|
|
|
4056
4446
|
void Execute() override {
|
|
4447
|
+
CHECK_RIG_VALID();
|
|
4448
|
+
|
|
4057
4449
|
result_code_ = rig_send_dtmf(hamlib_instance_->my_rig, vfo_, digits_.c_str());
|
|
4058
4450
|
if (result_code_ != RIG_OK) {
|
|
4059
4451
|
error_message_ = rigerror(result_code_);
|
|
@@ -4062,7 +4454,11 @@ public:
|
|
|
4062
4454
|
|
|
4063
4455
|
void OnOK() override {
|
|
4064
4456
|
Napi::Env env = Env();
|
|
4065
|
-
|
|
4457
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4458
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4459
|
+
} else {
|
|
4460
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4461
|
+
}
|
|
4066
4462
|
}
|
|
4067
4463
|
|
|
4068
4464
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4083,6 +4479,8 @@ public:
|
|
|
4083
4479
|
}
|
|
4084
4480
|
|
|
4085
4481
|
void Execute() override {
|
|
4482
|
+
CHECK_RIG_VALID();
|
|
4483
|
+
|
|
4086
4484
|
length_ = max_length_;
|
|
4087
4485
|
result_code_ = rig_recv_dtmf(hamlib_instance_->my_rig, vfo_, digits_.data(), &length_);
|
|
4088
4486
|
if (result_code_ != RIG_OK) {
|
|
@@ -4092,10 +4490,14 @@ public:
|
|
|
4092
4490
|
|
|
4093
4491
|
void OnOK() override {
|
|
4094
4492
|
Napi::Env env = Env();
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4098
|
-
|
|
4493
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4494
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4495
|
+
} else {
|
|
4496
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
4497
|
+
obj.Set(Napi::String::New(env, "digits"), Napi::String::New(env, digits_.substr(0, length_)));
|
|
4498
|
+
obj.Set(Napi::String::New(env, "length"), Napi::Number::New(env, length_));
|
|
4499
|
+
deferred_.Resolve(obj);
|
|
4500
|
+
}
|
|
4099
4501
|
}
|
|
4100
4502
|
|
|
4101
4503
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4117,6 +4519,8 @@ public:
|
|
|
4117
4519
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ch_(0) {}
|
|
4118
4520
|
|
|
4119
4521
|
void Execute() override {
|
|
4522
|
+
CHECK_RIG_VALID();
|
|
4523
|
+
|
|
4120
4524
|
result_code_ = rig_get_mem(hamlib_instance_->my_rig, vfo_, &ch_);
|
|
4121
4525
|
if (result_code_ != RIG_OK) {
|
|
4122
4526
|
error_message_ = rigerror(result_code_);
|
|
@@ -4125,7 +4529,11 @@ public:
|
|
|
4125
4529
|
|
|
4126
4530
|
void OnOK() override {
|
|
4127
4531
|
Napi::Env env = Env();
|
|
4128
|
-
|
|
4532
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4533
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4534
|
+
} else {
|
|
4535
|
+
deferred_.Resolve(Napi::Number::New(env, ch_));
|
|
4536
|
+
}
|
|
4129
4537
|
}
|
|
4130
4538
|
|
|
4131
4539
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4144,6 +4552,8 @@ public:
|
|
|
4144
4552
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), bank_(bank) {}
|
|
4145
4553
|
|
|
4146
4554
|
void Execute() override {
|
|
4555
|
+
CHECK_RIG_VALID();
|
|
4556
|
+
|
|
4147
4557
|
result_code_ = rig_set_bank(hamlib_instance_->my_rig, vfo_, bank_);
|
|
4148
4558
|
if (result_code_ != RIG_OK) {
|
|
4149
4559
|
error_message_ = rigerror(result_code_);
|
|
@@ -4152,7 +4562,11 @@ public:
|
|
|
4152
4562
|
|
|
4153
4563
|
void OnOK() override {
|
|
4154
4564
|
Napi::Env env = Env();
|
|
4155
|
-
|
|
4565
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4566
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4567
|
+
} else {
|
|
4568
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4569
|
+
}
|
|
4156
4570
|
}
|
|
4157
4571
|
|
|
4158
4572
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4171,6 +4585,8 @@ public:
|
|
|
4171
4585
|
: HamLibAsyncWorker(env, hamlib_instance), count_(0) {}
|
|
4172
4586
|
|
|
4173
4587
|
void Execute() override {
|
|
4588
|
+
CHECK_RIG_VALID();
|
|
4589
|
+
|
|
4174
4590
|
count_ = rig_mem_count(hamlib_instance_->my_rig);
|
|
4175
4591
|
if (count_ < 0) {
|
|
4176
4592
|
result_code_ = count_;
|
|
@@ -4182,7 +4598,11 @@ public:
|
|
|
4182
4598
|
|
|
4183
4599
|
void OnOK() override {
|
|
4184
4600
|
Napi::Env env = Env();
|
|
4185
|
-
|
|
4601
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4602
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4603
|
+
} else {
|
|
4604
|
+
deferred_.Resolve(Napi::Number::New(env, count_));
|
|
4605
|
+
}
|
|
4186
4606
|
}
|
|
4187
4607
|
|
|
4188
4608
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4201,6 +4621,8 @@ public:
|
|
|
4201
4621
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), msg_(msg) {}
|
|
4202
4622
|
|
|
4203
4623
|
void Execute() override {
|
|
4624
|
+
CHECK_RIG_VALID();
|
|
4625
|
+
|
|
4204
4626
|
result_code_ = rig_send_morse(hamlib_instance_->my_rig, vfo_, msg_.c_str());
|
|
4205
4627
|
if (result_code_ != RIG_OK) {
|
|
4206
4628
|
error_message_ = rigerror(result_code_);
|
|
@@ -4209,7 +4631,11 @@ public:
|
|
|
4209
4631
|
|
|
4210
4632
|
void OnOK() override {
|
|
4211
4633
|
Napi::Env env = Env();
|
|
4212
|
-
|
|
4634
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4635
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4636
|
+
} else {
|
|
4637
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4638
|
+
}
|
|
4213
4639
|
}
|
|
4214
4640
|
|
|
4215
4641
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4228,6 +4654,8 @@ public:
|
|
|
4228
4654
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
|
|
4229
4655
|
|
|
4230
4656
|
void Execute() override {
|
|
4657
|
+
CHECK_RIG_VALID();
|
|
4658
|
+
|
|
4231
4659
|
result_code_ = rig_stop_morse(hamlib_instance_->my_rig, vfo_);
|
|
4232
4660
|
if (result_code_ != RIG_OK) {
|
|
4233
4661
|
error_message_ = rigerror(result_code_);
|
|
@@ -4236,7 +4664,11 @@ public:
|
|
|
4236
4664
|
|
|
4237
4665
|
void OnOK() override {
|
|
4238
4666
|
Napi::Env env = Env();
|
|
4239
|
-
|
|
4667
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4668
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4669
|
+
} else {
|
|
4670
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4671
|
+
}
|
|
4240
4672
|
}
|
|
4241
4673
|
|
|
4242
4674
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4254,6 +4686,8 @@ public:
|
|
|
4254
4686
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
|
|
4255
4687
|
|
|
4256
4688
|
void Execute() override {
|
|
4689
|
+
CHECK_RIG_VALID();
|
|
4690
|
+
|
|
4257
4691
|
result_code_ = rig_wait_morse(hamlib_instance_->my_rig, vfo_);
|
|
4258
4692
|
if (result_code_ != RIG_OK) {
|
|
4259
4693
|
error_message_ = rigerror(result_code_);
|
|
@@ -4262,7 +4696,11 @@ public:
|
|
|
4262
4696
|
|
|
4263
4697
|
void OnOK() override {
|
|
4264
4698
|
Napi::Env env = Env();
|
|
4265
|
-
|
|
4699
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4700
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4701
|
+
} else {
|
|
4702
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4703
|
+
}
|
|
4266
4704
|
}
|
|
4267
4705
|
|
|
4268
4706
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4281,6 +4719,8 @@ public:
|
|
|
4281
4719
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), ch_(ch) {}
|
|
4282
4720
|
|
|
4283
4721
|
void Execute() override {
|
|
4722
|
+
CHECK_RIG_VALID();
|
|
4723
|
+
|
|
4284
4724
|
result_code_ = rig_send_voice_mem(hamlib_instance_->my_rig, vfo_, ch_);
|
|
4285
4725
|
if (result_code_ != RIG_OK) {
|
|
4286
4726
|
error_message_ = rigerror(result_code_);
|
|
@@ -4289,7 +4729,11 @@ public:
|
|
|
4289
4729
|
|
|
4290
4730
|
void OnOK() override {
|
|
4291
4731
|
Napi::Env env = Env();
|
|
4292
|
-
|
|
4732
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4733
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4734
|
+
} else {
|
|
4735
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4736
|
+
}
|
|
4293
4737
|
}
|
|
4294
4738
|
|
|
4295
4739
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4308,6 +4752,8 @@ public:
|
|
|
4308
4752
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo) {}
|
|
4309
4753
|
|
|
4310
4754
|
void Execute() override {
|
|
4755
|
+
CHECK_RIG_VALID();
|
|
4756
|
+
|
|
4311
4757
|
#if HAVE_RIG_STOP_VOICE_MEM
|
|
4312
4758
|
result_code_ = rig_stop_voice_mem(hamlib_instance_->my_rig, vfo_);
|
|
4313
4759
|
if (result_code_ != RIG_OK) {
|
|
@@ -4323,7 +4769,11 @@ public:
|
|
|
4323
4769
|
|
|
4324
4770
|
void OnOK() override {
|
|
4325
4771
|
Napi::Env env = Env();
|
|
4326
|
-
|
|
4772
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4773
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4774
|
+
} else {
|
|
4775
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4776
|
+
}
|
|
4327
4777
|
}
|
|
4328
4778
|
|
|
4329
4779
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4344,6 +4794,8 @@ public:
|
|
|
4344
4794
|
tx_mode_(tx_mode), tx_width_(tx_width) {}
|
|
4345
4795
|
|
|
4346
4796
|
void Execute() override {
|
|
4797
|
+
CHECK_RIG_VALID();
|
|
4798
|
+
|
|
4347
4799
|
#if HAVE_RIG_SPLIT_FREQ_MODE
|
|
4348
4800
|
result_code_ = rig_set_split_freq_mode(hamlib_instance_->my_rig, vfo_, tx_freq_, tx_mode_, tx_width_);
|
|
4349
4801
|
if (result_code_ != RIG_OK) {
|
|
@@ -4359,7 +4811,11 @@ public:
|
|
|
4359
4811
|
|
|
4360
4812
|
void OnOK() override {
|
|
4361
4813
|
Napi::Env env = Env();
|
|
4362
|
-
|
|
4814
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4815
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4816
|
+
} else {
|
|
4817
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4818
|
+
}
|
|
4363
4819
|
}
|
|
4364
4820
|
|
|
4365
4821
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4380,6 +4836,8 @@ public:
|
|
|
4380
4836
|
: HamLibAsyncWorker(env, hamlib_instance), vfo_(vfo), tx_freq_(0), tx_mode_(RIG_MODE_NONE), tx_width_(0) {}
|
|
4381
4837
|
|
|
4382
4838
|
void Execute() override {
|
|
4839
|
+
CHECK_RIG_VALID();
|
|
4840
|
+
|
|
4383
4841
|
#if HAVE_RIG_SPLIT_FREQ_MODE
|
|
4384
4842
|
result_code_ = rig_get_split_freq_mode(hamlib_instance_->my_rig, vfo_, &tx_freq_, &tx_mode_, &tx_width_);
|
|
4385
4843
|
if (result_code_ != RIG_OK) {
|
|
@@ -4395,11 +4853,15 @@ public:
|
|
|
4395
4853
|
|
|
4396
4854
|
void OnOK() override {
|
|
4397
4855
|
Napi::Env env = Env();
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4856
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4857
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4858
|
+
} else {
|
|
4859
|
+
Napi::Object obj = Napi::Object::New(env);
|
|
4860
|
+
obj.Set(Napi::String::New(env, "txFrequency"), Napi::Number::New(env, static_cast<double>(tx_freq_)));
|
|
4861
|
+
obj.Set(Napi::String::New(env, "txMode"), Napi::String::New(env, rig_strrmode(tx_mode_)));
|
|
4862
|
+
obj.Set(Napi::String::New(env, "txWidth"), Napi::Number::New(env, static_cast<double>(tx_width_)));
|
|
4863
|
+
deferred_.Resolve(obj);
|
|
4864
|
+
}
|
|
4403
4865
|
}
|
|
4404
4866
|
|
|
4405
4867
|
void OnError(const Napi::Error& e) override {
|
|
@@ -4421,6 +4883,8 @@ public:
|
|
|
4421
4883
|
: HamLibAsyncWorker(env, hamlib_instance), reset_(reset) {}
|
|
4422
4884
|
|
|
4423
4885
|
void Execute() override {
|
|
4886
|
+
CHECK_RIG_VALID();
|
|
4887
|
+
|
|
4424
4888
|
result_code_ = rig_reset(hamlib_instance_->my_rig, reset_);
|
|
4425
4889
|
if (result_code_ != RIG_OK) {
|
|
4426
4890
|
error_message_ = rigerror(result_code_);
|
|
@@ -4429,7 +4893,11 @@ public:
|
|
|
4429
4893
|
|
|
4430
4894
|
void OnOK() override {
|
|
4431
4895
|
Napi::Env env = Env();
|
|
4432
|
-
|
|
4896
|
+
if (result_code_ != RIG_OK && !error_message_.empty()) {
|
|
4897
|
+
deferred_.Reject(Napi::Error::New(env, error_message_).Value());
|
|
4898
|
+
} else {
|
|
4899
|
+
deferred_.Resolve(Napi::Number::New(env, result_code_));
|
|
4900
|
+
}
|
|
4433
4901
|
}
|
|
4434
4902
|
|
|
4435
4903
|
void OnError(const Napi::Error& e) override {
|