From 78047169910f14208d8247e340fc2a9b0c28bf8f Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Fri, 2 Feb 2024 15:44:03 -0500 Subject: [PATCH] Build sfoxtext from CMakefiles.txt, with RS(125,49) encode and decode. --- CMakeLists.txt | 4 ++++ lib/superfox/hard_symbols.f90 | 3 ++- lib/superfox/rs_sf.c | 2 +- lib/superfox/sfoxtest.f90 | 34 ++++++++++++++++++++++++++-------- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 787880655..69e844245 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -630,6 +630,10 @@ set (wsjt_CSRCS lib/vit213.c lib/wisdom.c lib/wrapkarn.c + lib/superfox/init_rs.c + lib/superfox/encode_rs.c + lib/superfox/decode_rs.c + lib/superfox/rs_sf.c ${ldpc_CSRCS} ${qra_CSRCS} ) diff --git a/lib/superfox/hard_symbols.f90 b/lib/superfox/hard_symbols.f90 index 1bf88cb87..1ba7d7ca9 100644 --- a/lib/superfox/hard_symbols.f90 +++ b/lib/superfox/hard_symbols.f90 @@ -4,7 +4,7 @@ subroutine hard_symbols(crcvd,f,t,jdat) complex crcvd(NMAX) !Signal as received complex c(0:NSPS-1) !Work array, one symbol long real s(0:NSPS-1) !Power spectrum - integer jdat(ND) !Recovered hard-decision symbols + integer jdat(NN) !Recovered hard-decision symbols integer ipk(1) i0=nint(12000.0*t) @@ -28,6 +28,7 @@ subroutine hard_symbols(crcvd,f,t,jdat) jdat(n)=ipk(1)+256-64 endif enddo + jdat(NN-1:nn)=0 return end subroutine hard_symbols diff --git a/lib/superfox/rs_sf.c b/lib/superfox/rs_sf.c index 4bb9528a2..6b3154d11 100644 --- a/lib/superfox/rs_sf.c +++ b/lib/superfox/rs_sf.c @@ -1,7 +1,7 @@ #include #include "rs_sf.h" -void *rs_sf; +static void *rs_sf; static int first=1; static int nn,kk,nroots,npad; diff --git a/lib/superfox/sfoxtest.f90 b/lib/superfox/sfoxtest.f90 index 5ac3a6095..f092bd137 100644 --- a/lib/superfox/sfoxtest.f90 +++ b/lib/superfox/sfoxtest.f90 @@ -12,9 +12,13 @@ program sfoxtest complex clo(NMAX) !Complex Local Oscillator complex cnoise(NMAX) !Complex noise complex crcvd(NMAX) !Signal as received - integer idat(ND) !Encoded data, 7-bit integers - integer jdat(ND) !Recovered hard-decision symbols + integer imsg(KK) !Information symbols + integer jmsg(KK) !Decoded information + integer*1 imsg1(7*KK) !Copy of imsg in 1-bit i*1 format + integer idat(NN) !Encoded data, 7-bit integers + integer jdat(NN) !Recovered hard-decision symbols character fname*17,arg*12 + character c357*357,c14*14 !,chkmsg*15 nargs=iargc() if(nargs.ne.8) then @@ -46,12 +50,21 @@ program sfoxtest idummy=0 bandwidth_ratio=2500.0/6000.0 -! Generate random data symbols - do i=1,ND - call random_number(r) - if(nran.eq.1) r=ran1(idummy) - idat(i)=128*r +! Generate a message + do i=1,KK-2 + imsg(i)=i enddo + +! Append a 14-bit CRC + imsg(KK-1:KK)=0 + write(c357,'(51b7.7)') imsg(1:KK) + read(c357,'(357i1)') imsg1 + call get_crc14(imsg1,7*KK,ncrc0) + write(c14,'(b14.14)') ncrc0 + read(c14,'(2b7.7)') imsg(KK-1:KK) + + call rs_init_sf(MM,NQ,NN,KK,NFZ) !Initialize the Karn codec + call rs_encode_sf(imsg,idat) !Encode imsg into idat ! Generate cdat (SuperFox waveform) and clo (LO for sync detection) call gen_sfox(idat,f0,fsample,syncwidth,cdat,clo) @@ -101,6 +114,12 @@ program sfoxtest if(abs(ferr).lt.5.0 .and. abs(terr).lt.0.01) ngoodsync=ngoodsync+1 call hard_symbols(crcvd,f,t,jdat) !Get hard symbol values + nera=0 + call rs_decode_sf(idat,iera,nera,jmsg,nfixed) !Call the decoder + write(c357,'(51b7.7)') jmsg(1:KK) + read(c357,'(357i1)') imsg11 + call get_crc14(imsg1,7*KK,ncrc) + nharderr=count(jdat.ne.idat) !Count hard errors if(snrdb.ne.0) then @@ -131,7 +150,6 @@ program sfoxtest 1310 format(f7.2,i6,2f7.2) if(snrdb.ne.0.0) exit if(fgoodsync.lt.0.5) exit -! if(fgood.eq.0.0) exit enddo ! isnr 999 end program sfoxtest