¿ªÔÆÌåÓý

rs232 ptt rts (like /dev/ttyUSB0) interface support #sBitx


 

good day. please tell me how to add USB (like /dev/ttyUSB0) rs232 ptt interface support for my amplifier.


 

¿ªÔÆÌåÓý

Could you not simply use a USB-to-9pin serial adapter/cable??????

Something like:

?- de AI4AI

On 3/22/24 18:02, zlamers via groups.io wrote:

good day. please tell me how to add USB (like /dev/ttyUSB0) rs232 ptt interface support for my amplifier.


 



I meant how to add to the code to sbitx control the amplifier via USB RTS

----------------------------------------------------------------------------------------------------------------

#include <stdio.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <fcntl.h>

int PTTport,level = 0;


// set RTS level, return -1 if error
// termios.h
int set_RTS(int level, int *fd)
{
	int serline;
    ioctl (*fd, TIOCMGET, &serline);
	if (level == 1) 
	{ 
 	  serline |= TIOCM_RTS;
	  return ioctl (*fd, TIOCMSET, &serline);
	}
	if (level == 0) 
	{ 
 	  serline &= ~TIOCM_RTS;
	  return ioctl (*fd, TIOCMSET, &serline);
	}
	return -1;
}

int openserial(char *serial)
{
 PTTport = open(serial, O_RDWR | O_NOCTTY | O_NONBLOCK | O_NDELAY);
 if (PTTport <0) 
	{
	 perror(serial); 
     printf("error open device [%s]\n\n",serial);
	 return -1;	
	}
  return 1;
}


int main(int argc, char *argv[])
{
		if (argc == 1)
	{
		printf("\nuse like ttyptt /dev/ttyPTT X (X=0 - set PTT-RTS off, X=1 - PTT-RTS ON)\n\n");
		return(0);
	} 

	if (openserial(argv[1]) < 1) return -1;		 

	if (*argv[2]=='1') level=1;
				  else level=0;
	set_RTS(level,&PTTport);

	return (0);
}


 

It might be easier to tap into the 12-volt transmit level on Q9.? ?I assume the transistor TR1 can take 12 volts through the 2.2k resistor without issue.

73
Evan
AC9TU


 


I'm not a programmer, I wrote this so can someone correct the mistakes?


-------------------------------------------------------------------------------------------------------------------------
diff --git a/sbitx.c b/sbitx.c.new
index 36fac58..f05cecf 100644
--- a/sbitx.c
+++ b/sbitx.c.new
@@ -10,6 +10,7 @@
?#include <wiringSerial.h>
?#include <linux/types.h>
?#include <linux/limits.h>
+#include <sys/ioctl.h>
?#include <stdint.h>
?#include <time.h>
?#include <signal.h>
@@ -68,6 +69,8 @@ fftw_complex *fft_m;????????????????? // holds previous samples for overlap and discard convolu
?fftw_plan plan_fwd, plan_tx;
?int bfo_freq = 40035000;
?int freq_hdr = -1;
+int fd;
+int RTS_flag = TIOCM_RTS;
?
?static double volume?? = 100.0;
?static int tx_drive = 40;
@@ -1187,6 +1190,8 @@ void tr_switch_v2(int tx_on){
??????????????????????? mute_count = 20;
??????????????????????? tx_process_restart = 1;
??????????????????????? digitalWrite(TX_LINE, HIGH);
+?????????????????????? fd = open("/dev/ttyUSB_PTT",O_RDWR | O_NOCTTY );
+?????????????????????? ioctl(fd, TIOCMBIS, &RTS_flag);
?????? delay(20);
??????????????????????? set_tx_power_levels();
??????????????????????? in_tx = 1;
@@ -1212,6 +1217,8 @@ void tr_switch_v2(int tx_on){
??????????????????????? delay(10);
??????????????????????? //power down the PA chain to null any gain
??????????????????????? digitalWrite(TX_LINE, LOW);
+?????????????????????? ioctl(fd, TIOCMBIC, &RTS_flag);
+?????????????????????? close(fd);
??????????????????????? delay(5);
??????????????????????? //audio codec is back on
??????????????????????? sound_mixer(audio_card, "Master", rx_vol)
---------------------------------------------------------------------------------------------------------------------------------