mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-27 14:48:46 -05:00
Fix the "changed modes" problem in soundout.cpp.
Move the ptt function into the Qt-managed code. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@2699 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
3e23c06913
commit
a1387d0a1f
Binary file not shown.
47
getfile.cpp
47
getfile.cpp
@ -3,6 +3,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <windows.h>
|
||||
|
||||
void getfile(QString fname, int ntrperiod)
|
||||
{
|
||||
@ -114,3 +115,49 @@ float gran()
|
||||
iset++;
|
||||
return v2*fac;
|
||||
}
|
||||
|
||||
int ptt(int nport, int ntx, int *iptt)
|
||||
{
|
||||
static HANDLE hFile;
|
||||
static int open=0;
|
||||
char s[10];
|
||||
int i3=1,i4=1,i5=1,i6=1,i9=1,i00=1;
|
||||
|
||||
if(nport==0) {
|
||||
*iptt=ntx;
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(ntx && (!open)) {
|
||||
sprintf(s,"COM%d",nport);
|
||||
hFile=CreateFile(TEXT(s),GENERIC_WRITE,0,NULL,OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
if(hFile==INVALID_HANDLE_VALUE) {
|
||||
// printf("PTT: Cannot open COM port %d.\n",nport);
|
||||
return 1;
|
||||
}
|
||||
open=1;
|
||||
}
|
||||
|
||||
if(ntx && open) {
|
||||
i3=EscapeCommFunction(hFile,SETRTS);
|
||||
i5=EscapeCommFunction(hFile,SETDTR);
|
||||
*iptt=1;
|
||||
}
|
||||
|
||||
else {
|
||||
i4=EscapeCommFunction(hFile,CLRRTS);
|
||||
i6=EscapeCommFunction(hFile,CLRDTR);
|
||||
i9=EscapeCommFunction(hFile,CLRBREAK);
|
||||
i00=CloseHandle(hFile);
|
||||
*iptt=0;
|
||||
open=0;
|
||||
}
|
||||
if(i3==0) return -(SETRTS);
|
||||
if(i4==0) return -(CLRRTS);
|
||||
if(i5==0) return -(SETDTR);
|
||||
if(i6==0) return -(CLRDTR);
|
||||
if(i9==0) return -(CLRBREAK);
|
||||
if(i00==0) return -10;
|
||||
return 0;
|
||||
}
|
||||
|
@ -8,5 +8,6 @@
|
||||
void getfile(QString fname, int ntrperiod);
|
||||
void savetf2(QString fname, int ntrperiod);
|
||||
float gran();
|
||||
int ptt(int* nport, int* ntx, int* iptt);
|
||||
|
||||
#endif // GETFILE_H
|
||||
|
16
lib/ptt.c
16
lib/ptt.c
@ -25,18 +25,24 @@ int ptt_(int *nport, int *ntx, int *iptt)
|
||||
}
|
||||
|
||||
if(*ntx && open) {
|
||||
EscapeCommFunction(hFile,3);
|
||||
EscapeCommFunction(hFile,5);
|
||||
i3=EscapeCommFunction(hFile,3);
|
||||
i5=EscapeCommFunction(hFile,5);
|
||||
*iptt=1;
|
||||
}
|
||||
|
||||
else {
|
||||
EscapeCommFunction(hFile,4);
|
||||
EscapeCommFunction(hFile,6);
|
||||
EscapeCommFunction(hFile,9);
|
||||
i4=EscapeCommFunction(hFile,4);
|
||||
i6=EscapeCommFunction(hFile,6);
|
||||
i9=EscapeCommFunction(hFile,9);
|
||||
i00=CloseHandle(hFile);
|
||||
*iptt=0;
|
||||
open=0;
|
||||
}
|
||||
if(i3==0) return 3;
|
||||
if(i4==0) return 4;
|
||||
if(i5==0) return 5;
|
||||
if(i6==0) return 6;
|
||||
if(i9==0) return 9;
|
||||
if(i00==0) return 10;
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "about.h"
|
||||
#include "widegraph.h"
|
||||
#include "sleep.h"
|
||||
#include "getfile.h"
|
||||
#include <portaudio.h>
|
||||
|
||||
int itone[85]; //Tx audio tones for 85 symbols
|
||||
@ -914,11 +915,11 @@ void MainWindow::guiUpdate()
|
||||
|
||||
if(bTxTime and iptt==0 and !m_txMute) {
|
||||
int itx=1;
|
||||
int ierr = ptt_(&m_pttPort,&itx,&iptt); // Raise PTT
|
||||
if(ierr != 0) {
|
||||
int ierr = ptt(m_pttPort,itx,&iptt); // Raise PTT
|
||||
if(ierr<0) {
|
||||
on_stopTxButton_clicked();
|
||||
char s[18];
|
||||
sprintf(s,"Cannot open COM%d",m_pttPort);
|
||||
sprintf(s,"PTT Error %d",ierr);
|
||||
msgBox(s);
|
||||
}
|
||||
if(!soundOutThread.isRunning()) {
|
||||
@ -985,7 +986,12 @@ void MainWindow::guiUpdate()
|
||||
if(nc0 <= 0) nc0++;
|
||||
if(nc0 == 0) {
|
||||
int itx=0;
|
||||
ptt_(&m_pttPort,&itx,&iptt); // Lower PTT
|
||||
int ierr=ptt(m_pttPort,itx,&iptt); // Lower PTT
|
||||
if(ierr<0) {
|
||||
char s[18];
|
||||
sprintf(s,"PTT Error %d",ierr);
|
||||
msgBox(s);
|
||||
}
|
||||
if(!m_txMute) soundOutThread.quitExecution=true;
|
||||
m_transmitting=false;
|
||||
if(m_auto) {
|
||||
|
@ -216,6 +216,8 @@ extern int killbyname(const char* progName);
|
||||
extern void getDev(int* numDevices,char hostAPI_DeviceName[][50],
|
||||
int minChan[], int maxChan[],
|
||||
int minSpeed[], int maxSpeed[]);
|
||||
extern int ptt(int nport, int itx, int* iptt);
|
||||
|
||||
|
||||
extern "C" {
|
||||
//----------------------------------------------------- C and Fortran routines
|
||||
@ -227,8 +229,6 @@ void symspec_(int* k, int* ntrperiod, int* nsps, int* nb, int* m_NBslider,
|
||||
void genjt9_(char* msg, char* msgsent, int itone[], int len1, int len2);
|
||||
|
||||
void decoder_(int* ntrperiod, int* mRxLog, float c0[]);
|
||||
|
||||
int ptt_(int* nport, int* itx, int* iptt);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -32,14 +32,16 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
|
||||
short *wptr = (short*)outputBuffer;
|
||||
|
||||
static double twopi=2.0*3.141592653589793238462;
|
||||
static double baud=12000.0/udata->nsps;
|
||||
static double baud;
|
||||
static double phi=0.0;
|
||||
static double dphi;
|
||||
static double freq;
|
||||
static double snr;
|
||||
static double fac;
|
||||
static int ic=0;
|
||||
static int isym0=-99;
|
||||
static short int i2;
|
||||
int isym;
|
||||
|
||||
if(udata->bRestart) {
|
||||
// Time according to this computer
|
||||
@ -49,8 +51,9 @@ extern "C" int d2aCallback(const void *inputBuffer, void *outputBuffer,
|
||||
ic=(mstr-1000)*12;
|
||||
udata->bRestart=false;
|
||||
}
|
||||
int isym=ic/udata->nsps;
|
||||
isym=ic/udata->nsps;
|
||||
if(isym>=85) return 0;
|
||||
baud=12000.0/udata->nsps;
|
||||
freq=udata->ntxfreq + itone[isym]*baud;
|
||||
dphi=twopi*freq/12000.0;
|
||||
if(udata->txsnrdb < 0.0) {
|
||||
|
Loading…
Reference in New Issue
Block a user