WIP on SuperFox integration into WSJT-X.

This commit is contained in:
Joe Taylor 2024-03-02 14:24:45 -05:00
parent b495531f78
commit 027b84f047
5 changed files with 94 additions and 47 deletions

View File

@ -1,4 +1,4 @@
subroutine foxgen(bSuperFox)
subroutine foxgen(bSuperFox,cmnd)
! 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,6 +18,7 @@ subroutine foxgen(bSuperFox)
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*40 cmsg
character*37 msg,msgsent
integer itone(79)
@ -31,7 +32,7 @@ subroutine foxgen(bSuperFox)
equivalence (x,cx),(y,cy)
if(bSuperFox) then
call foxgen2(nslots,cmsg)
call foxgen2(nslots,cmsg,cmnd)
return
endif

View File

@ -1,24 +1,25 @@
subroutine foxgen2(nslots,cmsg)
subroutine foxgen2(nslots,cmsg,line)
! Called from foxgen() when it's time to encode a SuperFox message and
! generate the waveform to be transmitted. We need to parse the old-style
! Fox messages and extract the necessary pieces.
use packjt77
character*120 line
character*40 cmsg(5) !Old-style Fox messages are here
character*37 msg
character*22 sfmsg
character*12 mycall
character*26 sfmsg
character*13 mycall
character*4 mygrid
character*6 hiscall_1,hiscall_2
character*4 rpt_1,rpt_2
character*4 rpt1,rpt2
character*13 w(19)
integer nw(19)
integer ntype !Message type: 0 Free Text
! 1 CQ MyCall MyGrid
! 2 Call_1 MyCall RR73
! 3 Call_1 MyCall rpt_1
! 4 Call_1 RR73; Call_2 <MyCall> rpt_2
! 3 Call_1 MyCall rpt1
! 4 Call_1 RR73; Call_2 <MyCall> rpt2
if(nslots.lt.1 .or. nslots.gt.5) return
k=0
@ -27,8 +28,8 @@ subroutine foxgen2(nslots,cmsg)
hiscall_2=''
mycall=''
mygrid=''
rpt_1=''
rpt_2=''
rpt1=''
rpt2=''
msg=cmsg(i)(1:37)
call split77(msg,nwords,nw,w)
ntype=0
@ -40,37 +41,38 @@ subroutine foxgen2(nslots,cmsg)
ntype=4
hiscall_1=w(1)(1:6)
hiscall_2=w(3)(1:6)
rpt_1='RR73'
rpt_2=w(5)(1:4)
rpt1='RR73'
rpt2=w(5)(1:4)
mycall=w(4)(2:nw(4)-1)
else if(index(msg,' RR73').gt.0) then
ntype=2
hiscall_1=w(1)(1:6)
mycall=w(2)(1:12)
rpt_1='RR73'
rpt1='RR73'
else if(nwords.eq.3 .and. nw(3).eq.3 .and. &
(w(3)(1:1).eq.'-' .or. w(3)(1:1).eq.'+')) then
ntype=3
hiscall_1=w(1)(1:6)
mycall=w(2)(1:12)
rpt_1=w(3)(1:4)
rpt1=w(3)(1:4)
endif
! write(*,3001) ntype,cmsg(i),hiscall_1,rpt_1,hiscall_2,rpt_2, &
! write(*,3001) ntype,cmsg(i),hiscall_1,rpt1,hiscall_2,rpt2, &
! mycall(1:6),mygrid
!3001 format(i1,2x,a37,1x,a6,1x,a4,1x,a6,1x,a4,1x,a6,1x,a4)
k=k+1
if(ntype.le.3) call sfox_assemble(ntype,k,msg(1:22),mycall,mygrid)
if(ntype.le.3) call sfox_assemble(ntype,k,msg(1:26),mycall,mygrid,line)
if(ntype.eq.4) then
sfmsg=w(1)(1:nw(1))//' '//mycall(1:len(trim(mycall))+1)//'RR73'
call sfox_assemble(2,k,sfmsg,mycall,mygrid)
call sfox_assemble(2,k,sfmsg,mycall,mygrid,line)
sfmsg=w(3)(1:nw(3))//' '//mycall(1:len(trim(mycall))+1)//w(5)(1:3)
k=k+1
call sfox_assemble(3,k,sfmsg,mycall,mygrid)
call sfox_assemble(3,k,sfmsg,mycall,mygrid,line)
endif
enddo
call sfox_assemble(ntype,11,msg(1:22),mycall,mygrid) !k=11 to finish up
call sfox_assemble(ntype,11,msg(1:26),mycall,mygrid,line) !k=11 to finish up
return
end subroutine foxgen2

View File

