diff --git a/WSJT-X_Quick_Start_Guide.docx b/WSJT-X_Quick_Start_Guide.docx index b3ed855ea..0dddcbc18 100644 Binary files a/WSJT-X_Quick_Start_Guide.docx and b/WSJT-X_Quick_Start_Guide.docx differ diff --git a/getfile.cpp b/getfile.cpp index 9468832a6..67f419546 100644 --- a/getfile.cpp +++ b/getfile.cpp @@ -3,6 +3,7 @@ #include #include #include +#include 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; +} diff --git a/getfile.h b/getfile.h index 7c6d8e629..38283538d 100644 --- a/getfile.h +++ b/getfile.h @@ -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 diff --git a/lib/ptt.c b/lib/ptt.c index d0ee0cb1e..c03054ba1 100644 --- a/lib/ptt.c +++ b/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; } diff --git a/mainwindow.cpp b/mainwindow.cpp index f11e756ed..08a10b7da 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -6,6 +6,7 @@ #include "about.h" #include "widegraph.h" #include "sleep.h" +#include "getfile.h" #include 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) { diff --git a/mainwindow.h b/mainwindow.h index e6cfe90d0..08504a1f1 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -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 diff --git a/soundout.cpp b/soundout.cpp index c1b2a4285..9a0734ea8 100644 --- a/soundout.cpp +++ b/soundout.cpp @@ -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) {