- Initial changes to add string names of audio devices/PTT ports

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/trunk@164 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Diane Bruce 2006-04-15 05:39:08 +00:00
parent f9ea0f6c43
commit c7938b6db6
7 changed files with 82 additions and 44 deletions

View File

@ -70,7 +70,7 @@ subroutine audio_init(ndin,ndout)
! print*,'Audio INIT called.'
ierr=start_threads(ndevin,ndevout,y1,y2,nmax,iwrite,iwave,nwave, &
11025,NSPB,TRPeriod,TxOK,ndebug,Transmitting, &
Tsec,ngo,nmode,tbuf,ibuf,ndsec)
Tsec,ngo,nmode,tbuf,ibuf,ndsec,PttPort,devin_name,devout_name)
#endif

View File

@ -40,12 +40,13 @@ integer nx !x coordinate for waterfall pixmap GUI
integer mfsample !Measured sample rate, input SoundIn
integer mfsample2 !Measured sample rate, output SoundOut
integer ns0 !Time at last ALL.TXT date entry Decoder
character*12 devin_name,devout_name ! GUI
common/gcom1/Tbuf(1024),ntrbuf(1024),Tsec,rxdelay,txdelay, &
samfacin,samfacout,txsnrdb,y1(NRXMAX),y2(NRXMAX), &
nmax,iwrite,iread,iwave(NTXMAX),nwave,TxOK,Receiving,Transmitting, &
TxFirst,TRPeriod,ibuf,ibuf0,ave,rms,ngo,level,mute,newdat,ndsec, &
ndevin,ndevout,nx,mfsample,mfsample2,ns0
ndevin,ndevout,nx,mfsample,mfsample2,ns0,devin_name,devout_name
!### volatile /gcom1/

View File

@ -79,6 +79,7 @@ character*24 decodedfile
character*80 AppDir !WSJT installation directory GUI
character*80 filetokilla !Filenames (full path) Decoder
character*80 filetokillb
character*12 pttport
common/gcom2/ps0(431),psavg(450),s2(64,3100),ccf(-5:540), &
green(500),ngreen,dgain,iter,ndecoding,ndecoding0,mousebutton, &
@ -90,6 +91,6 @@ common/gcom2/ps0(431),psavg(450),s2(64,3100),ccf(-5:540), &
idinterval,msmax,lenappdir,ndiskdat,nlines,nflat,ntxreq,ntxnow, &
ndepth,nspecial,ndf,ss1(-224:224),ss2(-224:224), &
mycall,hiscall,hisgrid,txmsg,sending,mode,fname0,fnamea, &
fnameb,decodedfile,AppDir,filetokilla,filetokillb,utcdate
fnameb,decodedfile,AppDir,filetokilla,filetokillb,utcdate,pttport
!### volatile /gcom2/

View File