@ -1,70 +1,91 @@
subroutine sfox_assemble(ntype,k,msg,mycall0,mygrid0)
subroutine sfox_assemble(ntype,k,msg,mycall0,mygrid0,line)
! In subsequent calls, assemble all necessary information for a SuperFox
! transmission.
character*22 msg
character*22 msg0,msg1,msg2(10),msg3(5)
character*12 mycall0,mycall
character*120 line
character*26 msg
character*26 msg0,msg1,msg2(5),msg3(5)
character*4 rpt2(5)
character*6 hiscall(10)
character*13 mycall0,mycall
character*4 mygrid0,mygrid
integer ntype !Message type: 0 Free Text
! 1 CQ MyCall MyGrid
! 2 Call_1 MyCall RR73
! 3 Call_1 MyCall rpt
integer nmsg(0:3) !Number of messages of type ntype
data nmsg/0,0,0,0/,nbits/0/,ntx/0/
data nmsg/0,0,0,0/,nbits/0/,ntx/0/,nb_mycall/0/
save
if(mycall0(1:1).ne.' ') mycall=mycall0
if(mygrid0(1:1).ne.' ') mygrid=mygrid0
if(ntype.ge.1) nb_mycall=28 !### Allow for nonstandard MyCall ###
if(sum(nmsg).eq.0) then
hiscall=' '
rpt2=' '
endif
if(k.le.10) then
if(ntype.eq.0) then
if(nbits.le.191) then !Enough room for a free text message?
if(nbits+nb_mycall.le.191) then !Enough room for a free text message?
nmsg(ntype)=nmsg(ntype)+1
nbits=nbits+142
msg0=msg
endif
else if(ntype.eq.1) then
if(nbits.le.290) then
if(nbits+nb_mycall.le.318) then !Enough room for a CQ ?
nmsg(ntype)=nmsg(ntype)+1
nbits=nbits+43
nbits=nbits+15
msg1=msg
endif
else if(ntype.eq.2) then
if(nbits.le.305) then
if(nbits+nb_mycall.le.305) then !Enough room for a RR73 message?
nmsg(ntype)=nmsg(ntype)+1
nbits=nbits+28
j=nmsg(ntype)
msg2(j)=msg
i1=index(msg,' ')
hiscall(j+5)=msg(1:i1-1)
endif
else
if(nbits.le.300) then
else if(ntype.eq.3) then
if(nbits+nb_mycall.le.300) then !Enough room for a message with report?
nmsg(ntype)=nmsg(ntype)+1
nbits=nbits+33
j=nmsg(ntype)
msg3(j)=msg
i1=index(msg,' ')
hiscall(j)=msg(1:i1-1)
i1=max(index(msg,'-'),index(msg,'+'))
rpt2(j)=msg(i1:i1+3)
endif
endif
return
endif
if(k.ge.11) then
! All necessary pieces are in place. Now encode the SuperFox message and
! generate the waveform to be transmitted.
ntx=ntx+1 !Transmission number
write(*,3002) ntx,ntype,nmsg(0:3),nbits
3002 format(i3,i5,2x,4i3,i6)
if(nmsg(0).ge.1) write(*,3010) ntx,msg0
3010 format(i3,2x,a22)
if(nmsg(1).ge.1) write(*,3010) ntx,msg1
do i=1,nmsg(2)
write(*,3010) ntx,msg2(i)
enddo
do i=1,nmsg(3)
write(*,3010) ntx,msg3(i)
enddo
! All pieces are now available. Put them into a command line for external
! program sfox_tx.
ntx=ntx+1 !Transmission number
nbits=nbits+nb_mycall !Add bits for MyCall
if(nmsg(1).ge.1) then
line=msg1
else
line=trim(mycall)
do i=1,nmsg(3)
line=trim(line)//' '//trim(hiscall(i))//' '//rpt2(i)
enddo
do i=1,nmsg(2)
line=trim(line)//' '//trim(hiscall(i))
enddo
endif
nmsg=0
nbits=0
nb_mycall=0
hiscall=' '
rpt2=' '
endif
return

View File

@ -176,7 +176,7 @@ 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);
void foxgen_(bool* bSuperFox, char* cmnd, fortran_charlen_t);
void plotsave_(float swide[], int* m_w , int* m_h1, int* irow);
@ -4824,7 +4824,12 @@ 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();
foxgen_(&bSuperFox);
char cmnd[120];
foxgen_(&bSuperFox, cmnd, 120);
if(bSuperFox) {
QString t=QString::fromLatin1(cmnd).trimmed();
sfox_tx(t);
}
}
}
}
@ -10299,7 +10304,13 @@ 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();
foxgen_(&bSuperFox);
qDebug() << "bb" << foxcom_.nslots << foxcom_.mycall << foxcom_.cmsg;
char cmnd[120];
foxgen_(&bSuperFox, cmnd, 120);
if(bSuperFox) {
QString t=QString::fromLatin1(cmnd).trimmed();
sfox_tx(t);
}
m_tFoxTxSinceCQ++;
for(QString hc: m_foxQSO.keys()) { //Check for strikeout or timeout
@ -10874,3 +10885,12 @@ void MainWindow::on_jt65Button_clicked()
{
on_actionJT65_triggered();
}
void MainWindow::sfox_tx(QString t)
{
qint64 ms0 = QDateTime::currentMSecsSinceEpoch();
p2.start("sfox_tx", QStringList {t});
p2.waitForFinished();
QString t2=p2.readAllStandardOutput();
qDebug() << "aa" << QDateTime::currentMSecsSinceEpoch() - ms0 << t2;
}

View File

@ -379,6 +379,7 @@ private:
bool elide_tx1_not_allowed () const;
void readWidebandDecodes();
void configActiveStations();
void sfox_tx(QString t);
QProcessEnvironment const& m_env;
NetworkAccessManager m_network_manager;
@ -622,6 +623,8 @@ private:
NonInheritingProcess p1;
NonInheritingProcess p3;
QProcess p2;
WSPRNet *wsprNet;
QTimer m_guiTimer;