From 199ff3dd3de1cd6b57630aa98362af18bd5758a8 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 10 Mar 2020 16:26:42 -0400 Subject: [PATCH] Experimental work-around for FT8 decoding on slow computers. Important changes: - don't start function decode() is decoder is already busy - send updated m_ihsym to jt9[.exe] via ss(1,1). Bill won't like this! - jt9 bails out of the 41-buffer pass at m_ihsym=45. --- lib/decoder.f90 | 2 +- lib/ft8_decode.f90 | 7 ++++--- lib/jt9a.f90 | 2 ++ widgets/mainwindow.cpp | 42 ++++++++++++++++++++++++++++++++++++++---- widgets/mainwindow.h | 5 +++-- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/lib/decoder.f90 b/lib/decoder.f90 index 7bbc285e1..f8c236cd0 100644 --- a/lib/decoder.f90 +++ b/lib/decoder.f90 @@ -108,7 +108,7 @@ subroutine multimode_decoder(ss,id2,params,nfsample) params%nftx,newdat,params%nutc,params%nfa,params%nfb, & params%nzhsym,params%ndepth,ncontest,logical(params%nagain), & logical(params%lft8apon),logical(params%lapcqonly), & - params%napwid,mycall,hiscall,hisgrid) + params%napwid,mycall,hiscall,hisgrid,ss(1,1)) call timer('decft8 ',1) if(nfox.gt.0) then n30min=minval(n30fox(1:nfox)) diff --git a/lib/ft8_decode.f90 b/lib/ft8_decode.f90 index dfdcc2060..58350d8e5 100644 --- a/lib/ft8_decode.f90 +++ b/lib/ft8_decode.f90 @@ -34,7 +34,7 @@ contains subroutine decode(this,callback,iwave,nQSOProgress,nfqso,nftx,newdat, & nutc,nfa,nfb,nzhsym,ndepth,ncontest,nagain,lft8apon,lapcqonly, & - napwid,mycall12,hiscall12,hisgrid6) + napwid,mycall12,hiscall12,hisgrid6,ss0) use timer_module, only: timer include 'ft8/ft8_params.f90' @@ -61,6 +61,7 @@ contains real xdt_save(MAX_EARLY) save s,dd,dd1,ndec_early,itone_save,f1_save,xdt_save,lsubtracted + volatile ss0 this%callback => callback write(datetime,1001) nutc !### TEMPORARY ### @@ -171,11 +172,11 @@ contains call this%callback(sync,nsnr,xdt,f1,msg37,iaptype,qual) endif endif + if(nint(ss0).eq.45) go to 800 !Bail out before finishing enddo enddo - ndec_early=0 +800 ndec_early=0 if(nzhsym.lt.50) ndec_early=ndecodes -! print*,'BBB',nzhsym,ndecodes 900 return end subroutine decode diff --git a/lib/jt9a.f90 b/lib/jt9a.f90 index 04e019a97..41aed3d9a 100644 --- a/lib/jt9a.f90 +++ b/lib/jt9a.f90 @@ -23,6 +23,7 @@ subroutine jt9a() type(dec_data), pointer :: shared_data type(params_block) :: local_params logical fileExists + volatile shared_data ! Multiple instances: i0 = len(trim(shm_key)) @@ -78,6 +79,7 @@ subroutine jt9a() endif ! Normal decoding pass call multimode_decoder(shared_data%ss,shared_data%id2,local_params,12000) +! print*,'AAA',shared_data%ss(1,1) call timer('decoder ',1) 100 inquire(file=trim(temp_dir)//'/.lock',exist=fileExists) diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 2c2bfa237..c14f94464 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -1411,6 +1411,10 @@ void MainWindow::dataSink(qint64 frames) m_dialFreqRxWSPR=m_freqNominal; } + if(m_mode=="FT8") { + to_jt9(m_ihsym); //Allow jt9 to bail out early, if necessary + } + if(m_ihsym==m_hsymStop or (m_mode=="FT8" and m_ihsym==m_earlyDecode and !m_diskData) or (m_mode=="FT8" and m_ihsym==m_earlyDecode2 and !m_diskData)) { if(m_mode=="Echo") { @@ -2079,7 +2083,12 @@ void MainWindow::keyPressEvent (QKeyEvent * e) return; } break; - case Qt::Key_PageUp: + case Qt::Key_Z: //### Recover from hung decode() ?? ### + if(e->modifiers() & Qt::AltModifier) { + decodeDone(); + return; + } + break; case Qt::Key_PageUp: break; case Qt::Key_PageDown: @@ -2816,6 +2825,7 @@ void MainWindow::msgAvgDecode2() void MainWindow::decode() //decode() { + if(m_decoderBusy) return; //Don't start decoder if it's already busy. QDateTime now = QDateTime::currentDateTimeUtc (); if( m_dateTimeLastTX.isValid () ) { qint64 isecs_since_tx = m_dateTimeLastTX.secsTo(now); @@ -2987,8 +2997,15 @@ void MainWindow::decode() //decode() dec_data.params.mycall,dec_data.params.hiscall,8000,12,12))); } else { memcpy(to, from, qMin(mem_jt9->size(), size)); + if(m_mode=="FT8") to_jt9(m_ihsym); //### TEMPORARY ? ### QFile {m_config.temp_dir ().absoluteFilePath (".lock")}.remove (); // Allow jt9 to start -// qDebug() << "aa" << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.s") << m_ihsym; + + auto now = QDateTime::currentDateTimeUtc(); + double tseq = fmod(double(now.toMSecsSinceEpoch() ),1000.0*m_TRperiod)/1000.0; + if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod; + if(m_ihsym==41) qDebug() << ""; + qDebug() << "aa" << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz") + << tseq << m_ihsym << m_ndepth << from_jt9(); decodeBusy(true); } } @@ -3018,7 +3035,6 @@ void::MainWindow::fast_decode_done() m_bDecoded=true; } postDecode (true, decodedtext.string ()); -// writeAllTxt(message); write_all("Rx",message); if(m_mode=="JT9" or m_mode=="MSK144") { @@ -3037,6 +3053,19 @@ void::MainWindow::fast_decode_done() m_bFastDone=false; } +void MainWindow::to_jt9(qint32 n) +{ + float ss0=n; + memcpy((char*)mem_jt9->data(),&ss0,4); +// qDebug() << "cc" << ss0 << "sent to jt9"; +} +qint32 MainWindow::from_jt9() +{ + float ss0; + memcpy(&ss0,(char*)mem_jt9->data(),4); + return int(ss0); +} + void MainWindow::decodeDone () { dec_data.params.nagain=0; @@ -3050,7 +3079,12 @@ void MainWindow::decodeDone () if(m_mode=="FT8" and dec_data.params.nzhsym==m_earlyDecode) m_blankLine=false; if(m_mode=="FT8" and dec_data.params.nzhsym==m_earlyDecode2) m_blankLine=false; if(SpecOp::FOX == m_config.special_op_id()) houndCallers(); -// qDebug() << "cc" << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz"); + + auto now = QDateTime::currentDateTimeUtc(); + double tseq = fmod(double(now.toMSecsSinceEpoch() ),1000.0*m_TRperiod)/1000.0; + if(tseq < 0.5*m_TRperiod) tseq+= m_TRperiod; + qDebug() << "bb" << QDateTime::currentDateTimeUtc().toString("hh:mm:ss.zzz") + << tseq << m_ihsym << from_jt9(); } void MainWindow::readFromStdout() //readFromStdout diff --git a/widgets/mainwindow.h b/widgets/mainwindow.h index ec66a6a99..2a257a448 100644 --- a/widgets/mainwindow.h +++ b/widgets/mainwindow.h @@ -759,8 +759,7 @@ private: qint64 nWidgets(QString t); void displayWidgets(qint64 n); void vhfWarning(); - QChar current_submode () const; // returns QChar {0} if sub mode is - // not appropriate + QChar current_submode () const; // returns QChar {0} if submode is not appropriate void write_transmit_entry (QString const& file_name); void selectHound(QString t); void houndCallers(); @@ -768,6 +767,8 @@ private: void foxTxSequencer(); void foxGenWaveform(int i,QString fm); void writeFoxQSO (QString const& msg); + void to_jt9(qint32 n); + qint32 from_jt9(); }; extern int killbyname(const char* progName);