1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 Grig: Gtk+ user interface for the Hamradio Control Libraries.
4
5 Copyright (C) 2001-2007 Alexandru Csete.
6
7 Authors: Alexandru Csete <oz9aec@gmail.com>
8
9 Comments, questions and bugreports should be submitted via
10 http://sourceforge.net/projects/groundstation/
11 More details can be found at the project home page:
12
13 http://groundstation.sourceforge.net/
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, visit http://www.fsf.org/
27 */
28 /** \file rig-data.c
29 * \ingroup shdata
30 * \brief Shared data between rig daemon and GUI.
31 *
32 * This object implements the data structures that are shared between
33 * the rig daemon and the GUI. These data include commanded and acquired
34 * rig settings.
35 *
36 * Although the data is global and publicly available, the idea is that
37 * while the rig daemon should access them directly, the GUI should
38 * only use the API functions.
39 *
40 * \note The rig-daemon object is responsible for the correct initialization
41 * of the shared data structures and their contents before they can
42 * be accessed by the GUI.
43 *
44 * \note 'set' functions will also modify the 'get' variable to avoid temporary
45 * flipping to he current value (in case the daemon does not update the
46 * 'get' variable before the GUI reads it again).
47 *
48 * \bug Must add rig_data_has_get_xxx and rig_data_has_set_xxx functions.
49 *
50 * \bug File includes gtk.h but not really needed?
51 */
52
53 #include <gtk/gtk.h>
54 #include <hamlib/rig.h>
55 #include <glib/gi18n.h>
56 #include "rig-data.h"
57
58
59 grig_settings_t set; /*!< These values are sent to the radio. */
60 grig_settings_t get; /*!< These values are read from the radio. */
61 grig_cmd_avail_t new; /*!< Flags to indicate whether new value is available. */
62 grig_cmd_avail_t has_set; /*!< Flags to indicate writing capabilities. */
63 grig_cmd_avail_t has_get; /*!< Flags to indicate reading capabilities. */
64
65
66 /** \brief List of attenuator values (absolute values). */
67 static int att[HAMLIB_MAXDBLSTSIZ];
68
69 /** \brief List of preamp values. */
70 static int preamp[HAMLIB_MAXDBLSTSIZ];
71
72 /** \brief Bit field of available VFO's */
73 static int vfo_list;
74
75 /** \brief Maximum power in W */
76 static float maxpwr = 0.0;
77
78
79 /** \brief Getavailable VFOs.
80 * \return Bit field of available VFOs.
81 *
82 * This function returns the available VFOs in a bit field
83 * Although the details of the bitfield can be deduced from the hamlib api
84 * documentation, grig is only interested in the symbolic references like
85 * RIG_VFO_A, RIG_VFO_B and such.
86 */
87 int
rig_data_get_vfos()88 rig_data_get_vfos ()
89 {
90 return vfo_list;
91 }
92
93
94 /** \brief Set available VFOs.
95 * \param vfos Bit field of available VFOs.
96 *
97 * This function sets the bit field of available VFOs.
98 * It should be used by the daemon after the VFOs are checked.
99 */
100 void
rig_data_set_vfos(int vfos)101 rig_data_set_vfos (int vfos)
102 {
103 vfo_list = vfos;
104 }
105
106
107
108 /** \brief Set attenuator data.
109 * \param index The index of the element to set
110 * \param data The value of the element.
111 *
112 * This function sets the element at index in the att array to data.
113 * This function is usedby the rig-daemon-check function to initialise
114 * the attenuator array.
115 */
116 void
rig_data_set_att_data(int index,int data)117 rig_data_set_att_data (int index, int data)
118 {
119 if ((index >= 0) && (index < HAMLIB_MAXDBLSTSIZ))
120 att[index] = data;
121 }
122
123
124 /** \brief Get attenuator value.
125 * \param index The index of the element.
126 * \return The value at index.
127 *
128 * This function returns the attenuator vlue stored at index.
129 * the function can be used by the GUI to initialise the attenuator
130 * widget.
131 */
132 int
rig_data_get_att_data(int index)133 rig_data_get_att_data (int index)
134 {
135 if ((index >= 0) && (index < HAMLIB_MAXDBLSTSIZ)) {
136 return att[index];
137 }
138 else {
139 return 0;
140 }
141 }
142
143
144 /** \brief Get array index of a specific att value.
145 * \param data The att value to check.
146 * \return The array index of data. -1 if data not in array.
147 *
148 * This function scans the att array for data and returns it's array
149 * index if data can be found in the array.
150 */
151 int
rig_data_get_att_index(int data)152 rig_data_get_att_index (int data)
153 {
154 int i = 0;
155
156 /* invali att value */
157 if (data <= 0)
158 return -1;
159
160 /* scan through the array */
161 while ((i < HAMLIB_MAXDBLSTSIZ) && (att[i] != 0)) {
162 if (att[i] == data) {
163 return i;
164 }
165 i++;
166 }
167
168 /* data not in array */
169 return -1;
170 }
171
172
173
174 /** \brief Set preamp data.
175 * \param index The index of the element to set
176 * \param data The value of the element.
177 *
178 * This function sets the element at index in the preamp array to data.
179 * This function is usedby the rig-daemon-check function to initialise
180 * the preamp array.
181 */
182 void
rig_data_set_preamp_data(int index,int data)183 rig_data_set_preamp_data (int index, int data)
184 {
185 if ((index >= 0) && (index < HAMLIB_MAXDBLSTSIZ))
186 preamp[index] = data;
187 }
188
189
190 /** \brief Get preamp value.
191 * \param index The index of the element.
192 * \return The value at index.
193 *
194 * This function returns the preamp value stored at index.
195 * the function can be used by the GUI to initialise the preamp
196 * widget.
197 */
198 int
rig_data_get_preamp_data(int index)199 rig_data_get_preamp_data (int index)
200 {
201 if ((index >= 0) && (index < HAMLIB_MAXDBLSTSIZ)) {
202 return preamp[index];
203 }
204 else {
205 return 0;
206 }
207 }
208
209
210
211 /** \brief Get array index of a specific preamp value.
212 * \param data The preamp value to check.
213 * \return The array index of data. -1 if data not in array.
214 *
215 * This function scans the preamp array for data and returns it's array
216 * index if data can be found in the array.
217 */
218 int
rig_data_get_preamp_index(int data)219 rig_data_get_preamp_index (int data)
220 {
221 int i = 0;
222
223 /* invalid preamp value */
224 if (data <= 0)
225 return -1;
226
227 /* scan through the array */
228 while ((i < HAMLIB_MAXDBLSTSIZ) && (preamp[i] != 0)) {
229 if (preamp[i] == data) {
230 return i;
231 }
232 i++;
233 }
234
235 /* data not in array */
236 return -1;
237 }
238
239
240 /** \brief Set power status.
241 * \param pwr The new power status.
242 *
243 * This function sets the targeted power status to pwr.
244 */
245 void
rig_data_set_pstat(powerstat_t pwr)246 rig_data_set_pstat (powerstat_t pwr)
247 {
248 set.pstat = pwr;
249 get.pstat = pwr;
250 new.pstat = 1;
251 }
252
253
254
255 /** \brief Set PTT status.
256 * \param ptt The new PTT status.
257 *
258 * This function sets the targeted PTT status to ptt.
259 */
260 void
rig_data_set_ptt(ptt_t ptt)261 rig_data_set_ptt (ptt_t ptt)
262 {
263 set.ptt = ptt;
264 get.ptt = ptt;
265 new.ptt = 1;
266 }
267
268
269
270
271
272
273
274 /** \brief Set TX power.
275 * \param power The new TX power.
276 *
277 * This function sets the desired TX power.
278 */
279 void
rig_data_set_power(float power)280 rig_data_set_power (float power)
281 {
282 set.power = power;
283 get.power = power;
284 new.power = TRUE;
285 }
286
287
288
289
290
291 /** \brief Set mode.
292 * \param mode The new mode.
293 *
294 * This function sets the targeted mode to mode.
295 *
296 * \note The current Hamlib API requires that the mode and passband width
297 * are set within the same function call.
298 */
299 void
rig_data_set_mode(rmode_t mode)300 rig_data_set_mode (rmode_t mode)
301 {
302 set.mode = mode;
303 get.mode = mode;
304 new.mode = 1;
305 }
306
307
308
309 /** \brief Set passband width.
310 * \param pbw The new passband width.
311 *
312 * This function set the targeted passband width to pbw.
313 *
314 * \note The current Hamlib API requires that the mode and passband width
315 * are set within the same function call.
316 */
317 void
rig_data_set_pbwidth(rig_data_pbw_t pbw)318 rig_data_set_pbwidth (rig_data_pbw_t pbw)
319 {
320 set.pbw = pbw;
321 get.pbw = pbw;
322 new.pbw = 1;
323 }
324
325
326 /** \brief Set frequency.
327 * \param int Number indicating which frequency to set. 1 corresponds to
328 * the main/primary/working frequency and 2 to the secondary.
329 * \param freq The new frequency.
330 *
331 * This function sets the targeted frequency to frew.
332 */
333 void
rig_data_set_freq(int num,freq_t freq)334 rig_data_set_freq (int num, freq_t freq)
335 {
336 switch (num) {
337
338 /* primary frequency */
339 case 1: set.freq1 = freq;
340 get.freq1 = freq;
341 new.freq1 = 1;
342 break;
343
344 /* secondary frequency */
345 case 2: set.freq2 = freq;
346 get.freq2 = freq;
347 new.freq2 = 1;
348 break;
349
350 /* this is a bug */
351 default:
352 g_warning (_("%s: Invalid target: %d\n"), __FUNCTION__, num);
353 break;
354 }
355 }
356
357
358 /** \brief Set RIT offset.
359 * \param rit The new RIT offset.
360 *
361 * This function sets the targeted RIT offset to rit.
362 */
363 void
rig_data_set_rit(shortfreq_t rit)364 rig_data_set_rit (shortfreq_t rit)
365 {
366 set.rit = rit;
367 get.rit = rit;
368 new.rit = 1;
369 }
370
371
372 /** \brief Set XIT offset.
373 * \param rit The new XIT offset.
374 *
375 * This function sets the targeted XIT offset to xit.
376 */
377 void
rig_data_set_xit(shortfreq_t xit)378 rig_data_set_xit (shortfreq_t xit)
379 {
380 set.xit = xit;
381 get.xit = xit;
382 new.xit = 1;
383 }
384
385
386 /** \brief Set AGC level.
387 * \param rit The new AGC level.
388 *
389 * This function sets the targeted AGC level to agc.
390 */
391 void
rig_data_set_agc(int agc)392 rig_data_set_agc (int agc)
393 {
394 set.agc = agc;
395 get.agc = agc;
396 new.agc = 1;
397 }
398
399
400 /** \brief Set attenuator level.
401 * \param rit The new attenuator level.
402 *
403 * This function sets the targeted attenuator level to att.
404 */
405 void
rig_data_set_att(int att)406 rig_data_set_att (int att)
407 {
408 set.att = att;
409 get.att = att;
410 new.att = 1;
411 }
412
413
414 /** \brief Set pre-amplifier level.
415 * \param rit The new pre-amplifier level.
416 *
417 * This function sets the targeted pre-amplifier level to preamp.
418 */
419 void
rig_data_set_preamp(int preamp)420 rig_data_set_preamp (int preamp)
421 {
422 set.preamp = preamp;
423 get.preamp = preamp;
424 new.preamp = 1;
425 }
426
427
428 /** \brief Set antenna.
429 * \param antenna The new antenna.
430 *
431 * This function sets the targeted antenna to antenna.
432 */
433 void
rig_data_set_antenna(ant_t antenna)434 rig_data_set_antenna (ant_t antenna)
435 {
436 set.antenna = antenna;
437 get.antenna = antenna;
438 new.antenna = 1;
439 }
440
441
442 /** \brief Get power status.
443 * \return The current power status.
444 *
445 * This function returns the current power status.
446 */
447 powerstat_t
rig_data_get_pstat()448 rig_data_get_pstat ()
449 {
450 return get.pstat;
451 }
452
453
454 /** \brief Get PTT status.
455 * \return The current PTT status.
456 *
457 * This function returns the current PTT status.
458 */
459 ptt_t
rig_data_get_ptt()460 rig_data_get_ptt ()
461 {
462 return get.ptt;
463 }
464
465
466 /* SET and GET VFO */
467 vfo_t
rig_data_get_vfo()468 rig_data_get_vfo ()
469 {
470 return get.vfo;
471 }
472
473 void
rig_data_set_vfo(vfo_t vfo)474 rig_data_set_vfo (vfo_t vfo)
475 {
476 set.vfo = vfo;
477 get.vfo = vfo;
478 new.vfo = 1;
479 }
480
481 int
rig_data_has_get_vfo()482 rig_data_has_get_vfo ()
483 {
484 return has_get.vfo;
485 }
486
487
488 int
rig_data_has_set_vfo()489 rig_data_has_set_vfo ()
490 {
491 return has_set.vfo;
492 }
493
494
495
496 /** \brief Get current mode.
497 * \return The current mode.
498 *
499 * This function returns the current mode.
500 */
501 rmode_t
rig_data_get_mode()502 rig_data_get_mode ()
503 {
504 return get.mode;
505 }
506
507
508
509 /** \brief Get current passband width.
510 * \returns The current passband width.
511 *
512 * This function returns the current passband width.
513 */
514 rig_data_pbw_t
rig_data_get_pbwidth()515 rig_data_get_pbwidth ()
516 {
517 return get.pbw;
518 }
519
520
521
522 /** \brief Get current frequency.
523 * \param num Integer indicating which frequency to obtain.
524 * \return The current frequency.
525 *
526 * This function returns the current frequnecy of the specified target.
527 * If num is 1 the value of the primary frequency is returned, while if
528 * num is equal to 2 the value of the secondary frequency is returned.
529 */
530 freq_t
rig_data_get_freq(int num)531 rig_data_get_freq (int num)
532 {
533 switch (num) {
534
535 /* primary frequency */
536 case 1: return get.freq1;
537 break;
538
539 /* secondary frequenct */
540 case 2: return get.freq2;
541 break;
542
543 /* bug */
544 default: g_warning (_("%s: Invalid target: %d\n"), __FUNCTION__, num);
545 return get.freq1;
546 break;
547 }
548 }
549
550
551 /** \brief Get lower freqency limit.
552 * \return The current lower frequency limit.
553 *
554 * This function returns the lower frequency limit which applies to
555 * the current mode.
556 */
557 freq_t
rig_data_get_fmin()558 rig_data_get_fmin ()
559 {
560 return get.fmin;
561 }
562
563
564
565 /** \brief Get upper freqency limit.
566 * \return The current upper frequency limit.
567 *
568 * This function returns the upper frequency limit which applies to
569 * the current mode.
570 */
571 freq_t
rig_data_get_fmax()572 rig_data_get_fmax ()
573 {
574 return get.fmax;
575 }
576
577
578
579 /** \brief Get tuning step.
580 * \return The current tuning step.
581 *
582 * This function returns the tuning step corresponding to the
583 * current mode.
584 */
585 shortfreq_t
rig_data_get_fstep()586 rig_data_get_fstep ()
587 {
588 return get.fstep;
589 }
590
591
592
593 /** \brief Get RIT offset.
594 * \return The current value of the RIT offset.
595 *
596 * This function returns the current value of the RIT offset.
597 */
598 shortfreq_t
rig_data_get_rit()599 rig_data_get_rit ()
600 {
601 return get.rit;
602 }
603
604
605 /** \brief Get XIT offset.
606 * \return The current value of the XIT offset.
607 *
608 * This function returns the current value of the XIT offset.
609 */
610 shortfreq_t
rig_data_get_xit()611 rig_data_get_xit ()
612 {
613 return get.xit;
614 }
615
616
617 /** \brief Get AGC level.
618 * \return The current value of the AGC.
619 *
620 * This function returns the current value of the AGC.
621 */
622 int
rig_data_get_agc()623 rig_data_get_agc ()
624 {
625 return get.agc;
626 }
627
628
629 /** \brief Get attenuator level.
630 * \return The current value of the attenuator.
631 *
632 * This function returns the current value of the attenuator.
633 */
634 int
rig_data_get_att()635 rig_data_get_att ()
636 {
637 return get.att;
638 }
639
640
641 /** \brief Get preamp level.
642 * \return The current value of the preamp.
643 *
644 * This function returns the current value of the preamp.
645 */
646 int
rig_data_get_preamp()647 rig_data_get_preamp ()
648 {
649 return get.preamp;
650 }
651
652
653 /** \brief Get signal strength.
654 * \return The current value of the signal strength.
655 *
656 * This function returns the current value of the signal strength.
657 */
658 int
rig_data_get_strength()659 rig_data_get_strength ()
660 {
661 return get.strength;
662 }
663
664
665 /** \brief Get TX power.
666 * \return The current value of the TX power.
667 *
668 * This function returns the current value of the TX power.
669 */
670 float
rig_data_get_power()671 rig_data_get_power ()
672 {
673 return get.power;
674 }
675
676
677 /** \brief Get SWR.
678 * \return The current value of the SWR.
679 *
680 * This function returns the current value of the SWR.
681 */
682 float
rig_data_get_swr()683 rig_data_get_swr ()
684 {
685 return get.swr;
686 }
687
688
689 /** \brief Get ALC.
690 * \return The current value of the ALC.
691 *
692 * This function returns the current value of the ALC.
693 */
694 float
rig_data_get_alc()695 rig_data_get_alc ()
696 {
697 return get.alc;
698 }
699
700
701 void
rig_data_set_alc(float alc)702 rig_data_set_alc (float alc)
703 {
704 set.alc = alc;
705 new.alc = TRUE;
706 }
707
708 /** \brief Get current antenna.
709 * \return The current antenna.
710 *
711 * This function returns the current antenna.
712 */
713 ant_t
rig_data_get_antenna()714 rig_data_get_antenna ()
715 {
716 return get.antenna;
717 }
718
719
720 /** \brief Get availablility of signal strength readback.
721 * \return 1 if available, otherwise 0.
722 *
723 * This function returns the value of the has_get.strength variable.
724 */
725 int
rig_data_has_get_strength()726 rig_data_has_get_strength ()
727 {
728 return has_get.strength;
729 }
730
731
732
733
734 /** \brief Get availablility of power status.
735 * \return 1 if available, otherwise 0.
736 *
737 * This function returns the value of the has_get.pstat variable.
738 */
739 int
rig_data_has_get_pstat()740 rig_data_has_get_pstat ()
741 {
742 return has_get.pstat;
743 }
744
745
746
747 /** \brief Get availablility of PTT.
748 * \return 1 if available, otherwise 0.
749 *
750 * This function returns the value of the has_get.ptt variable.
751 */
752 int
rig_data_has_get_ptt()753 rig_data_has_get_ptt ()
754 {
755 return has_get.ptt;
756 }
757
758
759
760 /** \brief Get availablility of RIT.
761 * \return 1 if available, otherwise 0.
762 *
763 * This function returns the value of the has_get.rit variable.
764 */
765 int
rig_data_has_get_rit()766 rig_data_has_get_rit ()
767 {
768 return has_get.rit;
769 }
770
771
772
773 /** \brief Get availablility of XIT.
774 * \return 1 if available, otherwise 0.
775 *
776 * This function returns the value of the has_get.xit variable.
777 */
778 int
rig_data_has_get_xit()779 rig_data_has_get_xit ()
780 {
781 return has_get.xit;
782 }
783
784
785 /** \brief Get availablility of RIT.
786 * \return 1 if available, otherwise 0.
787 *
788 * This function returns the value of the has_set.rit variable.
789 */
790 int
rig_data_has_set_rit()791 rig_data_has_set_rit ()
792 {
793 return has_set.rit;
794 }
795
796
797
798 /** \brief Get availablility of XIT.
799 * \return 1 if available, otherwise 0.
800 *
801 * This function returns the value of the has_set.xit variable.
802 */
803 int
rig_data_has_set_xit()804 rig_data_has_set_xit ()
805 {
806 return has_set.xit;
807 }
808
809
810 /** \brief Get availablility of AGC.
811 * \return 1 if available, otherwise 0.
812 *
813 * This function returns the value of the has_get.agc variable.
814 */
815 int
rig_data_has_get_agc()816 rig_data_has_get_agc ()
817 {
818 return has_get.agc;
819 }
820
821
822
823 /** \brief Get availablility of attenuator.
824 * \return 1 if available, otherwise 0.
825 *
826 * This function returns the value of the has_get.att variable.
827 */
828 int
rig_data_has_get_att()829 rig_data_has_get_att ()
830 {
831 return has_get.att;
832 }
833
834
835
836 /** \brief Get availablility of pre-amp.
837 * \return 1 if available, otherwise 0.
838 *
839 * This function returns the value of the has_get.preamp variable.
840 */
841 int
rig_data_has_get_preamp()842 rig_data_has_get_preamp ()
843 {
844 return has_get.preamp;
845 }
846
847
848
849
850 /** \brief Get availability of reading primary frequency.
851 * \return 1 if available, otherwise 0.
852 *
853 * This function returns the value of the has_get.freq1 variable.
854 *
855 */
856 int
rig_data_has_get_freq1()857 rig_data_has_get_freq1 ()
858 {
859 return has_get.freq1;
860 }
861
862
863
864 /** \brief Get availability of reading secondary frequency.
865 * \return 1 if available, otherwise 0.
866 *
867 * This function returns the value of the has_get.freq2 variable.
868 *
869 */
870 int
rig_data_has_get_freq2()871 rig_data_has_get_freq2 ()
872 {
873 return has_get.freq2;
874 }
875
876
877
878 /** \brief Get availability of reading TX power.
879 * \return 1 if available, otherwise 0.
880 *
881 * This function returns the value of the has_get.power variable.
882 *
883 */
884 int
rig_data_has_get_power()885 rig_data_has_get_power ()
886 {
887 return has_get.power;
888 }
889
890 int
rig_data_has_set_power()891 rig_data_has_set_power ()
892 {
893 return has_set.power;
894 }
895
896
897
898 /** \brief Get availability of reading SWR.
899 * \return 1 if available, otherwise 0.
900 *
901 * This function returns the value of the has_get.swr variable.
902 *
903 */
904 int
rig_data_has_get_swr()905 rig_data_has_get_swr ()
906 {
907 return has_get.swr;
908 }
909
910
911 /** \brief Get availability of reading ALC.
912 * \return 1 if available, otherwise 0.
913 *
914 * This function returns the value of the has_get.alc variable.
915 *
916 */
917 int
rig_data_has_get_alc()918 rig_data_has_get_alc ()
919 {
920 return has_get.alc;
921 }
922
923
924 int
rig_data_has_set_alc()925 rig_data_has_set_alc ()
926 {
927 return has_set.alc;
928 }
929
930 /** \brief Get availablility of power status.
931 * \return 1 if available, otherwise 0.
932 *
933 * This function returns the value of the has_set.pstat variable.
934 */
935 int
rig_data_has_set_pstat()936 rig_data_has_set_pstat ()
937 {
938 return has_set.pstat;
939 }
940
941
942
943 /** \brief Get availablility of PTT.
944 * \return 1 if available, otherwise 0.
945 *
946 * This function returns the value of the has_set.ptt variable.
947 */
948 int
rig_data_has_set_ptt()949 rig_data_has_set_ptt ()
950 {
951 return has_set.ptt;
952 }
953
954
955
956 /** \brief Some text.
957 * \return description
958 *
959 * Detailed description.
960 *
961 * \bug writeme
962 *
963 * \bug should have 1 or 2 as param like get_freq
964 */
965 int
rig_data_has_set_freq1()966 rig_data_has_set_freq1 ()
967 {
968 return has_set.freq1;
969 }
970
971
972
973 /** \brief Some text.
974 * \return description
975 *
976 * Detailed description.
977 *
978 * \bug writeme
979 */
980 int
rig_data_has_set_freq2()981 rig_data_has_set_freq2 ()
982 {
983 return has_set.freq2;
984 }
985
986
987
988 /** \brief Some text.
989 * \return description
990 *
991 * Detailed description.
992 *
993 * \bug writeme
994 */
995 int
rig_data_has_set_att()996 rig_data_has_set_att ()
997 {
998 return has_set.att;
999 }
1000
1001
1002
1003
1004 /** \brief Some text.
1005 * \return description
1006 *
1007 * Detailed description.
1008 *
1009 * \bug writeme
1010 */
1011 int
rig_data_has_set_preamp()1012 rig_data_has_set_preamp ()
1013 {
1014 return has_set.preamp;
1015 }
1016
1017
1018
1019 /** \brief Get lower RIT limit.
1020 * \return The current lower RIT limit.
1021 *
1022 * This function returns the lower RIT limit which applies to
1023 * the current mode.
1024 */
1025 shortfreq_t
rig_data_get_ritmin()1026 rig_data_get_ritmin ()
1027 {
1028 return -get.ritmax;
1029 }
1030
1031
1032
1033 /** \brief Get upper RIT limit.
1034 * \return The current upper RIT limit.
1035 *
1036 * This function returns the upper RIT limit which applies to
1037 * the current mode.
1038 */
1039 shortfreq_t
rig_data_get_ritmax()1040 rig_data_get_ritmax ()
1041 {
1042 return get.ritmax;
1043 }
1044
1045
1046
1047 /** \brief Get RIT tuning step.
1048 * \return The current RIT tuning step.
1049 *
1050 * This function returns the RIT tuning step corresponding to the
1051 * current mode.
1052 */
1053 shortfreq_t
rig_data_get_ritstep()1054 rig_data_get_ritstep ()
1055 {
1056 return get.ritstep;
1057 }
1058
1059
1060
1061 /** \brief Get lower XIT limit.
1062 * \return The current lower XIT limit.
1063 *
1064 * This function returns the lower XIT limit which applies to
1065 * the current mode.
1066 */
1067 shortfreq_t
rig_data_get_xitmin()1068 rig_data_get_xitmin ()
1069 {
1070 return -get.xitmax;
1071 }
1072
1073
1074
1075 /** \brief Get upper XIT limit.
1076 * \return The current upper XIT limit.
1077 *
1078 * This function returns the upper XIT limit which applies to
1079 * the current mode.
1080 */
1081 shortfreq_t
rig_data_get_xitmax()1082 rig_data_get_xitmax ()
1083 {
1084 return get.xitmax;
1085 }
1086
1087
1088
1089 /** \brief Get XIT tuning step.
1090 * \return The current XIT tuning step.
1091 *
1092 * This function returns the XIT tuning step corresponding to the
1093 * current mode.
1094 */
1095 shortfreq_t
rig_data_get_xitstep()1096 rig_data_get_xitstep ()
1097 {
1098 return get.xitstep;
1099 }
1100
1101
1102 /*** FUNC ***/
1103 int
rig_data_has_set_func(setting_t func)1104 rig_data_has_set_func (setting_t func)
1105 {
1106 return has_set.funcs[rig_setting2idx(func)];
1107 }
1108
1109
1110 int
rig_data_has_get_func(setting_t func)1111 rig_data_has_get_func (setting_t func)
1112 {
1113 return has_get.funcs[rig_setting2idx(func)];
1114 }
1115
1116
1117 void
rig_data_set_func(setting_t func,int status)1118 rig_data_set_func (setting_t func, int status)
1119 {
1120 set.funcs[rig_setting2idx(func)] = status;
1121 new.funcs[rig_setting2idx(func)] = 1;
1122 }
1123
1124
1125 int
rig_data_get_func(setting_t func)1126 rig_data_get_func (setting_t func)
1127 {
1128 return get.funcs[rig_setting2idx(func)];
1129 }
1130
1131 /*** LOCK ***/
1132 int
rig_data_has_set_lock()1133 rig_data_has_set_lock ()
1134 {
1135 return has_set.lock;
1136 }
1137
1138
1139 int
rig_data_has_get_lock()1140 rig_data_has_get_lock ()
1141 {
1142 return has_get.lock;
1143 }
1144
1145
1146 void
rig_data_set_lock(int lock)1147 rig_data_set_lock (int lock)
1148 {
1149 set.lock = lock;
1150 new.lock = 1;
1151 }
1152
1153
1154 int
rig_data_get_lock()1155 rig_data_get_lock ()
1156 {
1157 return get.lock;
1158 }
1159
1160
1161 /* VFO TOGGLE */
1162 int
rig_data_has_vfo_op_toggle()1163 rig_data_has_vfo_op_toggle ()
1164 {
1165 return has_set.vfo_op_toggle;
1166 }
1167
1168
1169 void
rig_data_vfo_op_toggle()1170 rig_data_vfo_op_toggle ()
1171 {
1172 set.vfo_op_toggle = 1;
1173 new.vfo_op_toggle = 1;
1174 }
1175
1176
1177 /* VFO COPY */
1178 int
rig_data_has_vfo_op_copy()1179 rig_data_has_vfo_op_copy ()
1180 {
1181 return has_set.vfo_op_copy;
1182 }
1183
1184
1185 void
rig_data_vfo_op_copy()1186 rig_data_vfo_op_copy ()
1187 {
1188 set.vfo_op_copy = 1;
1189 new.vfo_op_copy = 1;
1190 }
1191
1192
1193 /* VFO EXCHANGE */
1194 int
rig_data_has_vfo_op_xchg()1195 rig_data_has_vfo_op_xchg ()
1196 {
1197 return has_set.vfo_op_xchg;
1198 }
1199
1200
1201 void
rig_data_vfo_op_xchg()1202 rig_data_vfo_op_xchg ()
1203 {
1204 set.vfo_op_xchg = 1;
1205 new.vfo_op_xchg = 1;
1206 }
1207
1208
1209 /* set SPLIT ON/OFF */
1210 int
rig_data_has_set_split()1211 rig_data_has_set_split ()
1212 {
1213 return has_set.split;
1214 }
1215
1216 int
rig_data_has_get_split()1217 rig_data_has_get_split ()
1218 {
1219 return has_get.split;
1220 }
1221
1222 void
rig_data_set_split(int split)1223 rig_data_set_split (int split)
1224 {
1225 if (split)
1226 set.split = RIG_SPLIT_ON;
1227 else
1228 set.split = RIG_SPLIT_OFF;
1229
1230 new.split = TRUE;
1231 }
1232
1233 int
rig_data_get_split()1234 rig_data_get_split ()
1235 {
1236 return (get.split == RIG_SPLIT_ON ? 1 : 0);
1237 }
1238
1239
1240
1241 /** \brief Get address of 'get' variable.
1242 * \return A pointer to the shared data.
1243 *
1244 * This function is used to obtain the address of the 'get' global data.
1245 * This is primarly used by the radio daemon for fast access to the data
1246 * structure.
1247 */
1248 grig_settings_t *
rig_data_get_get_addr()1249 rig_data_get_get_addr ()
1250 {
1251 return &get;
1252 }
1253
1254
1255
1256 /** \brief Get address of 'set' variable.
1257 * \return A pointer to the shared data.
1258 *
1259 * This function is used to obtain the address of the 'set' global data.
1260 * This is primarly used by the radio daemon for fast access to the data
1261 * structure.
1262 */
1263 grig_settings_t *
rig_data_get_set_addr()1264 rig_data_get_set_addr ()
1265 {
1266 return &set;
1267 }
1268
1269
1270
1271 /** \brief Get address of 'new' variable.
1272 * \return A pointer to the shared data.
1273 *
1274 * This function is used to obtain the address of the 'new' global data.
1275 * This is primarly used by the radio daemon for fast access to the data
1276 * structure.
1277 */
1278 grig_cmd_avail_t *
rig_data_get_new_addr()1279 rig_data_get_new_addr ()
1280 {
1281 return &new;
1282 }
1283
1284
1285
1286 /** \brief Get address of 'has_set' variable.
1287 * \return A pointer to the shared data.
1288 *
1289 * This function is used to obtain the address of the 'has_set' global data.
1290 * This is primarly used by the radio daemon for fast access to the data
1291 * structure.
1292 */
1293 grig_cmd_avail_t *
rig_data_get_has_set_addr()1294 rig_data_get_has_set_addr ()
1295 {
1296 return &has_set;
1297 }
1298
1299
1300
1301 /** \brief Get address of 'has_get' variable.
1302 * \return A pointer to the shared data.
1303 *
1304 * This function is used to obtain the address of the 'has_get' global data.
1305 * This is primarly used by the radio daemon for fast access to the data
1306 * structure.
1307 */
1308 grig_cmd_avail_t *
rig_data_get_has_get_addr()1309 rig_data_get_has_get_addr ()
1310 {
1311 return &has_get;
1312 }
1313
1314
1315
1316 /** \brief Get the modes bitfield */
1317 int
rig_data_get_all_modes()1318 rig_data_get_all_modes ()
1319 {
1320 return get.allmodes;
1321 }
1322
1323
1324 /** \brief Get the antenna bitfield */
1325 int
rig_data_get_all_antennas()1326 rig_data_get_all_antennas ()
1327 {
1328 return get.allantennas;
1329 }
1330
1331
1332 /** \brief Store tha maximum RF power level */
1333 void
rig_data_set_max_rfpwr(float maxpow)1334 rig_data_set_max_rfpwr (float maxpow)
1335 {
1336 maxpwr = maxpow;
1337 }
1338
1339
1340 /** \brief Get maximum RF power level */
1341 float
rig_data_get_max_rfpwr()1342 rig_data_get_max_rfpwr ()
1343 {
1344 return maxpwr;
1345 }
1346
1347
1348 /* AF gain */
1349 int
rig_data_has_get_afg(void)1350 rig_data_has_get_afg (void)
1351 {
1352 return has_get.afg;
1353 }
1354
1355 int
rig_data_has_set_afg(void)1356 rig_data_has_set_afg (void)
1357 {
1358 return has_set.afg;
1359 }
1360
1361 float
rig_data_get_afg(void)1362 rig_data_get_afg (void)
1363 {
1364 return get.afg;
1365 }
1366
1367 void
rig_data_set_afg(float afg)1368 rig_data_set_afg (float afg)
1369 {
1370 set.afg = afg;
1371 get.afg = afg;
1372 new.afg = TRUE;
1373 }
1374
1375
1376 /* RF gain */
1377 int
rig_data_has_get_rfg(void)1378 rig_data_has_get_rfg (void)
1379 {
1380 return has_get.rfg;
1381 }
1382
1383 int
rig_data_has_set_rfg(void)1384 rig_data_has_set_rfg (void)
1385 {
1386 return has_set.rfg;
1387 }
1388
1389 float
rig_data_get_rfg(void)1390 rig_data_get_rfg (void)
1391 {
1392 return get.rfg;
1393 }
1394
1395 void
rig_data_set_rfg(float rfg)1396 rig_data_set_rfg (float rfg)
1397 {
1398 set.rfg = rfg;
1399 get.rfg = rfg;
1400 new.rfg = TRUE;
1401 }
1402
1403
1404 /* SQL */
1405 int
rig_data_has_get_sql(void)1406 rig_data_has_get_sql (void)
1407 {
1408 return has_get.sql;
1409 }
1410
1411 int
rig_data_has_set_sql(void)1412 rig_data_has_set_sql (void)
1413 {
1414 return has_set.sql;
1415 }
1416
1417 float
rig_data_get_sql(void)1418 rig_data_get_sql (void)
1419 {
1420 return get.sql;
1421 }
1422
1423 void
rig_data_set_sql(float sql)1424 rig_data_set_sql (float sql)
1425 {
1426 set.sql = sql;
1427 get.sql = sql;
1428 new.sql = TRUE;
1429 }
1430
1431
1432 /* IF shift */
1433 int
rig_data_has_get_ifs(void)1434 rig_data_has_get_ifs (void)
1435 {
1436 return has_get.ifs;
1437 }
1438
1439 int
rig_data_has_set_ifs(void)1440 rig_data_has_set_ifs (void)
1441 {
1442 return has_set.ifs;
1443 }
1444
1445 int
rig_data_get_ifs(void)1446 rig_data_get_ifs (void)
1447 {
1448 return get.ifs;
1449 }
1450
1451 void
rig_data_set_ifs(int ifs)1452 rig_data_set_ifs (int ifs)
1453 {
1454 set.ifs = ifs;
1455 get.ifs = ifs;
1456 new.ifs = TRUE;
1457 }
1458
1459 shortfreq_t
rig_data_get_ifsmax()1460 rig_data_get_ifsmax ()
1461 {
1462 return get.ifsmax;
1463 }
1464
1465 shortfreq_t
rig_data_get_ifsstep()1466 rig_data_get_ifsstep ()
1467 {
1468 return get.ifsstep;
1469 }
1470
1471
1472 /* APF */
1473 int
rig_data_has_get_apf(void)1474 rig_data_has_get_apf (void)
1475 {
1476 return has_get.apf;
1477 }
1478
1479 int
rig_data_has_set_apf(void)1480 rig_data_has_set_apf (void)
1481 {
1482 return has_set.apf;
1483 }
1484
1485 float
rig_data_get_apf(void)1486 rig_data_get_apf (void)
1487 {
1488 return get.apf;
1489 }
1490
1491 void
rig_data_set_apf(float apf)1492 rig_data_set_apf (float apf)
1493 {
1494 set.apf = apf;
1495 get.apf = apf;
1496 new.apf = TRUE;
1497 }
1498
1499
1500 /* NR */
1501 int
rig_data_has_get_nr(void)1502 rig_data_has_get_nr (void)
1503 {
1504 return has_get.nr;
1505 }
1506
1507 int
rig_data_has_set_nr(void)1508 rig_data_has_set_nr (void)
1509 {
1510 return has_set.nr;
1511 }
1512
rig_data_get_nr(void)1513 float rig_data_get_nr (void)
1514 {
1515 return get.nr;
1516 }
1517
rig_data_set_nr(float nr)1518 void rig_data_set_nr (float nr)
1519 {
1520 set.nr = nr;
1521 get.nr = nr;
1522 new.nr = TRUE;
1523 }
1524
1525
1526 /* Notch */
1527 int
rig_data_has_get_notch(void)1528 rig_data_has_get_notch (void)
1529 {
1530 return has_get.notch;
1531 }
1532
1533 int
rig_data_has_set_notch(void)1534 rig_data_has_set_notch (void)
1535 {
1536 return has_set.notch;
1537 }
1538
1539 int
rig_data_get_notch(void)1540 rig_data_get_notch (void)
1541 {
1542 return get.notch;
1543 }
1544
1545 void
rig_data_set_notch(int notch)1546 rig_data_set_notch (int notch)
1547 {
1548 set.notch = notch;
1549 get.notch = notch;
1550 new.notch = TRUE;
1551 }
1552
1553
1554 /* PBT in */
1555 int
rig_data_has_get_pbtin(void)1556 rig_data_has_get_pbtin (void)
1557 {
1558 return has_get.pbtin;
1559 }
1560
1561 int
rig_data_has_set_pbtin(void)1562 rig_data_has_set_pbtin (void)
1563 {
1564 return has_set.pbtin;
1565 }
1566
1567 float
rig_data_get_pbtin(void)1568 rig_data_get_pbtin (void)
1569 {
1570 return get.pbtin;
1571 }
1572
1573 void
rig_data_set_pbtin(float pbt)1574 rig_data_set_pbtin (float pbt)
1575 {
1576 set.pbtin = pbt;
1577 get.pbtin = pbt;
1578 new.pbtin = TRUE;
1579 }
1580
1581
1582 /* PBT out */
1583 int
rig_data_has_get_pbtout(void)1584 rig_data_has_get_pbtout (void)
1585 {
1586 return has_get.pbtout;
1587 }
1588
1589 int
rig_data_has_set_pbtout(void)1590 rig_data_has_set_pbtout (void)
1591 {
1592 return has_set.pbtout;
1593 }
1594
1595 float
rig_data_get_pbtout(void)1596 rig_data_get_pbtout (void)
1597 {
1598 return get.pbtout;
1599 }
1600
1601 void
rig_data_set_pbtout(float pbt)1602 rig_data_set_pbtout (float pbt)
1603 {
1604 set.pbtout = pbt;
1605 get.pbtout = pbt;
1606 new.pbtout = TRUE;
1607 }
1608
1609 /* CW pitch */
1610 int
rig_data_has_get_cwpitch(void)1611 rig_data_has_get_cwpitch (void)
1612 {
1613 return has_get.cwpitch;
1614 }
1615
1616 int
rig_data_has_set_cwpitch(void)1617 rig_data_has_set_cwpitch (void)
1618 {
1619 return has_set.cwpitch;
1620 }
1621
1622 int
rig_data_get_cwpitch(void)1623 rig_data_get_cwpitch (void)
1624 {
1625 return get.cwpitch;
1626 }
1627
1628 void
rig_data_set_cwpitch(int cwp)1629 rig_data_set_cwpitch (int cwp)
1630 {
1631 set.cwpitch = cwp;
1632 get.cwpitch = cwp;
1633 new.cwpitch = TRUE;
1634 }
1635
1636
1637 /* keyer speed */
1638 int
rig_data_has_get_keyspd(void)1639 rig_data_has_get_keyspd (void)
1640 {
1641 return has_get.keyspd;
1642 }
1643
1644 int
rig_data_has_set_keyspd(void)1645 rig_data_has_set_keyspd (void)
1646 {
1647 return has_set.keyspd;
1648 }
1649
1650 int
rig_data_get_keyspd(void)1651 rig_data_get_keyspd (void)
1652 {
1653 return get.keyspd;
1654 }
1655
1656 void
rig_data_set_keyspd(int keyspd)1657 rig_data_set_keyspd (int keyspd)
1658 {
1659 set.keyspd = keyspd;
1660 get.keyspd = keyspd;
1661 new.keyspd = TRUE;
1662 }
1663
1664 /* break-in delay */
1665 int
rig_data_has_get_bkindel(void)1666 rig_data_has_get_bkindel (void)
1667 {
1668 return has_get.bkindel;
1669 }
1670
1671 int
rig_data_has_set_bkindel(void)1672 rig_data_has_set_bkindel (void)
1673 {
1674 return has_set.bkindel;
1675 }
1676
1677 int
rig_data_get_bkindel(void)1678 rig_data_get_bkindel (void)
1679 {
1680 return get.bkindel;
1681 }
1682
1683 void
rig_data_set_bkindel(int bkindel)1684 rig_data_set_bkindel (int bkindel)
1685 {
1686 set.bkindel = bkindel;
1687 get.bkindel = bkindel;
1688 new.bkindel = TRUE;
1689 }
1690
1691
1692 /* balance */
1693 int
rig_data_has_get_balance(void)1694 rig_data_has_get_balance (void)
1695 {
1696 return has_get.balance;
1697 }
1698
1699 int
rig_data_has_set_balance(void)1700 rig_data_has_set_balance (void)
1701 {
1702 return has_set.balance;
1703 }
1704
1705 float
rig_data_get_balance(void)1706 rig_data_get_balance (void)
1707 {
1708 return get.balance;
1709 }
1710
1711 void
rig_data_set_balance(float bal)1712 rig_data_set_balance (float bal)
1713 {
1714 set.balance = bal;
1715 get.balance = bal;
1716 new.balance = TRUE;
1717 }
1718
1719 /* VOX delay */
1720 int
rig_data_has_get_voxdel(void)1721 rig_data_has_get_voxdel (void)
1722 {
1723 return has_get.voxdel;
1724 }
1725
1726 int
rig_data_has_set_voxdel(void)1727 rig_data_has_set_voxdel (void)
1728 {
1729 return has_set.voxdel;
1730 }
1731
1732 int
rig_data_get_voxdel(void)1733 rig_data_get_voxdel (void)
1734 {
1735 return get.voxdel;
1736 }
1737
1738 void
rig_data_set_voxdel(int voxdel)1739 rig_data_set_voxdel (int voxdel)
1740 {
1741 set.voxdel = voxdel;
1742 get.voxdel = voxdel;
1743 new.voxdel = TRUE;
1744 }
1745
1746 /* VOX gain */
1747 int
rig_data_has_get_voxg(void)1748 rig_data_has_get_voxg (void)
1749 {
1750 return has_get.voxg;
1751 }
1752
1753 int
rig_data_has_set_voxg(void)1754 rig_data_has_set_voxg (void)
1755 {
1756 return has_set.voxg;
1757 }
1758
1759 float
rig_data_get_voxg(void)1760 rig_data_get_voxg (void)
1761 {
1762 return get.voxg;
1763 }
1764
1765 void
rig_data_set_voxg(float voxg)1766 rig_data_set_voxg (float voxg)
1767 {
1768 set.voxg = voxg;
1769 get.voxg = voxg;
1770 new.voxg = TRUE;
1771 }
1772
1773 /* anti VOX */
1774 int
rig_data_has_get_antivox(void)1775 rig_data_has_get_antivox (void)
1776 {
1777 return has_get.antivox;
1778 }
1779
1780 int
rig_data_has_set_antivox(void)1781 rig_data_has_set_antivox (void)
1782 {
1783 return has_set.antivox;
1784 }
1785
1786 float
rig_data_get_antivox(void)1787 rig_data_get_antivox (void)
1788 {
1789 return get.antivox;
1790 }
1791
1792 void
rig_data_set_antivox(float antivox)1793 rig_data_set_antivox (float antivox)
1794 {
1795 set.antivox = antivox;
1796 get.antivox = antivox;
1797 new.antivox = TRUE;
1798 }
1799
1800 /* MIC gain */
1801 int
rig_data_has_get_micg(void)1802 rig_data_has_get_micg (void)
1803 {
1804 return has_get.micg;
1805 }
1806
1807 int
rig_data_has_set_micg(void)1808 rig_data_has_set_micg (void)
1809 {
1810 return has_set.micg;
1811 }
1812
1813 float
rig_data_get_micg(void)1814 rig_data_get_micg (void)
1815 {
1816 return get.micg;
1817 }
1818
1819 void
rig_data_set_micg(float micg)1820 rig_data_set_micg (float micg)
1821 {
1822 set.micg = micg;
1823 get.micg = micg;
1824 new.micg = TRUE;
1825 }
1826
1827 /* compression */
1828 int
rig_data_has_get_comp(void)1829 rig_data_has_get_comp (void)
1830 {
1831 return has_get.comp;
1832 }
1833
1834 int
rig_data_has_set_comp(void)1835 rig_data_has_set_comp (void)
1836 {
1837 return has_set.comp;
1838 }
1839
1840 float
rig_data_get_comp(void)1841 rig_data_get_comp (void)
1842 {
1843 return get.comp;
1844 }
1845
1846 void
rig_data_set_comp(float comp)1847 rig_data_set_comp (float comp)
1848 {
1849 set.comp = comp;
1850 get.comp = comp;
1851 new.comp = TRUE;
1852 }
1853
1854
1855