hamlib 0.2.6 → 0.3.0

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.
@@ -837,9 +837,15 @@ struct shim_ptt_cb_adapter {
837
837
  void* user_arg;
838
838
  };
839
839
 
840
+ struct shim_spectrum_cb_adapter {
841
+ shim_spectrum_cb_t user_cb;
842
+ void* user_arg;
843
+ };
844
+
840
845
  /* We store adapters statically (one per rig handle - simplified) */
841
846
  static struct shim_freq_cb_adapter freq_cb_adapter = {NULL, NULL};
842
847
  static struct shim_ptt_cb_adapter ptt_cb_adapter = {NULL, NULL};
848
+ static struct shim_spectrum_cb_adapter spectrum_cb_adapter = {NULL, NULL};
843
849
 
844
850
  static int shim_freq_cb_thunk(RIG *rig, vfo_t vfo, freq_t freq, rig_ptr_t arg) {
845
851
  struct shim_freq_cb_adapter *adapter = (struct shim_freq_cb_adapter*)arg;
@@ -857,6 +863,33 @@ static int shim_ptt_cb_thunk(RIG *rig, vfo_t vfo, ptt_t ptt, rig_ptr_t arg) {
857
863
  return 0;
858
864
  }
859
865
 
866
+ static int shim_spectrum_cb_thunk(RIG *rig, struct rig_spectrum_line *line, rig_ptr_t arg) {
867
+ struct shim_spectrum_cb_adapter *adapter = (struct shim_spectrum_cb_adapter*)arg;
868
+ shim_spectrum_line_t safe_line;
869
+
870
+ if (!adapter || !adapter->user_cb || !line) {
871
+ return 0;
872
+ }
873
+
874
+ memset(&safe_line, 0, sizeof(safe_line));
875
+ safe_line.id = line->id;
876
+ safe_line.data_level_min = line->data_level_min;
877
+ safe_line.data_level_max = line->data_level_max;
878
+ safe_line.signal_strength_min = line->signal_strength_min;
879
+ safe_line.signal_strength_max = line->signal_strength_max;
880
+ safe_line.spectrum_mode = (int)line->spectrum_mode;
881
+ safe_line.center_freq = (double)line->center_freq;
882
+ safe_line.span_freq = (double)line->span_freq;
883
+ safe_line.low_edge_freq = (double)line->low_edge_freq;
884
+ safe_line.high_edge_freq = (double)line->high_edge_freq;
885
+ safe_line.data_length = (int)((line->spectrum_data_length > sizeof(safe_line.data)) ? sizeof(safe_line.data) : line->spectrum_data_length);
886
+ if (safe_line.data_length > 0 && line->spectrum_data) {
887
+ memcpy(safe_line.data, line->spectrum_data, (size_t)safe_line.data_length);
888
+ }
889
+
890
+ return adapter->user_cb((void*)rig, &safe_line, adapter->user_arg);
891
+ }
892
+
860
893
  SHIM_API int shim_rig_set_freq_callback(hamlib_shim_handle_t h, shim_freq_cb_t cb, void* arg) {
861
894
  freq_cb_adapter.user_cb = cb;
862
895
  freq_cb_adapter.user_arg = arg;
@@ -869,6 +902,12 @@ SHIM_API int shim_rig_set_ptt_callback(hamlib_shim_handle_t h, shim_ptt_cb_t cb,
869
902
  return rig_set_ptt_callback((RIG*)h, shim_ptt_cb_thunk, &ptt_cb_adapter);
870
903
  }
871
904
 
905
+ SHIM_API int shim_rig_set_spectrum_callback(hamlib_shim_handle_t h, shim_spectrum_cb_t cb, void* arg) {
906
+ spectrum_cb_adapter.user_cb = cb;
907
+ spectrum_cb_adapter.user_arg = arg;
908
+ return rig_set_spectrum_callback((RIG*)h, cb ? shim_spectrum_cb_thunk : NULL, cb ? &spectrum_cb_adapter : NULL);
909
+ }
910
+
872
911
  /* rig_set_trn: deprecated in Hamlib 4.7.0, may be removed in future versions. */
873
912
  #ifdef __GNUC__
874
913
  #pragma GCC diagnostic push
@@ -908,6 +947,92 @@ SHIM_API uint64_t shim_rig_get_caps_has_set_func(hamlib_shim_handle_t h) {
908
947
  return (uint64_t)(rig->caps->has_set_func);
909
948
  }
910
949
 
950
+ SHIM_API int shim_rig_is_async_data_supported(hamlib_shim_handle_t h) {
951
+ RIG* rig = (RIG*)h;
952
+ if (!rig || !rig->caps) return 0;
953
+ return rig->caps->async_data_supported ? 1 : 0;
954
+ }
955
+
956
+ SHIM_API int shim_rig_get_caps_spectrum_scope_count(hamlib_shim_handle_t h) {
957
+ int count = 0;
958
+ RIG* rig = (RIG*)h;
959
+ if (!rig || !rig->caps) return 0;
960
+ while (count < HAMLIB_MAX_SPECTRUM_SCOPES && rig->caps->spectrum_scopes[count].name) {
961
+ count++;
962
+ }
963
+ return count;
964
+ }
965
+
966
+ SHIM_API int shim_rig_get_caps_spectrum_scope(hamlib_shim_handle_t h, int index, shim_spectrum_scope_t* out) {
967
+ RIG* rig = (RIG*)h;
968
+ if (!rig || !rig->caps || !out || index < 0 || index >= HAMLIB_MAX_SPECTRUM_SCOPES) return -RIG_EINVAL;
969
+ if (!rig->caps->spectrum_scopes[index].name) return -RIG_ENAVAIL;
970
+ memset(out, 0, sizeof(*out));
971
+ out->id = rig->caps->spectrum_scopes[index].id;
972
+ strncpy(out->name, rig->caps->spectrum_scopes[index].name, sizeof(out->name) - 1);
973
+ return RIG_OK;
974
+ }
975
+
976
+ SHIM_API int shim_rig_get_caps_spectrum_mode_count(hamlib_shim_handle_t h) {
977
+ int count = 0;
978
+ RIG* rig = (RIG*)h;
979
+ if (!rig || !rig->caps) return 0;
980
+ while (count < HAMLIB_MAX_SPECTRUM_MODES && rig->caps->spectrum_modes[count] != RIG_SPECTRUM_MODE_NONE) {
981
+ count++;
982
+ }
983
+ return count;
984
+ }
985
+
986
+ SHIM_API int shim_rig_get_caps_spectrum_mode(hamlib_shim_handle_t h, int index, int* out) {
987
+ RIG* rig = (RIG*)h;
988
+ if (!rig || !rig->caps || !out || index < 0 || index >= HAMLIB_MAX_SPECTRUM_MODES) return -RIG_EINVAL;
989
+ if (rig->caps->spectrum_modes[index] == RIG_SPECTRUM_MODE_NONE) return -RIG_ENAVAIL;
990
+ *out = (int)rig->caps->spectrum_modes[index];
991
+ return RIG_OK;
992
+ }
993
+
994
+ SHIM_API int shim_rig_get_caps_spectrum_span_count(hamlib_shim_handle_t h) {
995
+ int count = 0;
996
+ RIG* rig = (RIG*)h;
997
+ if (!rig || !rig->caps) return 0;
998
+ while (count < HAMLIB_MAX_SPECTRUM_SPANS && rig->caps->spectrum_spans[count] != 0) {
999
+ count++;
1000
+ }
1001
+ return count;
1002
+ }
1003
+
1004
+ SHIM_API int shim_rig_get_caps_spectrum_span(hamlib_shim_handle_t h, int index, double* out) {
1005
+ RIG* rig = (RIG*)h;
1006
+ if (!rig || !rig->caps || !out || index < 0 || index >= HAMLIB_MAX_SPECTRUM_SPANS) return -RIG_EINVAL;
1007
+ if (rig->caps->spectrum_spans[index] == 0) return -RIG_ENAVAIL;
1008
+ *out = (double)rig->caps->spectrum_spans[index];
1009
+ return RIG_OK;
1010
+ }
1011
+
1012
+ SHIM_API int shim_rig_get_caps_spectrum_avg_mode_count(hamlib_shim_handle_t h) {
1013
+ int count = 0;
1014
+ RIG* rig = (RIG*)h;
1015
+ if (!rig || !rig->caps) return 0;
1016
+ while (count < HAMLIB_MAX_SPECTRUM_AVG_MODES && rig->caps->spectrum_avg_modes[count].name) {
1017
+ count++;
1018
+ }
1019
+ return count;
1020
+ }
1021
+
1022
+ SHIM_API int shim_rig_get_caps_spectrum_avg_mode(hamlib_shim_handle_t h, int index, shim_spectrum_avg_mode_t* out) {
1023
+ RIG* rig = (RIG*)h;
1024
+ if (!rig || !rig->caps || !out || index < 0 || index >= HAMLIB_MAX_SPECTRUM_AVG_MODES) return -RIG_EINVAL;
1025
+ if (!rig->caps->spectrum_avg_modes[index].name) return -RIG_ENAVAIL;
1026
+ memset(out, 0, sizeof(*out));
1027
+ out->id = rig->caps->spectrum_avg_modes[index].id;
1028
+ strncpy(out->name, rig->caps->spectrum_avg_modes[index].name, sizeof(out->name) - 1);
1029
+ return RIG_OK;
1030
+ }
1031
+
1032
+ SHIM_API const char* shim_rig_str_spectrum_mode(int mode) {
1033
+ return rig_strspectrummode((enum rig_spectrum_mode_e)mode);
1034
+ }
1035
+
911
1036
  SHIM_API int shim_rig_sprintf_mode(uint64_t modes, char* buf, int buflen) {
912
1037
  if (!buf || buflen <= 0) return 0;
913
1038
  buf[0] = '\0';
@@ -199,6 +199,14 @@ typedef void* hamlib_shim_handle_t;
199
199
  #define SHIM_RIG_LEVEL_MONITOR_GAIN (1ULL << 37)
200
200
  #define SHIM_RIG_LEVEL_NB (1ULL << 38)
201
201
  #define SHIM_RIG_LEVEL_RFPOWER_METER_WATTS (1ULL << 39)
202
+ #define SHIM_RIG_LEVEL_SPECTRUM_MODE (1ULL << 40)
203
+ #define SHIM_RIG_LEVEL_SPECTRUM_SPAN (1ULL << 41)
204
+ #define SHIM_RIG_LEVEL_SPECTRUM_EDGE_LOW (1ULL << 42)
205
+ #define SHIM_RIG_LEVEL_SPECTRUM_EDGE_HIGH (1ULL << 43)
206
+ #define SHIM_RIG_LEVEL_SPECTRUM_SPEED (1ULL << 44)
207
+ #define SHIM_RIG_LEVEL_SPECTRUM_REF (1ULL << 45)
208
+ #define SHIM_RIG_LEVEL_SPECTRUM_AVG (1ULL << 46)
209
+ #define SHIM_RIG_LEVEL_SPECTRUM_ATT (1ULL << 47)
202
210
  #define SHIM_RIG_LEVEL_TEMP_METER (1ULL << 48)
203
211
 
204
212
  /* ===== Function constants (bit positions for setting_t / uint64_t) ===== */
@@ -234,6 +242,12 @@ typedef void* hamlib_shim_handle_t;
234
242
  #define SHIM_RIG_FUNC_TBURST (1ULL << 29)
235
243
  #define SHIM_RIG_FUNC_TUNER (1ULL << 30)
236
244
  #define SHIM_RIG_FUNC_XIT (1ULL << 31)
245
+ #define SHIM_RIG_FUNC_TRANSCEIVE (1ULL << 42)
246
+ #define SHIM_RIG_FUNC_SPECTRUM (1ULL << 43)
247
+ #define SHIM_RIG_FUNC_SPECTRUM_HOLD (1ULL << 44)
248
+ #define SHIM_RIG_FUNC_SEND_MORSE (1ULL << 45)
249
+ #define SHIM_RIG_FUNC_SEND_VOICE_MEM (1ULL << 46)
250
+ #define SHIM_RIG_FUNC_OVF_STATUS (1ULL << 47)
237
251
 
238
252
  /* ===== VFO operation constants ===== */
239
253
  #define SHIM_RIG_OP_CPY (1<<0)
@@ -279,6 +293,31 @@ typedef struct {
279
293
  int rig_type;
280
294
  } shim_rig_info_t;
281
295
 
296
+ typedef struct {
297
+ int id;
298
+ char name[64];
299
+ } shim_spectrum_scope_t;
300
+
301
+ typedef struct {
302
+ int id;
303
+ char name[64];
304
+ } shim_spectrum_avg_mode_t;
305
+
306
+ typedef struct {
307
+ int id;
308
+ int data_level_min;
309
+ int data_level_max;
310
+ double signal_strength_min;
311
+ double signal_strength_max;
312
+ int spectrum_mode;
313
+ double center_freq;
314
+ double span_freq;
315
+ double low_edge_freq;
316
+ double high_edge_freq;
317
+ int data_length;
318
+ unsigned char data[2048];
319
+ } shim_spectrum_line_t;
320
+
282
321
  /* ===== Callback types ===== */
283
322
 
284
323
  /* Frequency change callback: (handle, vfo, freq, arg) -> int */
@@ -287,6 +326,9 @@ typedef int (*shim_freq_cb_t)(void* handle, int vfo, double freq, void* arg);
287
326
  /* PTT change callback: (handle, vfo, ptt, arg) -> int */
288
327
  typedef int (*shim_ptt_cb_t)(void* handle, int vfo, int ptt, void* arg);
289
328
 
329
+ /* Spectrum line callback: (handle, line, arg) -> int */
330
+ typedef int (*shim_spectrum_cb_t)(void* handle, const shim_spectrum_line_t* line, void* arg);
331
+
290
332
  /* Rig list callback: (info, data) -> int */
291
333
  typedef int (*shim_rig_list_cb_t)(const shim_rig_info_t* info, void* data);
292
334
 
@@ -510,6 +552,7 @@ SHIM_API int shim_rig_reset(hamlib_shim_handle_t h, int reset_type);
510
552
 
511
553
  SHIM_API int shim_rig_set_freq_callback(hamlib_shim_handle_t h, shim_freq_cb_t cb, void* arg);
512
554
  SHIM_API int shim_rig_set_ptt_callback(hamlib_shim_handle_t h, shim_ptt_cb_t cb, void* arg);
555
+ SHIM_API int shim_rig_set_spectrum_callback(hamlib_shim_handle_t h, shim_spectrum_cb_t cb, void* arg);
513
556
  SHIM_API int shim_rig_set_trn(hamlib_shim_handle_t h, int trn);
514
557
 
515
558
  /* ===== Capability queries (replaces direct caps-> access) ===== */
@@ -519,6 +562,16 @@ SHIM_API uint64_t shim_rig_get_caps_has_get_level(hamlib_shim_handle_t h);
519
562
  SHIM_API uint64_t shim_rig_get_caps_has_set_level(hamlib_shim_handle_t h);
520
563
  SHIM_API uint64_t shim_rig_get_caps_has_get_func(hamlib_shim_handle_t h);
521
564
  SHIM_API uint64_t shim_rig_get_caps_has_set_func(hamlib_shim_handle_t h);
565
+ SHIM_API int shim_rig_is_async_data_supported(hamlib_shim_handle_t h);
566
+ SHIM_API int shim_rig_get_caps_spectrum_scope_count(hamlib_shim_handle_t h);
567
+ SHIM_API int shim_rig_get_caps_spectrum_scope(hamlib_shim_handle_t h, int index, shim_spectrum_scope_t* out);
568
+ SHIM_API int shim_rig_get_caps_spectrum_mode_count(hamlib_shim_handle_t h);
569
+ SHIM_API int shim_rig_get_caps_spectrum_mode(hamlib_shim_handle_t h, int index, int* out);
570
+ SHIM_API int shim_rig_get_caps_spectrum_span_count(hamlib_shim_handle_t h);
571
+ SHIM_API int shim_rig_get_caps_spectrum_span(hamlib_shim_handle_t h, int index, double* out);
572
+ SHIM_API int shim_rig_get_caps_spectrum_avg_mode_count(hamlib_shim_handle_t h);
573
+ SHIM_API int shim_rig_get_caps_spectrum_avg_mode(hamlib_shim_handle_t h, int index, shim_spectrum_avg_mode_t* out);
574
+ SHIM_API const char* shim_rig_str_spectrum_mode(int mode);
522
575
 
523
576
  /* Format mode bitmask to string list */
524
577
  SHIM_API int shim_rig_sprintf_mode(uint64_t modes, char* buf, int buflen);