@@ -121,6 +121,7 @@ void ptt_set_debug(int debug)
121
121
* PTT_METHOD_SERIAL - serial (com) port.
122
122
* PTT_METHOD_GPIO - general purpose I/O.
123
123
* PTT_METHOD_LPT - Parallel printer port.
124
+ * PTT_METHOD_HAMLIB - HAMLib rig control.
124
125
*
125
126
* ptt_device Name of serial port device.
126
127
* e.g. COM1 or /dev/ttyS0.
@@ -173,6 +174,7 @@ void ptt_init (struct audio_s *audio_config_p)
173
174
174
175
strcpy (otnames [OCTYPE_PTT ], "PTT" );
175
176
strcpy (otnames [OCTYPE_DCD ], "DCD" );
177
+ strcpy (otnames [OCTYPE_RIG ], "RIG" );
176
178
strcpy (otnames [OCTYPE_FUTURE ], "FUTURE" );
177
179
178
180
@@ -314,7 +316,7 @@ void ptt_init (struct audio_s *audio_config_p)
314
316
#else
315
317
316
318
/*
317
- * Does any of them use GPIO?
319
+ * Does any of them use GPIO or HAMLIB ?
318
320
*/
319
321
320
322
using_gpio = 0 ;
@@ -561,6 +563,36 @@ void ptt_init (struct audio_s *audio_config_p)
561
563
562
564
#endif /* x86 Linux */
563
565
566
+ #ifdef USE_HAMLIB
567
+ for (ch = 0 ; ch < MAX_CHANS ; ch ++ ) {
568
+ if (save_audio_config_p -> achan [ch ].valid ) {
569
+ int ot , retcode ;
570
+ RIG * rig ;
571
+ freq_t freq ;
572
+
573
+ for (ot = 0 ; ot < NUM_OCTYPES ; ot ++ ) {
574
+ if (audio_config_p -> achan [ch ].octrl [ot ].ptt_method == PTT_METHOD_HAMLIB ) {
575
+ if (audio_config_p -> achan [ch ].octrl [ot ].ptt_rig - 1 >= audio_config_p -> rigs ) {
576
+ text_color_set (DW_COLOR_ERROR );
577
+ dw_printf ("Error: RIG %d not available.\n" , audio_config_p -> achan [ch ].octrl [ot ].ptt_rig );
578
+ audio_config_p -> achan [ch ].octrl [ot ].ptt_method = PTT_METHOD_NONE ;
579
+ }
580
+
581
+ rig = audio_config_p -> rig [audio_config_p -> achan [ch ].octrl [ot ].ptt_rig ];
582
+ retcode = rig_get_freq (rig , RIG_VFO_CURR , & freq );
583
+ if (retcode == RIG_OK ) {
584
+ text_color_set (DW_COLOR_INFO );
585
+ dw_printf ("RIG tuned on %" PRIfreq "\n" , freq );
586
+ } else {
587
+ text_color_set (DW_COLOR_ERROR );
588
+ dw_printf ("RIG rig_get_freq error %s, PTT probably will not work\n" , rigerror (retcode ));
589
+ }
590
+ }
591
+ }
592
+ }
593
+ }
594
+ #endif
595
+
564
596
565
597
/* Why doesn't it transmit? Probably forgot to specify PTT option. */
566
598
@@ -586,7 +618,7 @@ void ptt_init (struct audio_s *audio_config_p)
586
618
* probably be renamed something like octrl_set.
587
619
*
588
620
* Inputs: ot - Output control type:
589
- * OCTYPE_PTT, OCTYPE_DCD, OCTYPE_FUTURE
621
+ * OCTYPE_PTT, OCTYPE_DCD, OCTYPE_HAMLIB, OCTYPE_FUTURE
590
622
*
591
623
* chan - channel, 0 .. (number of channels)-1
592
624
*
@@ -758,6 +790,24 @@ void ptt_set (int ot, int chan, int ptt_signal)
758
790
759
791
#endif /* x86 Linux */
760
792
793
+ #ifdef USE_HAMLIB
794
+ /*
795
+ * Using hamlib?
796
+ */
797
+
798
+ if (save_audio_config_p -> achan [chan ].octrl [ot ].ptt_method == PTT_METHOD_HAMLIB ) {
799
+ int retcode ;
800
+ RIG * rig = save_audio_config_p -> rig [save_audio_config_p -> achan [chan ].octrl [ot ].ptt_rig ];
801
+
802
+ if ((retcode = rig_set_ptt (rig , RIG_VFO_CURR , ptt ? RIG_PTT_ON : RIG_PTT_OFF )) != RIG_OK ) {
803
+ text_color_set (DW_COLOR_ERROR );
804
+ dw_printf ("Error sending rig_set_ptt command for channel %d %s\n" , chan , otnames [ot ]);
805
+ dw_printf ("%s\n" , rigerror (retcode ));
806
+ }
807
+ }
808
+
809
+ #endif
810
+
761
811
762
812
} /* end ptt_set */
763
813
@@ -803,6 +853,31 @@ void ptt_term (void)
803
853
}
804
854
}
805
855
}
856
+
857
+ #ifdef USE_HAMLIB
858
+ for (n = 0 ; n < save_audio_config_p -> rigs ; n ++ ) {
859
+ RIG * rig = save_audio_config_p -> rig [n ];
860
+ int retcode ;
861
+
862
+ if ((retcode = rig_set_ptt (rig , RIG_VFO_CURR , RIG_PTT_OFF )) != RIG_OK ) {
863
+ text_color_set (DW_COLOR_ERROR );
864
+ dw_printf ("Error sending rig_set_ptt command for rig %d\n" , n );
865
+ dw_printf ("%s\n" , rigerror (retcode ));
866
+ }
867
+
868
+ if ((retcode = rig_close (rig )) != RIG_OK ) {
869
+ text_color_set (DW_COLOR_ERROR );
870
+ dw_printf ("Error sending rig_close command for rig %d\n" , n );
871
+ dw_printf ("%s\n" , rigerror (retcode ));
872
+ }
873
+
874
+ if ((retcode = rig_cleanup (rig )) != RIG_OK ) {
875
+ text_color_set (DW_COLOR_ERROR );
876
+ dw_printf ("Error sending rig_cleanup command for rig %d\n" , n );
877
+ dw_printf ("%s\n" , rigerror (retcode ));
878
+ }
879
+ }
880
+ #endif
806
881
}
807
882
808
883
0 commit comments