hamlib 0.2.0 → 0.2.2
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/index.d.ts +259 -4
- package/lib/index.js +234 -0
- package/package.json +1 -1
- package/prebuilds/darwin-arm64/{libhamlib.5.dylib → libhamlib.4.dylib} +0 -0
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/darwin-x64/{libhamlib.5.dylib → 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.5.0.0 → libhamlib.so.4} +0 -0
- package/prebuilds/linux-arm64/{libhamlib.so.5 → 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.5 → libhamlib.so.4} +0 -0
- package/prebuilds/linux-x64/{libhamlib.so.5.0.0 → 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/libhamlib-4.dll +0 -0
- package/prebuilds/win32-x64/node.napi.node +0 -0
- package/src/hamlib.cpp +829 -15
- package/src/hamlib.h +44 -0
- package/src/shim/hamlib_shim.c +311 -7
- package/src/shim/hamlib_shim.h +94 -3
package/src/hamlib.h
CHANGED
|
@@ -159,6 +159,46 @@ class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
|
159
159
|
// Reset Function
|
|
160
160
|
Napi::Value Reset(const Napi::CallbackInfo&);
|
|
161
161
|
|
|
162
|
+
// Lock Mode (Hamlib >= 4.7.0)
|
|
163
|
+
Napi::Value SetLockMode(const Napi::CallbackInfo&);
|
|
164
|
+
Napi::Value GetLockMode(const Napi::CallbackInfo&);
|
|
165
|
+
|
|
166
|
+
// Clock (Hamlib >= 4.7.0)
|
|
167
|
+
Napi::Value SetClock(const Napi::CallbackInfo&);
|
|
168
|
+
Napi::Value GetClock(const Napi::CallbackInfo&);
|
|
169
|
+
|
|
170
|
+
// VFO Info (Hamlib >= 4.7.0)
|
|
171
|
+
Napi::Value GetVfoInfo(const Napi::CallbackInfo&);
|
|
172
|
+
|
|
173
|
+
// Rig Info / Raw / Conf (async)
|
|
174
|
+
Napi::Value GetInfo(const Napi::CallbackInfo&);
|
|
175
|
+
Napi::Value SendRaw(const Napi::CallbackInfo&);
|
|
176
|
+
Napi::Value SetConf(const Napi::CallbackInfo&);
|
|
177
|
+
Napi::Value GetConf(const Napi::CallbackInfo&);
|
|
178
|
+
|
|
179
|
+
// Passband / Resolution (sync)
|
|
180
|
+
Napi::Value GetPassbandNormal(const Napi::CallbackInfo&);
|
|
181
|
+
Napi::Value GetPassbandNarrow(const Napi::CallbackInfo&);
|
|
182
|
+
Napi::Value GetPassbandWide(const Napi::CallbackInfo&);
|
|
183
|
+
Napi::Value GetResolution(const Napi::CallbackInfo&);
|
|
184
|
+
|
|
185
|
+
// Capability queries (sync)
|
|
186
|
+
Napi::Value GetSupportedParms(const Napi::CallbackInfo&);
|
|
187
|
+
Napi::Value GetSupportedVfoOps(const Napi::CallbackInfo&);
|
|
188
|
+
Napi::Value GetSupportedScanTypes(const Napi::CallbackInfo&);
|
|
189
|
+
|
|
190
|
+
// Capability queries - batch 2 (sync)
|
|
191
|
+
Napi::Value GetPreampValues(const Napi::CallbackInfo&);
|
|
192
|
+
Napi::Value GetAttenuatorValues(const Napi::CallbackInfo&);
|
|
193
|
+
Napi::Value GetMaxRit(const Napi::CallbackInfo&);
|
|
194
|
+
Napi::Value GetMaxXit(const Napi::CallbackInfo&);
|
|
195
|
+
Napi::Value GetMaxIfShift(const Napi::CallbackInfo&);
|
|
196
|
+
Napi::Value GetAvailableCtcssTones(const Napi::CallbackInfo&);
|
|
197
|
+
Napi::Value GetAvailableDcsCodes(const Napi::CallbackInfo&);
|
|
198
|
+
Napi::Value GetFrequencyRanges(const Napi::CallbackInfo&);
|
|
199
|
+
Napi::Value GetTuningSteps(const Napi::CallbackInfo&);
|
|
200
|
+
Napi::Value GetFilterList(const Napi::CallbackInfo&);
|
|
201
|
+
|
|
162
202
|
// Static method to get supported rig models
|
|
163
203
|
static Napi::Value GetSupportedRigs(const Napi::CallbackInfo&);
|
|
164
204
|
|
|
@@ -169,6 +209,10 @@ class NodeHamLib : public Napi::ObjectWrap<NodeHamLib> {
|
|
|
169
209
|
static Napi::Value SetDebugLevel(const Napi::CallbackInfo&);
|
|
170
210
|
static Napi::Value GetDebugLevel(const Napi::CallbackInfo&);
|
|
171
211
|
|
|
212
|
+
// Static copyright/license
|
|
213
|
+
static Napi::Value GetCopyright(const Napi::CallbackInfo&);
|
|
214
|
+
static Napi::Value GetLicense(const Napi::CallbackInfo&);
|
|
215
|
+
|
|
172
216
|
static Napi::Function GetClass(Napi::Env);
|
|
173
217
|
|
|
174
218
|
// Frequency change callback (uses basic C types via shim)
|
package/src/shim/hamlib_shim.c
CHANGED
|
@@ -43,10 +43,10 @@ SHIM_API void shim_rig_set_debug(int level) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
SHIM_API int shim_rig_get_debug(void) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return (int)
|
|
46
|
+
#ifdef SHIM_HAS_GET_DEBUG
|
|
47
|
+
enum rig_debug_level_e level;
|
|
48
|
+
rig_get_debug(&level);
|
|
49
|
+
return (int)level;
|
|
50
50
|
#else
|
|
51
51
|
return -1; /* Not available */
|
|
52
52
|
#endif
|
|
@@ -448,7 +448,7 @@ SHIM_API int shim_rig_get_split_mode(hamlib_shim_handle_t h, int vfo, int* mode,
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
SHIM_API int shim_rig_set_split_freq_mode(hamlib_shim_handle_t h, int vfo, double freq, int mode, int width) {
|
|
451
|
-
#
|
|
451
|
+
#ifdef SHIM_HAS_SPLIT_FREQ_MODE
|
|
452
452
|
return rig_set_split_freq_mode((RIG*)h, (vfo_t)vfo, (freq_t)freq, (rmode_t)mode, (pbwidth_t)width);
|
|
453
453
|
#else
|
|
454
454
|
/* Fallback: set freq and mode separately */
|
|
@@ -459,7 +459,7 @@ SHIM_API int shim_rig_set_split_freq_mode(hamlib_shim_handle_t h, int vfo, doubl
|
|
|
459
459
|
}
|
|
460
460
|
|
|
461
461
|
SHIM_API int shim_rig_get_split_freq_mode(hamlib_shim_handle_t h, int vfo, double* freq, int* mode, int* width) {
|
|
462
|
-
#
|
|
462
|
+
#ifdef SHIM_HAS_SPLIT_FREQ_MODE
|
|
463
463
|
freq_t f = 0;
|
|
464
464
|
rmode_t m = 0;
|
|
465
465
|
pbwidth_t w = 0;
|
|
@@ -712,7 +712,7 @@ SHIM_API int shim_rig_send_voice_mem(hamlib_shim_handle_t h, int vfo, int ch) {
|
|
|
712
712
|
}
|
|
713
713
|
|
|
714
714
|
SHIM_API int shim_rig_stop_voice_mem(hamlib_shim_handle_t h, int vfo) {
|
|
715
|
-
#
|
|
715
|
+
#ifdef SHIM_HAS_STOP_VOICE_MEM
|
|
716
716
|
return rig_stop_voice_mem((RIG*)h, (vfo_t)vfo);
|
|
717
717
|
#else
|
|
718
718
|
(void)h; (void)vfo;
|
|
@@ -794,9 +794,17 @@ SHIM_API int shim_rig_set_ptt_callback(hamlib_shim_handle_t h, shim_ptt_cb_t cb,
|
|
|
794
794
|
return rig_set_ptt_callback((RIG*)h, shim_ptt_cb_thunk, &ptt_cb_adapter);
|
|
795
795
|
}
|
|
796
796
|
|
|
797
|
+
/* rig_set_trn: deprecated in Hamlib 4.7.0, may be removed in future versions. */
|
|
798
|
+
#ifdef __GNUC__
|
|
799
|
+
#pragma GCC diagnostic push
|
|
800
|
+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
801
|
+
#endif
|
|
797
802
|
SHIM_API int shim_rig_set_trn(hamlib_shim_handle_t h, int trn) {
|
|
798
803
|
return rig_set_trn((RIG*)h, trn);
|
|
799
804
|
}
|
|
805
|
+
#ifdef __GNUC__
|
|
806
|
+
#pragma GCC diagnostic pop
|
|
807
|
+
#endif
|
|
800
808
|
|
|
801
809
|
/* ===== Capability queries ===== */
|
|
802
810
|
|
|
@@ -863,3 +871,299 @@ SHIM_API const char* shim_rig_type_str(int rig_type) {
|
|
|
863
871
|
default: return "Unknown";
|
|
864
872
|
}
|
|
865
873
|
}
|
|
874
|
+
|
|
875
|
+
/* ===== Lock Mode (Hamlib >= 4.7.0) ===== */
|
|
876
|
+
|
|
877
|
+
SHIM_API int shim_rig_set_lock_mode(hamlib_shim_handle_t h, int lock) {
|
|
878
|
+
#ifdef SHIM_HAS_LOCK_MODE
|
|
879
|
+
RIG *rig = (RIG *)h;
|
|
880
|
+
if (!rig) return -RIG_EINVAL;
|
|
881
|
+
return rig_set_lock_mode(rig, lock);
|
|
882
|
+
#else
|
|
883
|
+
(void)h; (void)lock;
|
|
884
|
+
return -RIG_ENIMPL;
|
|
885
|
+
#endif
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
SHIM_API int shim_rig_get_lock_mode(hamlib_shim_handle_t h, int *lock) {
|
|
889
|
+
#ifdef SHIM_HAS_LOCK_MODE
|
|
890
|
+
RIG *rig = (RIG *)h;
|
|
891
|
+
if (!rig) return -RIG_EINVAL;
|
|
892
|
+
return rig_get_lock_mode(rig, lock);
|
|
893
|
+
#else
|
|
894
|
+
(void)h; (void)lock;
|
|
895
|
+
return -RIG_ENIMPL;
|
|
896
|
+
#endif
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
/* ===== Clock (Hamlib >= 4.7.0) ===== */
|
|
900
|
+
|
|
901
|
+
SHIM_API int shim_rig_set_clock(hamlib_shim_handle_t h, int year, int month, int day,
|
|
902
|
+
int hour, int min, int sec, double msec, int utc_offset) {
|
|
903
|
+
#ifdef SHIM_HAS_CLOCK
|
|
904
|
+
RIG *rig = (RIG *)h;
|
|
905
|
+
if (!rig) return -RIG_EINVAL;
|
|
906
|
+
return rig_set_clock(rig, year, month, day, hour, min, sec, msec, utc_offset);
|
|
907
|
+
#else
|
|
908
|
+
(void)h; (void)year; (void)month; (void)day;
|
|
909
|
+
(void)hour; (void)min; (void)sec; (void)msec; (void)utc_offset;
|
|
910
|
+
return -RIG_ENIMPL;
|
|
911
|
+
#endif
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
SHIM_API int shim_rig_get_clock(hamlib_shim_handle_t h, int *year, int *month, int *day,
|
|
915
|
+
int *hour, int *min, int *sec, double *msec, int *utc_offset) {
|
|
916
|
+
#ifdef SHIM_HAS_CLOCK
|
|
917
|
+
RIG *rig = (RIG *)h;
|
|
918
|
+
if (!rig) return -RIG_EINVAL;
|
|
919
|
+
return rig_get_clock(rig, year, month, day, hour, min, sec, msec, utc_offset);
|
|
920
|
+
#else
|
|
921
|
+
(void)h; (void)year; (void)month; (void)day;
|
|
922
|
+
(void)hour; (void)min; (void)sec; (void)msec; (void)utc_offset;
|
|
923
|
+
return -RIG_ENIMPL;
|
|
924
|
+
#endif
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/* ===== VFO Info (Hamlib >= 4.7.0) ===== */
|
|
928
|
+
|
|
929
|
+
SHIM_API int shim_rig_get_vfo_info(hamlib_shim_handle_t h, int vfo,
|
|
930
|
+
double *freq, uint64_t *mode,
|
|
931
|
+
long *width, int *split, int *satmode) {
|
|
932
|
+
#ifdef SHIM_HAS_VFO_INFO
|
|
933
|
+
RIG *rig = (RIG *)h;
|
|
934
|
+
if (!rig) return -RIG_EINVAL;
|
|
935
|
+
freq_t f = 0;
|
|
936
|
+
rmode_t m = 0;
|
|
937
|
+
pbwidth_t w = 0;
|
|
938
|
+
split_t s = RIG_SPLIT_OFF;
|
|
939
|
+
int sm = 0;
|
|
940
|
+
int ret = rig_get_vfo_info(rig, (vfo_t)vfo, &f, &m, &w, &s, &sm);
|
|
941
|
+
if (freq) *freq = (double)f;
|
|
942
|
+
if (mode) *mode = (uint64_t)m;
|
|
943
|
+
if (width) *width = (long)w;
|
|
944
|
+
if (split) *split = (int)s;
|
|
945
|
+
if (satmode) *satmode = sm;
|
|
946
|
+
return ret;
|
|
947
|
+
#else
|
|
948
|
+
(void)h; (void)vfo; (void)freq; (void)mode; (void)width; (void)split; (void)satmode;
|
|
949
|
+
return -RIG_ENIMPL;
|
|
950
|
+
#endif
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/* ===== Rig info / Raw / Conf ===== */
|
|
954
|
+
|
|
955
|
+
SHIM_API const char* shim_rig_get_info(hamlib_shim_handle_t h) {
|
|
956
|
+
RIG *rig = (RIG *)h;
|
|
957
|
+
if (!rig) return "";
|
|
958
|
+
const char *info = rig_get_info(rig);
|
|
959
|
+
return info ? info : "";
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
SHIM_API int shim_rig_send_raw(hamlib_shim_handle_t h,
|
|
963
|
+
const unsigned char* send, int send_len,
|
|
964
|
+
unsigned char* reply, int reply_len, const unsigned char* term) {
|
|
965
|
+
#ifdef SHIM_HAS_SEND_RAW
|
|
966
|
+
RIG *rig = (RIG *)h;
|
|
967
|
+
if (!rig) return -RIG_EINVAL;
|
|
968
|
+
return rig_send_raw(rig, send, send_len, reply, reply_len, (unsigned char*)term);
|
|
969
|
+
#else
|
|
970
|
+
(void)h; (void)send; (void)send_len; (void)reply; (void)reply_len; (void)term;
|
|
971
|
+
return -RIG_ENIMPL;
|
|
972
|
+
#endif
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
SHIM_API int shim_rig_set_conf(hamlib_shim_handle_t h, const char* name, const char* val) {
|
|
976
|
+
RIG *rig = (RIG *)h;
|
|
977
|
+
if (!rig || !name || !val) return -RIG_EINVAL;
|
|
978
|
+
token_t token = rig_token_lookup(rig, name);
|
|
979
|
+
if (token == 0) return -RIG_EINVAL;
|
|
980
|
+
return rig_set_conf(rig, token, val);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
SHIM_API int shim_rig_get_conf(hamlib_shim_handle_t h, const char* name, char* buf, int buflen) {
|
|
984
|
+
RIG *rig = (RIG *)h;
|
|
985
|
+
if (!rig || !name || !buf || buflen <= 0) return -RIG_EINVAL;
|
|
986
|
+
token_t token = rig_token_lookup(rig, name);
|
|
987
|
+
if (token == 0) return -RIG_EINVAL;
|
|
988
|
+
#ifdef SHIM_HAS_CONF2
|
|
989
|
+
return rig_get_conf2(rig, token, buf, buflen);
|
|
990
|
+
#else
|
|
991
|
+
return rig_get_conf(rig, token, buf);
|
|
992
|
+
#endif
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/* ===== Passband / Resolution ===== */
|
|
996
|
+
|
|
997
|
+
SHIM_API int shim_rig_passband_normal(hamlib_shim_handle_t h, int mode) {
|
|
998
|
+
return (int)rig_passband_normal((RIG*)h, (rmode_t)mode);
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
SHIM_API int shim_rig_get_resolution(hamlib_shim_handle_t h, int mode) {
|
|
1002
|
+
RIG *rig = (RIG *)h;
|
|
1003
|
+
if (!rig) return 0;
|
|
1004
|
+
return (int)rig_get_resolution(rig, (rmode_t)mode);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/* ===== Capability queries (parm / vfo_ops / scan) ===== */
|
|
1008
|
+
|
|
1009
|
+
SHIM_API uint64_t shim_rig_get_caps_has_get_parm(hamlib_shim_handle_t h) {
|
|
1010
|
+
RIG *rig = (RIG *)h;
|
|
1011
|
+
return (uint64_t)(rig->caps->has_get_parm);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
SHIM_API uint64_t shim_rig_get_caps_has_set_parm(hamlib_shim_handle_t h) {
|
|
1015
|
+
RIG *rig = (RIG *)h;
|
|
1016
|
+
return (uint64_t)(rig->caps->has_set_parm);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
SHIM_API int shim_rig_get_caps_vfo_ops(hamlib_shim_handle_t h) {
|
|
1020
|
+
RIG *rig = (RIG *)h;
|
|
1021
|
+
return (int)(rig->caps->vfo_ops);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
SHIM_API int shim_rig_get_caps_has_scan(hamlib_shim_handle_t h) {
|
|
1025
|
+
RIG *rig = (RIG *)h;
|
|
1026
|
+
return (int)(rig->caps->scan_ops);
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
/* ===== Capability Query: Preamp/Attenuator/Max values ===== */
|
|
1030
|
+
|
|
1031
|
+
SHIM_API int shim_rig_get_caps_preamp(hamlib_shim_handle_t h, int* out, int max_count) {
|
|
1032
|
+
RIG *rig = (RIG *)h;
|
|
1033
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1034
|
+
int count = 0;
|
|
1035
|
+
for (int i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->caps->preamp[i] != 0 && count < max_count; i++) {
|
|
1036
|
+
out[count++] = rig->caps->preamp[i];
|
|
1037
|
+
}
|
|
1038
|
+
return count;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
SHIM_API int shim_rig_get_caps_attenuator(hamlib_shim_handle_t h, int* out, int max_count) {
|
|
1042
|
+
RIG *rig = (RIG *)h;
|
|
1043
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1044
|
+
int count = 0;
|
|
1045
|
+
for (int i = 0; i < HAMLIB_MAXDBLSTSIZ && rig->caps->attenuator[i] != 0 && count < max_count; i++) {
|
|
1046
|
+
out[count++] = rig->caps->attenuator[i];
|
|
1047
|
+
}
|
|
1048
|
+
return count;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
SHIM_API long shim_rig_get_caps_max_rit(hamlib_shim_handle_t h) {
|
|
1052
|
+
RIG *rig = (RIG *)h;
|
|
1053
|
+
if (!rig) return 0;
|
|
1054
|
+
return (long)rig->caps->max_rit;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
SHIM_API long shim_rig_get_caps_max_xit(hamlib_shim_handle_t h) {
|
|
1058
|
+
RIG *rig = (RIG *)h;
|
|
1059
|
+
if (!rig) return 0;
|
|
1060
|
+
return (long)rig->caps->max_xit;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
SHIM_API long shim_rig_get_caps_max_ifshift(hamlib_shim_handle_t h) {
|
|
1064
|
+
RIG *rig = (RIG *)h;
|
|
1065
|
+
if (!rig) return 0;
|
|
1066
|
+
return (long)rig->caps->max_ifshift;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/* ===== Capability Query: CTCSS/DCS lists ===== */
|
|
1070
|
+
|
|
1071
|
+
SHIM_API int shim_rig_get_caps_ctcss_list(hamlib_shim_handle_t h, unsigned int* out, int max_count) {
|
|
1072
|
+
RIG *rig = (RIG *)h;
|
|
1073
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1074
|
+
if (!rig->caps->ctcss_list) return 0;
|
|
1075
|
+
int count = 0;
|
|
1076
|
+
for (int i = 0; rig->caps->ctcss_list[i] != 0 && count < max_count; i++) {
|
|
1077
|
+
out[count++] = rig->caps->ctcss_list[i];
|
|
1078
|
+
}
|
|
1079
|
+
return count;
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
SHIM_API int shim_rig_get_caps_dcs_list(hamlib_shim_handle_t h, unsigned int* out, int max_count) {
|
|
1083
|
+
RIG *rig = (RIG *)h;
|
|
1084
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1085
|
+
if (!rig->caps->dcs_list) return 0;
|
|
1086
|
+
int count = 0;
|
|
1087
|
+
for (int i = 0; rig->caps->dcs_list[i] != 0 && count < max_count; i++) {
|
|
1088
|
+
out[count++] = rig->caps->dcs_list[i];
|
|
1089
|
+
}
|
|
1090
|
+
return count;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/* ===== Capability Query: Frequency ranges ===== */
|
|
1094
|
+
|
|
1095
|
+
SHIM_API int shim_rig_get_caps_rx_range(hamlib_shim_handle_t h, shim_freq_range_t* out, int max_count) {
|
|
1096
|
+
RIG *rig = (RIG *)h;
|
|
1097
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1098
|
+
int count = 0;
|
|
1099
|
+
for (int i = 0; i < HAMLIB_FRQRANGESIZ && count < max_count; i++) {
|
|
1100
|
+
const freq_range_t *r = &rig->caps->rx_range_list1[i];
|
|
1101
|
+
if (r->startf == 0 && r->endf == 0) break;
|
|
1102
|
+
out[count].start_freq = (double)r->startf;
|
|
1103
|
+
out[count].end_freq = (double)r->endf;
|
|
1104
|
+
out[count].modes = (uint64_t)r->modes;
|
|
1105
|
+
out[count].low_power = (int)r->low_power;
|
|
1106
|
+
out[count].high_power = (int)r->high_power;
|
|
1107
|
+
out[count].vfo = (int)r->vfo;
|
|
1108
|
+
out[count].ant = (int)r->ant;
|
|
1109
|
+
count++;
|
|
1110
|
+
}
|
|
1111
|
+
return count;
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
SHIM_API int shim_rig_get_caps_tx_range(hamlib_shim_handle_t h, shim_freq_range_t* out, int max_count) {
|
|
1115
|
+
RIG *rig = (RIG *)h;
|
|
1116
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1117
|
+
int count = 0;
|
|
1118
|
+
for (int i = 0; i < HAMLIB_FRQRANGESIZ && count < max_count; i++) {
|
|
1119
|
+
const freq_range_t *r = &rig->caps->tx_range_list1[i];
|
|
1120
|
+
if (r->startf == 0 && r->endf == 0) break;
|
|
1121
|
+
out[count].start_freq = (double)r->startf;
|
|
1122
|
+
out[count].end_freq = (double)r->endf;
|
|
1123
|
+
out[count].modes = (uint64_t)r->modes;
|
|
1124
|
+
out[count].low_power = (int)r->low_power;
|
|
1125
|
+
out[count].high_power = (int)r->high_power;
|
|
1126
|
+
out[count].vfo = (int)r->vfo;
|
|
1127
|
+
out[count].ant = (int)r->ant;
|
|
1128
|
+
count++;
|
|
1129
|
+
}
|
|
1130
|
+
return count;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/* ===== Capability Query: Tuning steps / Filters ===== */
|
|
1134
|
+
|
|
1135
|
+
SHIM_API int shim_rig_get_caps_tuning_steps(hamlib_shim_handle_t h, shim_mode_value_t* out, int max_count) {
|
|
1136
|
+
RIG *rig = (RIG *)h;
|
|
1137
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1138
|
+
int count = 0;
|
|
1139
|
+
for (int i = 0; i < HAMLIB_TSLSTSIZ && count < max_count; i++) {
|
|
1140
|
+
if (rig->caps->tuning_steps[i].modes == 0) break;
|
|
1141
|
+
out[count].modes = (uint64_t)rig->caps->tuning_steps[i].modes;
|
|
1142
|
+
out[count].value = (int)rig->caps->tuning_steps[i].ts;
|
|
1143
|
+
count++;
|
|
1144
|
+
}
|
|
1145
|
+
return count;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
SHIM_API int shim_rig_get_caps_filters(hamlib_shim_handle_t h, shim_mode_value_t* out, int max_count) {
|
|
1149
|
+
RIG *rig = (RIG *)h;
|
|
1150
|
+
if (!rig || !out || max_count <= 0) return 0;
|
|
1151
|
+
int count = 0;
|
|
1152
|
+
for (int i = 0; i < HAMLIB_FLTLSTSIZ && count < max_count; i++) {
|
|
1153
|
+
if (rig->caps->filters[i].modes == 0) break;
|
|
1154
|
+
out[count].modes = (uint64_t)rig->caps->filters[i].modes;
|
|
1155
|
+
out[count].value = (int)rig->caps->filters[i].width;
|
|
1156
|
+
count++;
|
|
1157
|
+
}
|
|
1158
|
+
return count;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/* ===== Static info ===== */
|
|
1162
|
+
|
|
1163
|
+
SHIM_API const char* shim_rig_copyright(void) {
|
|
1164
|
+
return rig_copyright();
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
SHIM_API const char* shim_rig_license(void) {
|
|
1168
|
+
return rig_license();
|
|
1169
|
+
}
|
package/src/shim/hamlib_shim.h
CHANGED
|
@@ -71,9 +71,10 @@ typedef void* hamlib_shim_handle_t;
|
|
|
71
71
|
/* Passband constants */
|
|
72
72
|
#define SHIM_RIG_PASSBAND_NORMAL 0
|
|
73
73
|
|
|
74
|
-
/* Port types */
|
|
75
|
-
#define
|
|
76
|
-
#define
|
|
74
|
+
/* Port types (must match hamlib rig_port_e enum) */
|
|
75
|
+
#define SHIM_RIG_PORT_NONE 0
|
|
76
|
+
#define SHIM_RIG_PORT_SERIAL 1
|
|
77
|
+
#define SHIM_RIG_PORT_NETWORK 2
|
|
77
78
|
|
|
78
79
|
/* Scan types */
|
|
79
80
|
#define SHIM_RIG_SCAN_STOP 0
|
|
@@ -83,6 +84,16 @@ typedef void* hamlib_shim_handle_t;
|
|
|
83
84
|
#define SHIM_RIG_SCAN_DELTA (1<<3)
|
|
84
85
|
#define SHIM_RIG_SCAN_PRIO (1<<4)
|
|
85
86
|
|
|
87
|
+
/* Parm constants (bit positions for setting_t / uint64_t) */
|
|
88
|
+
#define SHIM_RIG_PARM_ANN (1ULL << 0)
|
|
89
|
+
#define SHIM_RIG_PARM_APO (1ULL << 1)
|
|
90
|
+
#define SHIM_RIG_PARM_BACKLIGHT (1ULL << 2)
|
|
91
|
+
#define SHIM_RIG_PARM_BEEP (1ULL << 4)
|
|
92
|
+
#define SHIM_RIG_PARM_TIME (1ULL << 5)
|
|
93
|
+
#define SHIM_RIG_PARM_BAT (1ULL << 6)
|
|
94
|
+
#define SHIM_RIG_PARM_KEYLIGHT (1ULL << 7)
|
|
95
|
+
#define SHIM_RIG_PARM_SCREENSAVER (1ULL << 8)
|
|
96
|
+
|
|
86
97
|
/* Transceive mode */
|
|
87
98
|
#define SHIM_RIG_TRN_POLL 1
|
|
88
99
|
|
|
@@ -504,6 +515,86 @@ SHIM_API int shim_rig_sprintf_mode(uint64_t modes, char* buf, int buflen);
|
|
|
504
515
|
/* Rig type to string conversion */
|
|
505
516
|
SHIM_API const char* shim_rig_type_str(int rig_type);
|
|
506
517
|
|
|
518
|
+
/* ===== Capability Query: Structured data types ===== */
|
|
519
|
+
|
|
520
|
+
/* ABI-safe struct for frequency range (no Hamlib types cross boundary) */
|
|
521
|
+
typedef struct {
|
|
522
|
+
double start_freq; /* Hz */
|
|
523
|
+
double end_freq; /* Hz */
|
|
524
|
+
uint64_t modes; /* rmode_t bitmask */
|
|
525
|
+
int low_power; /* mW */
|
|
526
|
+
int high_power; /* mW */
|
|
527
|
+
int vfo; /* vfo_t */
|
|
528
|
+
int ant; /* ant_t */
|
|
529
|
+
} shim_freq_range_t;
|
|
530
|
+
|
|
531
|
+
/* ABI-safe struct for tuning step / filter */
|
|
532
|
+
typedef struct {
|
|
533
|
+
uint64_t modes; /* rmode_t bitmask */
|
|
534
|
+
int value; /* step Hz or filter width Hz */
|
|
535
|
+
} shim_mode_value_t;
|
|
536
|
+
|
|
537
|
+
/* Group A: Simple value queries */
|
|
538
|
+
SHIM_API int shim_rig_get_caps_preamp(hamlib_shim_handle_t h, int* out, int max_count);
|
|
539
|
+
SHIM_API int shim_rig_get_caps_attenuator(hamlib_shim_handle_t h, int* out, int max_count);
|
|
540
|
+
SHIM_API long shim_rig_get_caps_max_rit(hamlib_shim_handle_t h);
|
|
541
|
+
SHIM_API long shim_rig_get_caps_max_xit(hamlib_shim_handle_t h);
|
|
542
|
+
SHIM_API long shim_rig_get_caps_max_ifshift(hamlib_shim_handle_t h);
|
|
543
|
+
|
|
544
|
+
/* Group B: Tone/code lists */
|
|
545
|
+
SHIM_API int shim_rig_get_caps_ctcss_list(hamlib_shim_handle_t h, unsigned int* out, int max_count);
|
|
546
|
+
SHIM_API int shim_rig_get_caps_dcs_list(hamlib_shim_handle_t h, unsigned int* out, int max_count);
|
|
547
|
+
|
|
548
|
+
/* Group C: Structured data */
|
|
549
|
+
SHIM_API int shim_rig_get_caps_rx_range(hamlib_shim_handle_t h, shim_freq_range_t* out, int max_count);
|
|
550
|
+
SHIM_API int shim_rig_get_caps_tx_range(hamlib_shim_handle_t h, shim_freq_range_t* out, int max_count);
|
|
551
|
+
SHIM_API int shim_rig_get_caps_tuning_steps(hamlib_shim_handle_t h, shim_mode_value_t* out, int max_count);
|
|
552
|
+
SHIM_API int shim_rig_get_caps_filters(hamlib_shim_handle_t h, shim_mode_value_t* out, int max_count);
|
|
553
|
+
|
|
554
|
+
/* ===== Lock Mode (Hamlib >= 4.7.0) ===== */
|
|
555
|
+
|
|
556
|
+
SHIM_API int shim_rig_set_lock_mode(hamlib_shim_handle_t h, int lock);
|
|
557
|
+
SHIM_API int shim_rig_get_lock_mode(hamlib_shim_handle_t h, int *lock);
|
|
558
|
+
|
|
559
|
+
/* ===== Clock (Hamlib >= 4.7.0) ===== */
|
|
560
|
+
|
|
561
|
+
SHIM_API int shim_rig_set_clock(hamlib_shim_handle_t h, int year, int month, int day,
|
|
562
|
+
int hour, int min, int sec, double msec, int utc_offset);
|
|
563
|
+
SHIM_API int shim_rig_get_clock(hamlib_shim_handle_t h, int *year, int *month, int *day,
|
|
564
|
+
int *hour, int *min, int *sec, double *msec, int *utc_offset);
|
|
565
|
+
|
|
566
|
+
/* ===== VFO Info (Hamlib >= 4.7.0) ===== */
|
|
567
|
+
|
|
568
|
+
SHIM_API int shim_rig_get_vfo_info(hamlib_shim_handle_t h, int vfo,
|
|
569
|
+
double *freq, uint64_t *mode,
|
|
570
|
+
long *width, int *split, int *satmode);
|
|
571
|
+
|
|
572
|
+
/* ===== Rig info / Raw / Conf ===== */
|
|
573
|
+
|
|
574
|
+
SHIM_API const char* shim_rig_get_info(hamlib_shim_handle_t h);
|
|
575
|
+
SHIM_API int shim_rig_send_raw(hamlib_shim_handle_t h,
|
|
576
|
+
const unsigned char* send, int send_len,
|
|
577
|
+
unsigned char* reply, int reply_len, const unsigned char* term);
|
|
578
|
+
SHIM_API int shim_rig_set_conf(hamlib_shim_handle_t h, const char* name, const char* val);
|
|
579
|
+
SHIM_API int shim_rig_get_conf(hamlib_shim_handle_t h, const char* name, char* buf, int buflen);
|
|
580
|
+
|
|
581
|
+
/* ===== Passband / Resolution ===== */
|
|
582
|
+
|
|
583
|
+
SHIM_API int shim_rig_passband_normal(hamlib_shim_handle_t h, int mode);
|
|
584
|
+
SHIM_API int shim_rig_get_resolution(hamlib_shim_handle_t h, int mode);
|
|
585
|
+
|
|
586
|
+
/* ===== Capability queries (parm / vfo_ops / scan) ===== */
|
|
587
|
+
|
|
588
|
+
SHIM_API uint64_t shim_rig_get_caps_has_get_parm(hamlib_shim_handle_t h);
|
|
589
|
+
SHIM_API uint64_t shim_rig_get_caps_has_set_parm(hamlib_shim_handle_t h);
|
|
590
|
+
SHIM_API int shim_rig_get_caps_vfo_ops(hamlib_shim_handle_t h);
|
|
591
|
+
SHIM_API int shim_rig_get_caps_has_scan(hamlib_shim_handle_t h);
|
|
592
|
+
|
|
593
|
+
/* ===== Static info ===== */
|
|
594
|
+
|
|
595
|
+
SHIM_API const char* shim_rig_copyright(void);
|
|
596
|
+
SHIM_API const char* shim_rig_license(void);
|
|
597
|
+
|
|
507
598
|
#ifdef __cplusplus
|
|
508
599
|
}
|
|
509
600
|
#endif
|