forked from Hamlib/Hamlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rig.h
3898 lines (3392 loc) · 162 KB
/
rig.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Hamlib Interface - API header
* Copyright (c) 2000-2003 by Frank Singleton
* Copyright (c) 2000-2012 by Stephane Fillod
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#ifndef _RIG_H
#define _RIG_H 1
// as of 2023-11-23 rig_caps is no longer constant
// this #define allows clients to test which declaration to use for backwards compatibility
#define RIGCAPS_NOT_CONST 1
#define BUILTINFUNC 0
// Our shared secret password
#define HAMLIB_SECRET_LENGTH 32
#define HAMLIB_TRACE rig_debug(RIG_DEBUG_TRACE,"%s%s(%d) trace\n",spaces(STATE(rig)->depth), __FILE__, __LINE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <time.h>
// to stop warnings about including winsock2.h before windows.h
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
// mingw64 still shows __TIMESIZE != 64
// need to do more testing
#if 0
#if __TIMESIZE != 64
#warning TIMESIZE != 64 -- Please report your OS system to hamlib-developer@lists.sourceforge.net
#endif
#endif
// For MSVC install the NUGet pthread package
#if defined(_MSC_VER)
#define HAVE_STRUCT_TIMESPEC
#endif
#include <pthread.h>
/* Rig list is in a separate file so as not to mess up w/ this one */
#include <hamlib/riglist.h>
//#include <hamlib/config.h>
/**
* \addtogroup rig
* @{
*/
/*! \file rig.h
* \brief Hamlib rig data structures.
*
* This file contains the data structures and definitions for the Hamlib rig API.
* see the rig.c file for more details on the rig API.
*/
/* __BEGIN_DECLS should be used at the beginning of your declarations,
* so that C++ compilers don't mangle their names. Use __END_DECLS at
* the end of C declarations. */
//! @cond Doxygen_Suppress
#undef __BEGIN_DECLS
#undef __END_DECLS
#ifdef __cplusplus
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
#else
# define __BEGIN_DECLS /* empty */
# define __END_DECLS /* empty */
#endif
//! @endcond
/* HAMLIB_PARAMS is a macro used to wrap function prototypes, so that compilers
* that don't understand ANSI C prototypes still work, and ANSI C
* compilers can issue warnings about type mismatches. */
//! @cond Doxygen_Suppress
#undef HAMLIB_PARAMS
#if defined (__STDC__) \
|| defined (_AIX) \
|| (defined (__mips) && defined (_SYSTYPE_SVR4)) \
|| defined(__CYGWIN__) \
|| defined(_WIN32) \
|| defined(__cplusplus)
# define HAMLIB_PARAMS(protos) protos
# define rig_ptr_t void *
# define amp_ptr_t void *
#else
# define HAMLIB_PARAMS(protos) ()
# define rig_ptr_t char *
# define amp_ptr_t char *
#endif
//! @endcond
#include <hamlib/rig_dll.h>
#ifndef SWIGLUA
//! @cond Doxygen_Suppress
#define CONSTANT_64BIT_FLAG(BIT) (1ull << (BIT))
//! @endcond
#else
/* SWIG's older Lua generator doesn't grok ull due to Lua using a
double-precision floating point type internally for number
representations (max 53 bits of precision) so makes a string
constant from a constant number literal using ull */
// #define CONSTANT_64BIT_FLAG(BIT) (1 << (BIT))
// #define SWIGLUAHIDE
/* But this appears to have been fixed so we'll use the correct one now
If you have the older version of SWIG comment out this line and use
the two above */
// This 1ul definition works on swig 4.0.1 and lua 5.3.5
#define CONSTANT_64BIT_FLAG(BIT) (1ul << (BIT))
#endif
__BEGIN_DECLS
// FIFO currently used for send_morse queue
#define HAMLIB_FIFO_SIZE 1024
typedef struct
{
char data[HAMLIB_FIFO_SIZE];
int head;
int tail;
int flush; // flush flag for stop_morse
#ifdef _PTHREAD_H
pthread_mutex_t mutex;
#else
int mutex;
#endif
} FIFO_RIG;
/**
* \brief size of cookie request buffer
* Minimum size of cookie buffer to pass to rig_cookie
*/
// cookie is 26-char time code plus 10-char (2^31-1) random number
#define HAMLIB_COOKIE_SIZE 37
extern int cookie_use; // this is global as once one client requests it everybody needs to honor it
extern int skip_init; // allow rigctl to skip any radio commands at startup
//! @cond Doxygen_Suppress
extern HAMLIB_EXPORT_VAR(const char) hamlib_version[];
extern HAMLIB_EXPORT_VAR(const char) hamlib_copyright[];
extern HAMLIB_EXPORT_VAR(const char *) hamlib_version2;
extern HAMLIB_EXPORT_VAR(const char *) hamlib_copyright2;
//! @endcond
/**
* \brief Hamlib error codes
* Error code definition that can be returned by the Hamlib functions.
* Unless stated otherwise, Hamlib functions return the negative value
* of rig_errcode_e definitions in case of error, or 0 when successful.
*/
/**
* @{ \name Hamlib error codes
*/
enum rig_errcode_e {
RIG_OK = 0, /*!< 0 No error, operation completed successfully */
RIG_EINVAL, /*!< 1 invalid parameter */
RIG_ECONF, /*!< 2 invalid configuration (serial,..) */
RIG_ENOMEM, /*!< 3 memory shortage */
RIG_ENIMPL, /*!< 4 function not implemented, but will be */
RIG_ETIMEOUT, /*!< 5 communication timed out */
RIG_EIO, /*!< 6 IO error, including open failed */
RIG_EINTERNAL, /*!< 7 Internal Hamlib error, huh! */
RIG_EPROTO, /*!< 8 Protocol error */
RIG_ERJCTED, /*!< 9 Command rejected by the rig */
RIG_ETRUNC, /*!< 10 Command performed, but arg truncated */
RIG_ENAVAIL, /*!< 11 Function not available */
RIG_ENTARGET, /*!< 12 VFO not targetable */
RIG_BUSERROR, /*!< 13 Error talking on the bus */
RIG_BUSBUSY, /*!< 14 Collision on the bus */
RIG_EARG, /*!< 15 NULL RIG handle or any invalid pointer parameter in get arg */
RIG_EVFO, /*!< 16 Invalid VFO */
RIG_EDOM, /*!< 17 Argument out of domain of func */
RIG_EDEPRECATED,/*!< 18 Function deprecated */
RIG_ESECURITY, /*!< 19 Security error */
RIG_EPOWER, /*!< 20 Rig not powered on */
RIG_ELIMIT, /*!< 21 Limit exceeded */
RIG_EEND // MUST BE LAST ITEM IN LAST
};
/**
* @}
*/
/**
* \brief Determines if the given error code indicates a "soft" error
* Soft errors are caused by invalid parameters and software/hardware features
* and cannot be fixed by retries or by re-initializing hardware.
*/
#define RIG_IS_SOFT_ERRCODE(errcode) (errcode == RIG_EINVAL || errcode == RIG_ENIMPL || errcode == RIG_ERJCTED \
|| errcode == RIG_ETRUNC || errcode == RIG_ENAVAIL || errcode == RIG_ENTARGET \
|| errcode == RIG_EVFO || errcode == RIG_EDOM || errcode == RIG_EDEPRECATED \
|| errcode == RIG_ESECURITY || errcode == RIG_EPOWER)
/**
* \brief Token in the netrigctl protocol for returning error code
*/
#define NETRIGCTL_RET "RPRT "
/**
*\brief Hamlib debug levels
*
* NOTE: Numeric order matters for debug level
*
* \sa rig_set_debug()
*/
enum rig_debug_level_e {
RIG_DEBUG_NONE = 0, /*!< no bug reporting */
RIG_DEBUG_BUG, /*!< serious bug */
RIG_DEBUG_ERR, /*!< error case (e.g. protocol, memory allocation) */
RIG_DEBUG_WARN, /*!< warning */
RIG_DEBUG_VERBOSE, /*!< verbose */
RIG_DEBUG_TRACE, /*!< tracing */
RIG_DEBUG_CACHE /*!< caching */
};
/* --------------- Rig capabilities -----------------*/
/* Forward struct references */
struct rig;
struct rig_state;
/**
* \brief Rig structure definition (see rig for details).
*/
typedef struct s_rig RIG;
//! @cond Doxygen_Suppress
#define HAMLIB_RIGNAMSIZ 30
#define HAMLIB_RIGVERSIZ 8
#define HAMLIB_FILPATHLEN 512
#define HAMLIB_FRQRANGESIZ 30
#define HAMLIB_MAXCHANDESC 30 /* describe channel eg: "WWV 5Mhz" */
#define HAMLIB_TSLSTSIZ 20 /* max tuning step list size, zero ended */
#define HAMLIB_FLTLSTSIZ 60 /* max mode/filter list size, zero ended */
#define HAMLIB_MAXDBLSTSIZ 8 /* max preamp/att levels supported, zero ended */
#define HAMLIB_CHANLSTSIZ 16 /* max mem_list size, zero ended */
#define HAMLIB_MAX_AGC_LEVELS 8 /* max AGC levels supported */
#define HAMLIB_MAX_SPECTRUM_SCOPES 4 /* max number of spectrum scopes supported */
#define HAMLIB_MAX_SPECTRUM_MODES 5 /* max number of spectrum modes supported */
#define HAMLIB_MAX_SPECTRUM_AVG_MODES 12 /* max number of spectrum averaging modes supported */
#define HAMLIB_MAX_SPECTRUM_SPANS 20 /* max number of spectrum modes supported */
#define HAMLIB_MAX_SPECTRUM_DATA 2048 /* max number of data bytes in a single spectrum line */
#define HAMLIB_MAX_CAL_LENGTH 32 /* max calibration plots in cal_table_t */
#define HAMLIB_MAX_MODES 63
#define HAMLIB_MAX_VFOS 31
#define HAMLIB_MAX_ROTORS 63
#define HAMLIB_MAX_VFO_OPS 31
#define HAMLIB_MAX_RSCANS 31
#define HAMLIB_MAX_SNAPSHOT_PACKET_SIZE 16384 /* maximum number of bytes in a UDP snapshot packet */
//! @endcond
/**
* \brief CTCSS and DCS type definition.
*
* Continuous Tone Controlled Squelch System (CTCSS)
* sub-audible tone frequency are expressed in \em tenth of Hz.
* For example, the subaudible tone of 88.5 Hz is represented within
* Hamlib by 885.
*
* Digitally-Coded Squelch codes are simple direct integers.
*/
#define CTCSS_LIST_SIZE 60
#define DCS_LIST_SIZE 128
typedef unsigned int tone_t;
/**
* \brief Port type
*
* Note: All rigs may use a network:port address ( e.g. tcp/serial adapter)
*/
typedef enum rig_port_e {
RIG_PORT_NONE = 0, /*!< No port */
RIG_PORT_SERIAL, /*!< Serial */
RIG_PORT_NETWORK, /*!< Network socket type */
RIG_PORT_DEVICE, /*!< Device driver, like the WiNRADiO */
RIG_PORT_PACKET, /*!< AX.25 network type, e.g. SV8CS protocol */
RIG_PORT_DTMF, /*!< DTMF protocol bridge via another rig, eg. Kenwood Sky Cmd System */
RIG_PORT_ULTRA, /*!< IrDA Ultra protocol! */
RIG_PORT_RPC, /*!< RPC wrapper */
RIG_PORT_PARALLEL, /*!< Parallel port */
RIG_PORT_USB, /*!< USB port */
RIG_PORT_UDP_NETWORK, /*!< UDP Network socket type */
RIG_PORT_CM108, /*!< CM108 GPIO */
RIG_PORT_GPIO, /*!< GPIO */
RIG_PORT_GPION, /*!< GPIO inverted */
} rig_port_t;
/**
* \brief Serial parity
*/
enum serial_parity_e {
RIG_PARITY_NONE = 0, /*!< No parity */
RIG_PARITY_ODD, /*!< Odd */
RIG_PARITY_EVEN, /*!< Even */
RIG_PARITY_MARK, /*!< Mark */
RIG_PARITY_SPACE /*!< Space */
};
/**
* \brief Serial handshake
*/
enum serial_handshake_e {
RIG_HANDSHAKE_NONE = 0, /*!< No handshake */
RIG_HANDSHAKE_XONXOFF, /*!< Software XON/XOFF */
RIG_HANDSHAKE_HARDWARE /*!< Hardware CTS/RTS */
};
/**
* \brief Serial control state
*/
enum serial_control_state_e {
RIG_SIGNAL_UNSET = 0, /*!< Unset or tri-state */
RIG_SIGNAL_ON, /*!< ON */
RIG_SIGNAL_OFF /*!< OFF */
};
/**
* \brief Rig type flags
*/
typedef enum {
RIG_FLAG_RECEIVER = (1 << 1), /*!< Receiver 2 */
RIG_FLAG_TRANSMITTER = (1 << 2), /*!< Transmitter 4 */
RIG_FLAG_SCANNER = (1 << 3), /*!< Scanner 8 */
RIG_FLAG_MOBILE = (1 << 4), /*!< mobile sized 16 */
RIG_FLAG_HANDHELD = (1 << 5), /*!< handheld sized 32 */
RIG_FLAG_COMPUTER = (1 << 6), /*!< "Computer" rig 64 */
RIG_FLAG_TRUNKING = (1 << 7), /*!< has trunking 128 */
RIG_FLAG_APRS = (1 << 8), /*!< has APRS 256 */
RIG_FLAG_TNC = (1 << 9), /*!< has TNC 512 */
RIG_FLAG_DXCLUSTER = (1 << 10), /*!< has DXCluster 1024 */
RIG_FLAG_TUNER = (1 << 11) /*!< dumb tuner 2048 */
} rig_type_t;
/**
* \brief AGC delay settings
*/
/* TODO: kill me, and replace by real AGC delay */
enum agc_level_e {
RIG_AGC_OFF = 0,
RIG_AGC_SUPERFAST,
RIG_AGC_FAST,
RIG_AGC_SLOW,
RIG_AGC_USER, /*!< user selectable -- RIG_LEVEL_AGC to set USER level */
RIG_AGC_MEDIUM,
RIG_AGC_AUTO,
RIG_AGC_LONG,
RIG_AGC_ON, /*!< Turns AGC ON -- Kenwood -- restores last level set */
RIG_AGC_NONE /*!< Rig does not have CAT AGC control */
};
//! @cond Doxygen_Suppress
#define RIG_FLAG_TRANSCEIVER (RIG_FLAG_RECEIVER|RIG_FLAG_TRANSMITTER)
#define RIG_TYPE_MASK (RIG_FLAG_TRANSCEIVER|RIG_FLAG_SCANNER|RIG_FLAG_MOBILE|RIG_FLAG_HANDHELD|RIG_FLAG_COMPUTER|RIG_FLAG_TRUNKING|RIG_FLAG_TUNER)
#define RIG_TYPE_OTHER 0
#define RIG_TYPE_TRANSCEIVER RIG_FLAG_TRANSCEIVER
#define RIG_TYPE_HANDHELD (RIG_FLAG_TRANSCEIVER|RIG_FLAG_HANDHELD)
#define RIG_TYPE_MOBILE (RIG_FLAG_TRANSCEIVER|RIG_FLAG_MOBILE)
#define RIG_TYPE_RECEIVER RIG_FLAG_RECEIVER
#define RIG_TYPE_PCRECEIVER (RIG_FLAG_COMPUTER|RIG_FLAG_RECEIVER)
#define RIG_TYPE_SCANNER (RIG_FLAG_SCANNER|RIG_FLAG_RECEIVER)
#define RIG_TYPE_TRUNKSCANNER (RIG_TYPE_SCANNER|RIG_FLAG_TRUNKING)
#define RIG_TYPE_COMPUTER (RIG_FLAG_TRANSCEIVER|RIG_FLAG_COMPUTER)
#define RIG_TYPE_TUNER RIG_FLAG_TUNER
//! @endcond
/**
* \brief Development status of the backend
*/
enum rig_status_e {
RIG_STATUS_ALPHA = 0, /*!< Alpha quality, i.e. development */
RIG_STATUS_UNTESTED, /*!< Written from available specs, rig unavailable for test, feedback wanted! */
RIG_STATUS_BETA, /*!< Beta quality */
RIG_STATUS_STABLE, /*!< Stable */
RIG_STATUS_BUGGY /*!< Was stable, but something broke it! */
/* RIG_STATUS_NEW * *!< Initial release of code
* !! Use of RIG_STATUS_NEW is deprecated. Do not use it anymore */
};
/**
* \brief Map all deprecated RIG_STATUS_NEW references to
* RIG_STATUS_UNTESTED for backward compatibility
*/
#define RIG_STATUS_NEW RIG_STATUS_UNTESTED
/**
* \brief Repeater shift type
*/
typedef enum {
RIG_RPT_SHIFT_NONE = 0, /*!< No repeater shift */
RIG_RPT_SHIFT_MINUS, /*!< "-" shift */
RIG_RPT_SHIFT_PLUS /*!< "+" shift */
} rptr_shift_t;
/**
* \brief Split mode
*/
typedef enum {
RIG_SPLIT_OFF = 0, /*!< Split mode disabled */
RIG_SPLIT_ON, /*!< Split mode enabled */
} split_t;
/**
* \brief Frequency type,
*
* Frequency type unit in Hz, able to hold SHF frequencies.
*/
typedef double freq_t;
/**
* \brief printf(3) format to be used for freq_t type
*/
#define PRIfreq ".0f"
/**
* \brief scanf(3) format to be used for freq_t type
*/
#define SCNfreq "lf"
/**
* \brief printf(3) format to be used for freq_t type
*/
#define FREQFMT SCNfreq
/**
* \brief Short frequency type
*
* Frequency in Hz restricted to 31bits, suitable for offsets, shifts, etc..
*/
typedef signed long shortfreq_t;
/** \brief \c Macro to return Hz when f=Hz */
#define Hz(f) ((freq_t)(f))
/** \brief \c Macro to return Hz when f=kHz */
#define kHz(f) ((freq_t)((f)*(freq_t)1000))
/** \brief \c Macro to return Hz when f=MHz */
#define MHz(f) ((freq_t)((f)*(freq_t)1000000))
/** \brief \c Macro to return Hz when f=GHz */
#define GHz(f) ((freq_t)((f)*(freq_t)1000000000))
/** \brief \c Macro to return short Hz when f=Hz */
#define s_Hz(f) ((shortfreq_t)(f))
/** \brief \c Macro to return short Hz when f=kHz */
#define s_kHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000))
/** \brief \c Macro to return short Hz when f=MHz */
#define s_MHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000))
/** \brief \c Macro to return short Hz when f=GHz */
#define s_GHz(f) ((shortfreq_t)((f)*(shortfreq_t)1000000000))
/** \brief \c Frequency none -- used as default value for checking */
#define RIG_FREQ_NONE Hz(0)
/**
* \brief VFO definition
*
* There are several ways of using a vfo_t. For most cases, using RIG_VFO_A,
* RIG_VFO_B, RIG_VFO_CURR, etc., as opaque macros should suffice.
*
* Strictly speaking a VFO is Variable Frequency Oscillator.
* Here, it is referred as a tunable channel, from the radio operator's
* point of view. The channel can be designated individually by its real
* number, or by using an alias.
*
* Aliases may or may not be honored by a backend and are defined using
* high significant bits, i.e. RIG_VFO_MEM, RIG_VFO_MAIN, etc.
*/
typedef unsigned int vfo_t;
/** \brief '' -- used in caps */
#define RIG_VFO_N(n) (1u<<(n))
/** \brief \c VFONone -- vfo unknown */
#define RIG_VFO_NONE 0
/** \brief \c VFOA -- VFO A */
#define RIG_VFO_A RIG_VFO_N(0)
/** \brief \c VFOB -- VFO B */
#define RIG_VFO_B RIG_VFO_N(1)
/** \brief \c VFOC -- VFO C */
#define RIG_VFO_C RIG_VFO_N(2)
// Any addition VFOS need to go from 3-20
// To maintain backward compatibility these values cannot change
/** \brief \c SubA -- alias for SUB_A */
#define RIG_VFO_SUB_A RIG_VFO_N(21)
/** \brief \c SubB -- alias for SUB_B */
#define RIG_VFO_SUB_B RIG_VFO_N(22)
/** \brief \c SubC -- alias for SUB_B */
#define RIG_VFO_SUB_C RIG_VFO_N(3)
/** \brief \c MainA -- alias for MAIN_A */
#define RIG_VFO_MAIN_A RIG_VFO_N(23)
/** \brief \c MainB -- alias for MAIN_B */
#define RIG_VFO_MAIN_B RIG_VFO_N(24)
/** \brief \c MainC -- alias for MAIN_C */
#define RIG_VFO_MAIN_C RIG_VFO_N(4)
/** \brief \c Other -- alias for OTHER -- e.g. Icom rigs without get_vfo capability */
#define RIG_VFO_OTHER RIG_VFO_N(5)
/** \brief \c Sub -- alias for SUB */
#define RIG_VFO_SUB RIG_VFO_N(25)
/** \brief \c Main -- alias for MAIN */
#define RIG_VFO_MAIN RIG_VFO_N(26)
/** \brief \c VFO -- means (last or any)VFO mode, with set_vfo */
#define RIG_VFO_VFO RIG_VFO_N(27)
/** \brief \c MEM -- means Memory mode, to be used with set_vfo */
#define RIG_VFO_MEM RIG_VFO_N(28)
/** \brief \c currVFO -- current "tunable channel"/VFO */
#define RIG_VFO_CURR RIG_VFO_N(29)
/** \brief \c Flag to set if VFO can transmit */
#define RIG_VFO_TX_FLAG RIG_VFO_N(30)
/** \brief \c Flag to set all VFOS */
#define RIG_VFO_ALL RIG_VFO_N(31)
// we can also use RIG_VFO_N(31) if needed
// Misc VFO Macros
/** \brief \c Macro to tell you if VFO can transmit */
#define RIG_VFO_TX_VFO(v) ((v)|RIG_VFO_TX_FLAG)
/** \brief \c TX -- alias for split tx or uplink, of VFO_CURR */
#define RIG_VFO_TX RIG_VFO_TX_VFO(RIG_VFO_CURR)
/** \brief \c RX -- alias for split rx or downlink */
#define RIG_VFO_RX RIG_VFO_CURR
/*
* targetable bitfields, for internal use.
* In rig.c lack of a flag will case a VFO change if needed
* So setting this flag will mean the backend handles any VFO needs
* For many rigs RITXIT, PTT, MEM, and BANK are non-VFO commands so need these flags to avoid unnecessary VFO swapping
*/
//! @cond Doxygen_Suppress
#define RIG_TARGETABLE_NONE 0
#define RIG_TARGETABLE_FREQ (1<<0)
#define RIG_TARGETABLE_MODE (1<<1) // mode by vfo or same mode on both vfos
#define RIG_TARGETABLE_PURE (1<<2) // deprecated -- not used -- reuse it
#define RIG_TARGETABLE_TONE (1<<3)
#define RIG_TARGETABLE_FUNC (1<<4)
#define RIG_TARGETABLE_LEVEL (1<<5)
#define RIG_TARGETABLE_RITXIT (1<<6)
#define RIG_TARGETABLE_PTT (1<<7)
#define RIG_TARGETABLE_MEM (1<<8)
#define RIG_TARGETABLE_BANK (1<<9)
#define RIG_TARGETABLE_ANT (1<<10)
#define RIG_TARGETABLE_ROOFING (1<<11) // roofing filter targetable by VFO
#define RIG_TARGETABLE_SPECTRUM (1<<12) // spectrum scope targetable by VFO
#define RIG_TARGETABLE_BAND (1<<13) // Band select -- e.g. Yaesu BS command
#define RIG_TARGETABLE_COMMON (RIG_TARGETABLE_RITXIT | RIG_TARGETABLE_PTT | RIG_TARGETABLE_MEM | RIG_TARGETABLE_BANK)
#define RIG_TARGETABLE_ALL 0x7fffffff
//! @endcond
//
//
// Newer Icoms like the 9700 and 910 have VFOA/B on both Main & Sub
// Compared to older rigs which have one or the other
// So we need to distinguish between them
//! @cond Doxygen_Suppress
#define VFO_HAS_A_B ((STATE(rig)->vfo_list & (RIG_VFO_A|RIG_VFO_B)) == (RIG_VFO_A|RIG_VFO_B))
#define VFO_HAS_MAIN_SUB ((STATE(rig)->vfo_list & (RIG_VFO_MAIN|RIG_VFO_SUB)) == (RIG_VFO_MAIN|RIG_VFO_SUB))
#define VFO_HAS_MAIN_SUB_ONLY ((!VFO_HAS_A_B) & VFO_HAS_MAIN_SUB)
#define VFO_HAS_MAIN_SUB_A_B_ONLY (VFO_HAS_A_B & VFO_HAS_MAIN_SUB)
#define VFO_HAS_A_B_ONLY (VFO_HAS_A_B & (!VFO_HAS_MAIN_SUB))
#define VFO_DUAL (RIG_VFO_MAIN_A|RIG_VFO_MAIN_B|RIG_VFO_SUB_A|RIG_VFO_SUB_B)
#define VFO_HAS_DUAL ((STATE(rig)->vfo_list & VFO_DUAL) == VFO_DUAL)
//! @endcond
/**
* \brief Macro for bandpass to be set to normal
* \def RIG_PASSBAND_NORMAL
*/
#define RIG_PASSBAND_NORMAL s_Hz(0)
/**
* \brief Macro for bandpass to be left alone
*/
#define RIG_PASSBAND_NOCHANGE s_Hz(-1)
/**
*
* \sa rig_passband_normal(), rig_passband_narrow(), rig_passband_wide()
*/
typedef shortfreq_t pbwidth_t;
typedef float agc_time_t;
typedef enum dcd_e {
RIG_DCD_OFF = 0, /*!< Squelch closed */
RIG_DCD_ON /*!< Squelch open */
} dcd_t;
/**
* \brief DCD type
*
* \sa rig_get_dcd()
*/
typedef enum {
RIG_DCD_NONE = 0, /*!< No DCD available */
RIG_DCD_RIG, /*!< Rig has DCD status support, i.e. rig has get_dcd cap */
RIG_DCD_SERIAL_DSR, /*!< DCD status from serial DSR signal */
RIG_DCD_SERIAL_CTS, /*!< DCD status from serial CTS signal */
RIG_DCD_SERIAL_CAR, /*!< DCD status from serial CD signal */
RIG_DCD_PARALLEL, /*!< DCD status from parallel port pin */
RIG_DCD_CM108, /*!< DCD status from CM108 vol dn pin */
RIG_DCD_GPIO, /*!< DCD status from GPIO pin */
RIG_DCD_GPION, /*!< DCD status from inverted GPIO pin */
} dcd_type_t;
/**
* \brief PTT status
*/
typedef enum {
RIG_PTT_OFF = 0, /*!< PTT deactivated */
RIG_PTT_ON, /*!< PTT activated */
RIG_PTT_ON_MIC, /*!< PTT Mic only, fallbacks on RIG_PTT_ON if unavailable */
RIG_PTT_ON_DATA /*!< PTT Data (Mic-muted), fallbacks on RIG_PTT_ON if unavailable */
} ptt_t;
/**
* \brief PTT type
*
* \sa rig_get_ptt()
*/
typedef enum {
RIG_PTT_NONE = 0, /*!< No PTT available */
RIG_PTT_RIG, /*!< Legacy PTT (CAT PTT) */
RIG_PTT_SERIAL_DTR, /*!< PTT control through serial DTR signal */
RIG_PTT_SERIAL_RTS, /*!< PTT control through serial RTS signal */
RIG_PTT_PARALLEL, /*!< PTT control through parallel port */
RIG_PTT_RIG_MICDATA, /*!< Legacy PTT (CAT PTT), supports RIG_PTT_ON_MIC/RIG_PTT_ON_DATA */
RIG_PTT_CM108, /*!< PTT control through CM108 GPIO pin */
RIG_PTT_GPIO, /*!< PTT control through GPIO pin */
RIG_PTT_GPION, /*!< PTT control through inverted GPIO pin */
} ptt_type_t;
/**
* \brief Radio power state
*/
typedef enum {
RIG_POWER_OFF = 0, /*!< Power off */
RIG_POWER_ON = (1 << 0), /*!< Power on */
RIG_POWER_STANDBY = (1 << 1), /*!< Standby */
RIG_POWER_OPERATE = (1 << 2), /*!< Operate (from Standby) */
RIG_POWER_UNKNOWN = (1 << 3) /*!< Unknown power status */
} powerstat_t;
/**
* \brief Reset operation
*/
typedef enum {
RIG_RESET_NONE = 0, /*!< No reset */
RIG_RESET_SOFT = (1 << 0), /*!< Software reset */
RIG_RESET_VFO = (1 << 1), /*!< VFO reset */
RIG_RESET_MCALL = (1 << 2), /*!< Memory clear */
RIG_RESET_MASTER = (1 << 3) /*!< Master reset */
} reset_t;
/**
* \brief VFO operation
*
* A VFO operation is an action on a VFO (or tunable memory).
* The difference with a function is that an action has no on/off
* status, it is performed at once.
*
* NOTE: the vfo argument for some vfo operation may be irrelevant,
* and thus will be ignored.
*
* The VFO/MEM "mode" is set by rig_set_vfo.\n
* \c STRING used in rigctl
*
* \sa rig_parse_vfo_op(), rig_strvfop()
*/
typedef enum {
RIG_OP_NONE = 0, /*!< '' No VFO_OP */
RIG_OP_CPY = (1 << 0), /*!< \c CPY -- VFO A = VFO B */
RIG_OP_XCHG = (1 << 1), /*!< \c XCHG -- Exchange VFO A/B */
RIG_OP_FROM_VFO = (1 << 2), /*!< \c FROM_VFO -- VFO->MEM */
RIG_OP_TO_VFO = (1 << 3), /*!< \c TO_VFO -- MEM->VFO */
RIG_OP_MCL = (1 << 4), /*!< \c MCL -- Memory clear */
RIG_OP_UP = (1 << 5), /*!< \c UP -- UP increment VFO freq by tuning step*/
RIG_OP_DOWN = (1 << 6), /*!< \c DOWN -- DOWN decrement VFO freq by tuning step*/
RIG_OP_BAND_UP = (1 << 7), /*!< \c BAND_UP -- Band UP */
RIG_OP_BAND_DOWN = (1 << 8), /*!< \c BAND_DOWN -- Band DOWN */
RIG_OP_LEFT = (1 << 9), /*!< \c LEFT -- LEFT */
RIG_OP_RIGHT = (1 << 10), /*!< \c RIGHT -- RIGHT */
RIG_OP_TUNE = (1 << 11), /*!< \c TUNE -- Start tune */
RIG_OP_TOGGLE = (1 << 12) /*!< \c TOGGLE -- Toggle VFOA and VFOB */
} vfo_op_t;
/**
* \brief Band enumeration
*
* Some rig commands like Yaesu band select know about bands
*
* \sa rig_set_level()
*/
typedef enum { // numbers here reflect the Yaesu values
RIG_BAND_160M = 0, /*!< \c 160M */
RIG_BAND_80M = 1, /*!< \c 80M */
RIG_BAND_60M = 2, /*!< \c 60M */
RIG_BAND_40M = 3, /*!< \c 40M */
RIG_BAND_30M = 4, /*!< \c 30M */
RIG_BAND_20M = 5, /*!< \c 20M */
RIG_BAND_17M = 6, /*!< \c 17M */
RIG_BAND_15M = 7, /*!< \c 15M */
RIG_BAND_12M = 8, /*!< \c 12M */
RIG_BAND_10M = 9, /*!< \c 10M */
RIG_BAND_6M = 10, /*!< \c 6M */
RIG_BAND_GEN = 11, /*!< \c 60M */
RIG_BAND_MW = 12, /*!< \c Medium Wave */
RIG_BAND_UNUSED = 13, /*!< \c Medium Wave */
RIG_BAND_AIR = 14, /*!< \c Air band */
RIG_BAND_144MHZ = 15, /*!< \c 144MHz */
RIG_BAND_430MHZ = 16, /*!< \c 430MHz */
} hamlib_band_t;
typedef enum { // numbers here reflect generic values -- need to map to rig values
RIG_BANDSELECT_UNUSED = CONSTANT_64BIT_FLAG(0), /*!< \c Unused */
RIG_BANDSELECT_2200M = CONSTANT_64BIT_FLAG(1), /*!< \c 160M */
RIG_BANDSELECT_600M = CONSTANT_64BIT_FLAG(2), /*!< \c 160M */
RIG_BANDSELECT_160M = CONSTANT_64BIT_FLAG(3), /*!< \c 160M */
RIG_BANDSELECT_80M = CONSTANT_64BIT_FLAG(4), /*!< \c 80M */
RIG_BANDSELECT_60M = CONSTANT_64BIT_FLAG(5), /*!< \c 60M */
RIG_BANDSELECT_40M = CONSTANT_64BIT_FLAG(6), /*!< \c 40M */
RIG_BANDSELECT_30M = CONSTANT_64BIT_FLAG(7), /*!< \c 30M */
RIG_BANDSELECT_20M = CONSTANT_64BIT_FLAG(8), /*!< \c 20M */
RIG_BANDSELECT_17M = CONSTANT_64BIT_FLAG(9), /*!< \c 17M */
RIG_BANDSELECT_15M = CONSTANT_64BIT_FLAG(10), /*!< \c 15M */
RIG_BANDSELECT_12M = CONSTANT_64BIT_FLAG(11), /*!< \c 12M */
RIG_BANDSELECT_10M = CONSTANT_64BIT_FLAG(12), /*!< \c 10M */
RIG_BANDSELECT_6M = CONSTANT_64BIT_FLAG(13), /*!< \c 6M */
RIG_BANDSELECT_WFM = CONSTANT_64BIT_FLAG(14), /*!< \c IC705 74.8-108 */
RIG_BANDSELECT_GEN = CONSTANT_64BIT_FLAG(15), /*!< \c 60M */
RIG_BANDSELECT_MW = CONSTANT_64BIT_FLAG(16), /*!< \c Medium Wave */
RIG_BANDSELECT_AIR = CONSTANT_64BIT_FLAG(17), /*!< \c Air band */
RIG_BANDSELECT_4M = CONSTANT_64BIT_FLAG(18), /*!< \c 70MHz */
RIG_BANDSELECT_2M = CONSTANT_64BIT_FLAG(19), /*!< \c 144MHz */
RIG_BANDSELECT_1_25M = CONSTANT_64BIT_FLAG(20), /*!< \c 222MHz */
RIG_BANDSELECT_70CM = CONSTANT_64BIT_FLAG(21), /*!< \c 420MHz */
RIG_BANDSELECT_33CM = CONSTANT_64BIT_FLAG(22), /*!< \c 902MHz */
RIG_BANDSELECT_23CM = CONSTANT_64BIT_FLAG(23), /*!< \c 1240MHz */
RIG_BANDSELECT_13CM = CONSTANT_64BIT_FLAG(24), /*!< \c 2300MHz */
RIG_BANDSELECT_9CM = CONSTANT_64BIT_FLAG(25), /*!< \c 3300MHz */
RIG_BANDSELECT_5CM = CONSTANT_64BIT_FLAG(26), /*!< \c 5650MHz */
RIG_BANDSELECT_3CM = CONSTANT_64BIT_FLAG(27), /*!< \c 10000MHz */
} hamlib_bandselect_t;
#define RIG_BANDSELECT_ALL
#define RIG_BANDSELECT_LF (RIG_BANDSELECT_2200M | RIG_BANDSELECT_600M)
#define RIG_BANDSELECT_HF (RIG_BANDSELECT_160M | RIG_BANDSELECT_80M | RIG_BANDSELECT_60M | RIG_BANDSELECT_40M\
| RIG_BANDSELECT_30M | RIG_BANDSELECT_20M | RIG_BANDSELECT_17M | RIG_BANDSELECT_15M | RIG_BANDSELECT_12M\
RIG_BANDSELECT_10M | RIG_BANDSELECT_6M)
#define RIG_BANDSELECT_VHF (RIG_BANDSELECT_AIR | RIG_BANDSELECT_2M| RIG_BANDSELECT_1_25M(
#define RIG_BANDSELECT_UHF (RIG_BANDSELECT_70CM)
/**
* \brief Rig Scan operation
*
* Various scan operations supported by a rig.\n
* \c STRING used in rigctl
*
* \sa rig_parse_scan(), rig_strscan()
*/
typedef enum {
RIG_SCAN_NONE = 0, /*!< '' No-op value */
RIG_SCAN_MEM = (1 << 0), /*!< \c MEM -- Scan all memory channels */
RIG_SCAN_SLCT = (1 << 1), /*!< \c SLCT -- Scan all selected memory channels */
RIG_SCAN_PRIO = (1 << 2), /*!< \c PRIO -- Priority watch (mem or call channel) */
RIG_SCAN_PROG = (1 << 3), /*!< \c PROG -- Programmed(edge) scan */
RIG_SCAN_DELTA = (1 << 4), /*!< \c DELTA -- delta-f scan */
RIG_SCAN_VFO = (1 << 5), /*!< \c VFO -- most basic scan */
RIG_SCAN_PLT = (1 << 6), /*!< \c PLT -- Scan using pipelined tuning */
RIG_SCAN_STOP = (1 << 7) /*!< \c STOP -- Stop scanning */
} scan_t;
/**
* \brief configuration token
*/
typedef long hamlib_token_t;
#define token_t hamlib_token_t
//! @cond Doxygen_Suppress
#define RIG_CONF_END 0
//! @endcond
/**
* \brief parameter types
*
* Used with configuration, parameter and extra-parm tables.
*
* Current internal implementation
* NUMERIC: val.f or val.i
* COMBO: val.i, starting from 0. Points to a table of strings or ASCII stored values.
* STRING: val.s or val.cs
* CHECKBUTTON: val.i 0/1
* BINARY: val.b
*/
/* strongly inspired from soundmodem. Thanks Thomas! */
enum rig_conf_e {
RIG_CONF_STRING, /*!< String type */
RIG_CONF_COMBO, /*!< Combo type */
RIG_CONF_NUMERIC, /*!< Numeric type integer or real */
RIG_CONF_CHECKBUTTON, /*!< on/off type */
RIG_CONF_BUTTON, /*!< Button type */
RIG_CONF_BINARY, /*!< Binary buffer type */
RIG_CONF_INT /*!< Integer */
};
//! @cond Doxygen_Suppress
#define RIG_COMBO_MAX 16
#define RIG_BIN_MAX 80
//! @endcond
/**
* \brief Configuration parameter structure.
*/
struct confparams {
hamlib_token_t token; /*!< Conf param token ID */
const char *name; /*!< Param name, no spaces allowed */
const char *label; /*!< Human readable label */
const char *tooltip; /*!< Hint on the parameter */
const char *dflt; /*!< Default value */
enum rig_conf_e type; /*!< Type of the parameter */
union { /*!< */
struct { /*!< */
float min; /*!< Minimum value */
float max; /*!< Maximum value */
float step; /*!< Step */
} n; /*!< Numeric type */
struct { /*!< */
const char *combostr[RIG_COMBO_MAX]; /*!< Combo list */
} c; /*!< Combo type */
} u; /*!< Type union */
};
/**
* \brief Announce
*
* Designate optional speech synthesizer.
*/
typedef enum {
RIG_ANN_NONE = 0, /*!< None */
RIG_ANN_OFF = RIG_ANN_NONE, /*!< disable announces */
RIG_ANN_FREQ = (1 << 0), /*!< Announce frequency */
RIG_ANN_RXMODE = (1 << 1), /*!< Announce receive mode */
RIG_ANN_CW = (1 << 2), /*!< CW */
RIG_ANN_ENG = (1 << 3), /*!< English */
RIG_ANN_JAP = (1 << 4) /*!< Japan */
} ann_t;
/**
* \brief Antenna typedef
* \typedef ant_t
*/
/**
* \brief Antenna number
* \def RIG_ANT_NONE
* No antenna set yet or unknown
*/
/**
* \brief Antenna conversion macro
* \def RIG_ANT_N
* Convert antenna number to bit mask
*/
/**
* \brief Macro for Ant#1
* \def RIG_ANT_1
*/
/**
* \brief Macro for Ant#2
* \def RIG_ANT_2
*/
/**
* \brief Macro for Ant#3
* \def RIG_ANT_3
*/
/**
* \brief Macro for Ant#4
* \def RIG_ANT_4
*/
/**
* \brief Macro for Ant#5
* \def RIG_ANT_5
*/
/**
* \brief Antenna is on whatever "current" means
* \def RIG_ANT_CURR
*/
/**
* \brief Macro for unknown antenna
* \def RIG_ANT_UNKNOWN
*/
/**
* \brief Maximum antenna#
* \def RIG_ANT_MAX
*/
typedef unsigned int ant_t;
#define RIG_ANT_NONE 0
#define RIG_ANT_N(n) ((ant_t)1<<(n))
#define RIG_ANT_1 RIG_ANT_N(0)
#define RIG_ANT_2 RIG_ANT_N(1)
#define RIG_ANT_3 RIG_ANT_N(2)
#define RIG_ANT_4 RIG_ANT_N(3)
#define RIG_ANT_5 RIG_ANT_N(4)
#define RIG_ANT_UNKNOWN RIG_ANT_N(30)
#define RIG_ANT_CURR RIG_ANT_N(31)
#define RIG_ANT_MAX 32
//! @cond Doxygen_Suppress
#define RIG_AGC_LAST 99999
//! @endcond
#if 1 // deprecated
/**
* \brief Level display meters
*/
enum meter_level_e {
RIG_METER_NONE = 0, /*< No display meter */
RIG_METER_SWR = (1 << 0), /*< Stationary Wave Ratio */
RIG_METER_COMP = (1 << 1), /*< Compression level */