@ -25,8 +25,11 @@ MyGrid=StringVar()
#TxDelay=StringVar()
IDinterval=IntVar()
ComPort=IntVar()
PttPort=StringVar()
ndevin=IntVar()
ndevout=IntVar()
DevinName=StringVar()
DevoutName=StringVar()
samfacin=DoubleVar()
samfacout=DoubleVar()
Template1=StringVar()
@ -106,12 +109,12 @@ mygrid=Pmw.EntryField(g1.interior(),labelpos=W,label_text='Grid Locator:',
## value='0.2',entry_textvariable=TxDelay)
idinterval=Pmw.EntryField(g1.interior(),labelpos=W,label_text='ID Interval (m):',
value=10,entry_textvariable=IDinterval,entry_width=12)
comport=Pmw.EntryField(g1.interior(),labelpos=W,label_text='COM Port:',
value=1,entry_textvariable=ComPort,entry_width=12)
comport=Pmw.EntryField(g1.interior(),labelpos=W,label_text='PTT Port:',
value='1',entry_textvariable=PttPort,entry_width=12)
audioin=Pmw.EntryField(g1.interior(),labelpos=W,label_text='Audio In:',
value=0,entry_textvariable=ndevin,entry_width=12)
value='0',entry_textvariable=DevinName,entry_width=12)
audioout=Pmw.EntryField(g1.interior(),labelpos=W,label_text='Audio Out:',
value=0,entry_textvariable=ndevout,entry_width=12)
value='0',entry_textvariable=DevoutName,entry_width=12)
ratein=Pmw.EntryField(g1.interior(),labelpos=W,label_text='Rate In:',
value=1.0000,entry_textvariable=samfacin,entry_width=12)
rateout=Pmw.EntryField(g1.interior(),labelpos=W,label_text='Rate Out:',

View File

@ -489,10 +489,19 @@ if g.cmap == "AFMHot":
#---------------------------------------------- Display GUI and start mainloop
draw_axis()
Audio.gcom1.ndevin=g.ndevin.get()
Audio.gcom1.ndevout=g.ndevout.get()
ndevin=g.ndevin.get()
ndevout=g.ndevout.get()
try:
ndevin=g.ndevin.get()
except:
ndevin=0
Audio.gcom1.ndevin=ndevin
try:
ndevout=g.ndevout.get()
except:
ndevout=0
Audio.gcom1.ndevout=ndevout
# Only valid for windows
# for now
Audio.audio_init(ndevin,ndevout) #Start the audio stream
ltime.after(200,update)

View File

@ -80,7 +80,8 @@ start_threads_(int *ndevin, int *ndevout, short y1[], short y2[],
int *nwave, int *nfsample, int *nsamperbuf,
int *TRPeriod, int *TxOK, int *ndebug,
int *Transmitting, double *Tsec, int *ngo, int *nmode,
double tbuf[], int *ibuf, int *ndsec)
double tbuf[], int *ibuf, int *ndsec,
char *PttPort, char *devin_name, char *devout_name)
{
pthread_t thread1,thread2;
int iret1,iret2;
@ -90,32 +91,35 @@ start_threads_(int *ndevin, int *ndevout, short y1[], short y2[],
int format;
int channels;
double dnfs;
int i;
char *p;
p = strchr(devin_name, ' ');
if(p != NULL)
*p = '\0';
p = strchr(devin_name, '/');
if(p != NULL)
snprintf(dsp_in, MAXDSPNAME, "%s", devin_name); /* assume /dev/... */
else
snprintf(dsp_in, MAXDSPNAME, "/dev/%s", devin_name);
/* XXX OSS device is decoded from ndevin and ndevout
* This is not strictly speaking the way to do it and is
* probably specific to FreeBSD for now.
* i.e. the .0 addition is a vchan; I'll add configure magic later. --db
*/
snprintf(dsp_in, MAXDSPNAME,
"/dev/dsp%d.0", *ndevin);
dsp_in[MAXDSPNAME] = '\0';
data.fd_in = open (dsp_in, O_RDWR, 0);
if (data.fd_in < 0) {
fprintf(stderr, "Cannot open %s for input.\n", dsp_in);
exit(-1);
return(-1);
}
if (*ndevin == *ndevout) {
data.fd_out = data.fd_in;
strncpy(dsp_out, dsp_in, sizeof(dsp_out));
dsp_out[sizeof(dsp_out)] = '\0';
data.fd_out = data.fd_in;
strncpy(dsp_out, dsp_in, sizeof(dsp_out));
dsp_out[sizeof(dsp_out)] = '\0';
if (ioctl(data.fd_in, SNDCTL_DSP_SETDUPLEX, 0) < 0) {
fprintf(stderr, "Cannot use %s for full duplex.\n", dsp_in);
exit(-1);
}
if (ioctl(data.fd_in, SNDCTL_DSP_SETDUPLEX, 0) < 0) {
fprintf(stderr, "Cannot use %s for full duplex.\n", dsp_in);
return(-1);
}
data.Tsec = Tsec;
@ -140,23 +144,23 @@ start_threads_(int *ndevin, int *ndevout, short y1[], short y2[],
channels = 2;
if (ioctl (data.fd_in, SNDCTL_DSP_CHANNELS, &channels) == -1) {
fprintf (stderr, "Unable to set 2 channels for input.\n");
exit (-1);
return (-1);
}
if (channels != 2) {
fprintf (stderr, "Unable to set 2 channels.\n");
exit (-1);
return (-1);
}
format = AFMT_S16_NE;
if (ioctl (data.fd_in, SNDCTL_DSP_SETFMT, &format) == -1) {
fprintf (stderr, "Unable to set format for input.\n");
exit (-1);
return (-1);
}
if (ioctl (data.fd_in, SNDCTL_DSP_SPEED, &rate) == -1) {
fprintf (stderr, "Unable to set rate for input\n");
exit (-1);
return (-1);
}
printf("Audio OSS streams running normally.\n");
@ -214,7 +218,7 @@ oss_loop(int *iarg)
nread = read (data.fd_in, rcv_buf, AUDIOBUFSIZE);
if (nread <= 0) {
fprintf(stderr, "Read error %d\n", nread);
exit(-1);
return (-1);
}
if (nread == AUDIOBUFSIZE) {
/* Get System time */
@ -281,7 +285,7 @@ oss_loop(int *iarg)
if (write(data.fd_out, tx_buf, AUDIOBUFSIZE) < 0) {
fprintf(stderr, "Can't write to soundcard.\n");
exit(-1);
return (-1);
}
fivehztx_(); /* Call fortran routine */
}

40
wsjt.py
View File

@ -98,6 +98,8 @@ g.freeze_decode=0
g.mode=""
g.ndevin=IntVar()
g.ndevout=IntVar()
g.DevinName=StringVar()
g.DevoutName=StringVar()
g.focus=0
#------------------------------------------------------ showspecjt
def showspecjt(event=NONE):
@ -1512,7 +1514,7 @@ def update():
Audio.gcom2.nslim2=isync-4
if nosh441.get()==1 and mode.get()=='FSK441': Audio.gcom2.nslim2=99
try:
Audio.gcom2.nport=int(options.ComPort.get())
Audio.gcom2.nport=options.ComPort.get()
except:
Audio.gcom2.nport=0
@ -2013,17 +2015,35 @@ try:
# elif key == 'TxDelay': options.TxDelay.set(value)
elif key == 'IDinterval': options.IDinterval.set(value)
elif key == 'ComPort':
options.ComPort.set(value)
Audio.gcom2.nport=int(options.ComPort.get())
try:
options.ComPort.set(value)
Audio.gcom2.nport=options.ComPort.get()
except:
options.ComPort.set(0)
Audio.gcom2.nport=0
Audio.gcom2.PttPort=options.ComPort.get()
elif key == 'Mileskm': options.mileskm.set(value)
elif key == 'MsgStyle': options.ireport.set(value)
elif key == 'Region': options.iregion.set(value)
elif key == 'AudioIn':
g.ndevin.set(value)
options.ndevin.set(value)
try:
g.ndevin.set(value)
except:
g.ndevin.set(0)
g.DevinName.set(value)
options.DevinName.set(value)
Audio.gcom1.devin_name=(options.DevinName.get()+' ')[:12]
elif key == 'AudioOut':
g.ndevout.set(value)
options.ndevout.set(value)
try:
g.ndevout.set(value)
Audio.gcom1.devout_name=(options.DevoutName.get()+' ')[:12]
except:
g.ndevout.set(0)
g.DevoutName.set(value)
options.DevoutName.set(value)
Audio.gcom1.devout_name=(options.DevoutName.get()+' ')[:12]
elif key == 'SamFacIn': options.samfacin.set(value)
elif key == 'SamFacOut': options.samfacout.set(value)
elif key == 'Template1': options.Template1.set(value.replace("_"," "))
@ -2113,12 +2133,12 @@ f.write("HisGrid " + t + "\n")
#f.write("RxDelay " + str(options.RxDelay.get()) + "\n")
#f.write("TxDelay " + str(options.TxDelay.get()) + "\n")
f.write("IDinterval " + str(options.IDinterval.get()) + "\n")
f.write("ComPort " + str(options.ComPort.get()) + "\n")
f.write("ComPort " + options.PttPort.get() + "\n")
f.write("Mileskm " + str(options.mileskm.get()) + "\n")
f.write("MsgStyle " + str(options.ireport.get()) + "\n")
f.write("Region " + str(options.iregion.get()) + "\n")
f.write("AudioIn " + str(options.ndevin.get()) + "\n")
f.write("AudioOut " + str(options.ndevout.get()) + "\n")
f.write("AudioIn " + options.DevinName.get() + "\n")
f.write("AudioOut " + options.DevoutName.get() + "\n")
f.write("SamFacIn " + str(options.samfacin.get()) + "\n")
f.write("SamFacOut " + str(options.samfacout.get()) + "\n")
if options.Template6.get()=="": options.Template6.set("_")