From 05dd89c5523373bf7d66e2cdf374123251b44a14 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Sun, 3 Mar 2024 15:08:19 -0500 Subject: [PATCH] WIP on SuperFox transmit capability. --- CMakeLists.txt | 1 + lib/ft8/foxgen.f90 | 9 ++++--- lib/superfox/sfox_tx.f90 | 24 ++++++++++++++---- lib/superfox/sfox_wave.f90 | 35 ++++++++++++++++++++++++++ widgets/mainwindow.cpp | 51 +++++++++++--------------------------- widgets/mainwindow.h | 2 +- 6 files changed, 76 insertions(+), 46 deletions(-) create mode 100644 lib/superfox/sfox_wave.f90 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cdcfcb45..6dc064a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,6 +430,7 @@ set (wsjt_FSRCS lib/ft8/foxgen.f90 lib/superfox/foxgen2.f90 lib/superfox/sfox_assemble.f90 + lib/superfox/sfox_wave.f90 lib/ft8/foxgen_wrap.f90 lib/freqcal.f90 lib/ft8/ft8apset.f90 diff --git a/lib/ft8/foxgen.f90 b/lib/ft8/foxgen.f90 index 3251c8e94..5a78b8f78 100644 --- a/lib/ft8/foxgen.f90 +++ b/lib/ft8/foxgen.f90 @@ -1,4 +1,4 @@ -subroutine foxgen(bSuperFox,cmnd) +subroutine foxgen(bSuperFox,data_dir) ! Called from MainWindow::foxTxSequencer() to generate the Tx waveform in ! FT8 Fox mode. The Tx message can contain up to 5 "slots", each carrying @@ -18,7 +18,7 @@ subroutine foxgen(bSuperFox,cmnd) parameter (NWAVE=(160+2)*134400*4) !the biggest waveform we generate (FST4-1800 at 48kHz) parameter (NFFT=614400,NH=NFFT/2) logical*1 bSuperFox - character*120 cmnd + character*(*) data_dir character*40 cmsg character*37 msg,msgsent integer itone(79) @@ -32,7 +32,10 @@ subroutine foxgen(bSuperFox,cmnd) equivalence (x,cx),(y,cy) if(bSuperFox) then - call foxgen2(nslots,cmsg,cmnd) +! call foxgen2(nslots,cmsg,cmnd) + open(25,file=data_dir,status='unknown') + write(25,'(a40)') cmsg(1:nslots) + close(25) return endif diff --git a/lib/superfox/sfox_tx.f90 b/lib/superfox/sfox_tx.f90 index 431e9985c..e5017dcf6 100644 --- a/lib/superfox/sfox_tx.f90 +++ b/lib/superfox/sfox_tx.f90 @@ -1,9 +1,23 @@ program sfox_tx - character*120 line + character*120 fname + character*40 cmsg(5) + integer itone(151) + + call getarg(1,fname) + open(25,file=trim(fname),status='unknown') + do i=1,5 + read(25,1000,end=10) cmsg(i) +1000 format(a40) +! write(*,1000) cmsg(i) + enddo + +10 rewind(25) + do i=1,151 + itone(i)=i-1 + enddo + write(25,1100) itone +1100 format(20i4) + close(25) - call getarg(1,line) - write(*,1000) trim(line) -1000 format(a) - end program sfox_tx diff --git a/lib/superfox/sfox_wave.f90 b/lib/superfox/sfox_wave.f90 new file mode 100644 index 000000000..a603d81d9 --- /dev/null +++ b/lib/superfox/sfox_wave.f90 @@ -0,0 +1,35 @@ +subroutine sfox_wave(fname) + + parameter (NWAVE=(160+2)*134400*4) !Max WSJT-X waveform (FST4-1800 at 48kHz) + parameter (NN=151,NSPS=1024) + character*(*) fname + integer itone(151) + real*8 dt,twopi,f0,baud,phi,dphi + + common/foxcom/wave(NWAVE) + + open(25,file=trim(fname),status='unknown') + read(25,'(20i4)') itone + close(25) + +! Generate the SuperFox waveform. + + dt=1.d0/48000.d0 + twopi=8.d0*atan(1.d0) + f0=750.0d0 + phi=0.d0 + baud=12000.d0/NSPS + k=0 + do j=1,NN + f=f0 + baud*itone(j) + dphi=twopi*f*dt + do ii=1,NSPS + k=k+1 + phi=phi+dphi + xphi=phi + wave(k)=wave(k)+sin(xphi) + enddo + enddo + + return +end subroutine sfox_wave diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index a4d8cd54c..b0afade69 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -176,7 +176,9 @@ extern "C" { void calibrate_(char const * data_dir, int* iz, double* a, double* b, double* rms, double* sigmaa, double* sigmab, int* irc, fortran_charlen_t); - void foxgen_(bool* bSuperFox, char* cmnd, fortran_charlen_t); + void foxgen_(bool* bSuperFox, char const * fname, FCL len); + + void sfox_wave_(char const * fname, FCL len); void plotsave_(float swide[], int* m_w , int* m_h1, int* irow); @@ -4824,12 +4826,9 @@ void MainWindow::guiUpdate() QString foxCall=m_config.my_callsign() + " "; ::memcpy(foxcom_.mycall, foxCall.toLatin1(), sizeof foxcom_.mycall); //Copy Fox callsign into foxcom_ bool bSuperFox=m_config.superFox(); - char cmnd[120]; - foxgen_(&bSuperFox, cmnd, 120); - if(bSuperFox) { - QString t=QString::fromLatin1(cmnd).trimmed(); - sfox_tx(t); - } + auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir().absoluteFilePath("sfox.dat")).toLocal8Bit()}; + foxgen_(&bSuperFox, fname.constData(), (FCL)fname.size()); + if(bSuperFox) sfox_tx(); } } } @@ -10304,13 +10303,9 @@ Transmit: QString foxCall=m_config.my_callsign() + " "; ::memcpy(foxcom_.mycall, foxCall.toLatin1(),sizeof foxcom_.mycall); //Copy Fox callsign into foxcom_ bool bSuperFox=m_config.superFox(); -// qDebug() << "bb" << foxcom_.nslots << foxcom_.mycall << foxcom_.cmsg[0]; - char cmnd[120]; - foxgen_(&bSuperFox, cmnd, 120); - if(bSuperFox) { - QString t=QString::fromLatin1(cmnd).trimmed(); - sfox_tx(t); - } + auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir().absoluteFilePath("sfox.dat")).toLocal8Bit()}; + foxgen_(&bSuperFox, fname.constData(), (FCL)fname.size()); + if(bSuperFox) sfox_tx(); m_tFoxTxSinceCQ++; for(QString hc: m_foxQSO.keys()) { //Check for strikeout or timeout @@ -10886,30 +10881,12 @@ void MainWindow::on_jt65Button_clicked() on_actionJT65_triggered(); } -void MainWindow::sfox_tx(QString t) +void MainWindow::sfox_tx() { // qint64 ms0 = QDateTime::currentMSecsSinceEpoch(); - p2.start("sfox_tx", QStringList {t}); + auto fname {QDir::toNativeSeparators(m_config.writeable_data_dir().absoluteFilePath("sfox.dat")).toLocal8Bit()}; + p2.start("sfox_tx", QStringList {fname}); p2.waitForFinished(); - QString t2=p2.readAllStandardOutput(); - t2=t2.left(t2.length()-2); -// qDebug() << "aa" << QDateTime::currentMSecsSinceEpoch() - ms0 << t2; -// qDebug() << "aa" << t2; - p4.start("sfox_tx2",QStringList {""}); - p4.waitForStarted(); - QString t0; - for(int i=0; i