Try APtype 4, 3, 2, 1, 0.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6929 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2016-07-19 15:24:15 +00:00
parent 920fd25537
commit f92afadc6c
3 changed files with 119 additions and 107 deletions

View File

@ -35,33 +35,35 @@
#define QRA64_m 6 // bits per symbol #define QRA64_m 6 // bits per symbol
// packed predefined callsigns and fields as defined in JT65 // packed predefined callsigns and fields as defined in JT65
#define CALL_CQ 0xFA08319 #define CALL_CQ 0xFA08319
#define CALL_QRZ 0xFA0831A #define CALL_QRZ 0xFA0831A
#define CALL_CQ000 0xFA0831B #define CALL_CQ000 0xFA0831B
#define CALL_CQ999 0xFA08702 #define CALL_CQ999 0xFA08702
#define CALL_CQDX 0x5624C39 #define CALL_CQDX 0x5624C39
#define CALL_DE 0xFF641D1 #define CALL_DE 0xFF641D1
#define GRID_BLANK 0x7E91 #define GRID_BLANK 0x7E91
// Types of a-priori knowledge messages // Types of a-priori knowledge messages
#define APTYPE_CQQRZ 0 // [cq/qrz ? ?/blank] #define APTYPE_CQQRZ 0 // [cq/qrz ? ?/blank]
#define APTYPE_MYCALL 1 // [mycall ? ?/blank] #define APTYPE_MYCALL 1 // [mycall ? ?/blank]
#define APTYPE_HISCALL 2 // [? hiscall ?/blank] #define APTYPE_HISCALL 2 // [? hiscall ?/blank]
#define APTYPE_BOTHCALLS 3 // [mycall hiscall ?] #define APTYPE_BOTHCALLS 3 // [mycall hiscall ?]
#define APTYPE_FULL 4 // [mycall hiscall grid] #define APTYPE_FULL 4 // [mycall hiscall grid]
#define APTYPE_SIZE (APTYPE_FULL+1) #define APTYPE_SIZE (APTYPE_FULL+1)
typedef struct { typedef struct {
float decEsNoMetric; float decEsNoMetric;
int apflags; int apflags;
int apmsg_set[APTYPE_SIZE]; // indicate which ap type knowledge has been set by the user int apmsg_set[APTYPE_SIZE]; // indicate which ap type knowledge has
// ap messages buffers // been set by the user
// ap messages buffers
int apmsg_cqqrz[12]; // [cq/qrz ? ?/blank] int apmsg_cqqrz[12]; // [cq/qrz ? ?/blank]
int apmsg_call1[12]; // [mycall ? ?/blank] int apmsg_call1[12]; // [mycall ? ?/blank]
int apmsg_call2[12]; // [? hiscall ?/blank] int apmsg_call2[12]; // [? hiscall ?/blank]
int apmsg_call1_call2[12]; // [mycall hiscall ?] int apmsg_call1_call2[12]; // [mycall hiscall ?]
int apmsg_call1_call2_grid[12]; // [mycall hiscall grid] int apmsg_call1_call2_grid[12]; // [mycall hiscall grid]
// ap messages masks
// ap messages masks
int apmask_cqqrz[12]; int apmask_cqqrz[12];
int apmask_cqqrz_ooo[12]; int apmask_cqqrz_ooo[12];
int apmask_call1[12]; int apmask_call1[12];
@ -79,41 +81,39 @@ extern "C" {
qra64codec *qra64_init(int flags); qra64codec *qra64_init(int flags);
// QRA64 mode initialization function // QRA64 mode initialization function
// arguments: // arguments:
// flags: set the decoder mode // flags: set the decoder mode
// When flags = QRA_NOAP no a-priori information will be used by the decoder // QRA_NOAP use no a-priori information
// When flags = QRA_AUTOAP the decoder will attempt to decode with the amount // QRA_AUTOAP use any relevant previous decodes
// of available a-priori information // QRA_USERAP use a-priori information provided via qra64_apset(...)
// When flags = QRA_USERAP the decoder will attempt to decode with the amount
// of a-priori information as provided by the caller with the function qra64_apset(...)
// returns: // returns:
// Pointer to the qra64codec data structure allocated and inizialized by the function // Pointer to initialized qra64codec data structure
// this handle should be passed to the encoding/decoding functions // this pointer should be passed to the encoding/decoding functions
// //
// 0 if unsuccessful (can't allocate memory) // 0 if unsuccessful (can't allocate memory)
// ------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void qra64_encode(qra64codec *pcodec, int *y, const int *x); void qra64_encode(qra64codec *pcodec, int *y, const int *x);
// QRA64 mode encoder // QRA64 encoder
// arguments: // arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init // pcodec = pointer to a qra64codec data structure as returned by qra64_init
// x = pointer to the message to encode // x = pointer to the message to be encoded, int x[12]
// x must point to an array of integers (i.e. defined as int x[12]) // x must point to an array of integers (i.e. defined as int x[12])
// y = pointer to the encoded message // y = pointer to encoded message, int y[63]=
// y must point to an array of integers of lenght 63 (i.e. defined as int y[63]) // ----------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
int qra64_decode(qra64codec *pcodec, float *ebno, int *x, const float *r); int qra64_decode(qra64codec *pcodec, float *ebno, int *x, const float *r);
// QRA64 mode decoder // QRA64 mode decoder
// arguments: // arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init // pcodec = pointer to a qra64codec data structure as returned by qra64_init
// ebno = pointer to a float number where the avg Eb/No (in dB) will be stored // ebno = pointer to a float where the avg Eb/No (in dB) will be stored
// in case of successfull decoding (pass a null pointer if not interested) // in case of successfull decoding
// x = pointer to the array of integers where the decoded message will be stored // (pass a null pointer if not interested)
// x must point to an array of integers (i.e. defined as int x[12]) // x = pointer to decoded message, int x[12]
// r = pointer to the received symbols energies (squared amplitudes) // r = pointer to received symbol energies (squared amplitudes)
// r must point to an array of QRA64_M*QRA64_N (=64*63=4032) float numbers. // r must point to an array of length QRA64_M*QRA64_N (=64*63=4032)
// The first QRA_M entries should be the energies of the first symbol in the codeword // The first QRA_M entries should be the energies of the first
// The last QRA_M entries should be the energies of the last symbol in the codeword // symbol in the codeword; the last QRA_M entries should be the
// energies of the last symbol in the codeword
// //
// return code: // return code:
// //
@ -129,46 +129,46 @@ int qra64_decode(qra64codec *pcodec, float *ebno, int *x, const float *r);
// rc=6 [? CALL ?] AP29 // rc=6 [? CALL ?] AP29
// rc=7 [? CALL ] AP45 // rc=7 [? CALL ] AP45
// rc=8 [CALL CALL GRID] AP72 // rc=8 [CALL CALL GRID] AP72
// return codes in the range 1-8 indicate the amount and the type of a-priori information // return codes in the range 1-8 indicate the amount and the type of a-priori
// which was required to decode the received message // information was required to decode the received message.
int qra64_apset(qra64codec *pcodec, const int mycall, const int hiscall, const int grid, const int aptype); int qra64_apset(qra64codec *pcodec, const int mycall, const int hiscall, const int grid, const int aptype);
// Set decoder a-priori knowledge accordingly to the type of the message to look up for // Set decoder a-priori knowledge accordingly to the type of the message to
// look up for
// arguments: // arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init // pcodec = pointer to a qra64codec data structure as returned by qra64_init
// mycall = mycall to look for // mycall = mycall to look for
// hiscall = hiscall to look for // hiscall = hiscall to look for
// grid = grid to look for // grid = grid to look for
// aptype = define the type of AP to be set accordingly to the following table: // aptype = define the type of AP to be set:
// APTYPE_CQQRZ set [cq/qrz ? ?/blank] // APTYPE_CQQRZ set [cq/qrz ? ?/blank]
// APTYPE_MYCALL set [mycall ? ?/blank] // APTYPE_MYCALL set [mycall ? ?/blank]
// APTYPE_HISCALL set [? hiscall ?/blank] // APTYPE_HISCALL set [? hiscall ?/blank]
// APTYPE_BOTHCALLS set [mycall hiscall ?] // APTYPE_BOTHCALLS set [mycall hiscall ?]
// APTYPE_FULL set [mycall hiscall grid] // APTYPE_FULL set [mycall hiscall grid]
// returns: // returns:
// 0 on success // 0 on success
// -1 when qra64_init was called with the QRA_NOAP flag // -1 when qra64_init was called with the QRA_NOAP flag
// -2 invalid apytpe (aptype must be in the range [APTYPE_MYCALL..APTYPE_FULL] // -2 invalid apytpe (valid range [APTYPE_MYCALL..APTYPE_FULL]
// (APTYPE_CQQRZ [cq/qrz ? ?] is set during the initialization function and // (APTYPE_CQQRZ [cq/qrz ? ?] is set by default )
// doesn't need to be set by the user
void qra64_apdisable(qra64codec *pcodec, const int aptype); void qra64_apdisable(qra64codec *pcodec, const int aptype);
// disable specific AP type // disable specific AP type
// arguments: // arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init // pcodec = pointer to a qra64codec data structure as returned by qra64_init
// aptype = define the type of AP to be disabled // aptype = define the type of AP to be disabled
// APTYPE_CQQRZ disable [cq/qrz ? ?/blank] // APTYPE_CQQRZ disable [cq/qrz ? ?/blank]
// APTYPE_MYCALL disable [mycall ? ?/blank] // APTYPE_MYCALL disable [mycall ? ?/blank]
// APTYPE_HISCALL disable [? hiscall ?/blank] // APTYPE_HISCALL disable [ ? hiscall ?/blank]
// APTYPE_BOTHCALLS disable [mycall hiscall ?] // APTYPE_BOTHCALLS disable [mycall hiscall ? ]
// APTYPE_FULL disable [mycall hiscall grid] // APTYPE_FULL disable [mycall hiscall grid]
void qra64_close(qra64codec *pcodec); void qra64_close(qra64codec *pcodec);
// Free memory allocated by qra64_init // Free memory allocated by qra64_init
// arguments: // arguments:
// pcodec = pointer to a qra64codec data structure as returned by qra64_init // pcodec = pointer to a qra64codec data structure as returned by qra64_init
// ------------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// encode/decode std msgs in 12 symbols as done in jt65 // encode/decode std msgs in 12 symbols as done in jt65
void encodemsg_jt65(int *y, const int call1, const int call2, const int grid); void encodemsg_jt65(int *y, const int call1, const int call2, const int grid);

View File

@ -10,44 +10,48 @@ static qra64codec *pqra64codec = NULL;
void qra64_enc_(int x[], int y[]) void qra64_enc_(int x[], int y[])
{ {
if (pqra64codec==NULL) pqra64codec = qra64_init(QRA_AUTOAP); if (pqra64codec==NULL) pqra64codec = qra64_init(QRA_USERAP);
qra64_encode(pqra64codec, y, x); qra64_encode(pqra64codec, y, x);
} }
void qra64_dec_(float r[], int* nmycall, int* nhiscall, int* nhisgrid, void qra64_dec_(float r[], int* nc1, int* nc2, int* ng2, int* APtype,
int xdec[], float* snr, int* rc) int xdec[], float* snr, int* rc)
{ {
// Return codes: /*
// rc=-16 failed sanity check APtype:
// rc=-2 decoded, but crc check failed -1 (no AP information)
// rc=-1 no decode 0 [CQ/QRZ * ?_] (* means 26 or 28 bit info)
// rc=0 [? ? ?] AP0 (decoding with no a-priori information) 1 [call1 * ?_] (?_ means 16-bit info or "blank")
// rc=1 [CQ ? ?] AP27 2 [* call2 ?_]
// rc=2 [CQ ? ] AP42 3 [call1 call2 ?_]
// rc=3 [CALL ? ?] AP29 4 [call1 call2 grid]
// rc=4 [CALL ? ] AP44
// rc=5 [CALL CALL ?] AP57
// rc=6 [? CALL ?] AP29
// rc=7 [? CALL ] AP44
// rc=8 [CALL CALL G] AP72
static ncall0=-1; Return codes:
int ncall=*nmycall; -16 Failed sanity check
-2 Decoded, but crc check failed
-1 No decode
0 [? ? ?] AP0 (decoding with no a-priori information)
1 [CQ ? ?] AP27
2 [CQ ? ] AP42
3 [CALL ? ?] AP29
4 [CALL ? ] AP44
5 [CALL CALL ?] AP57
6 [? CALL ?] AP29
7 [? CALL ] AP44
8 [CALL CALL G] AP72
*/
static int nc1z=-1;
float EbNodBEstimated; float EbNodBEstimated;
int err=0;
#ifdef NICO_WANTS_SNR_DUMP #ifdef NICO_WANTS_SNR_DUMP
FILE *fout; FILE *fout;
#endif #endif
if(ncall!=ncall0) { if(pqra64codec==NULL) pqra64codec = qra64_init(QRA_USERAP);
if (pqra64codec!=NULL) qra64_close(pqra64codec); err=qra64_apset(pqra64codec,*nc1,*nc2,*ng2,*APtype);
pqra64codec = qra64_init(QRA_AUTOAP); if(err<0) printf("ERROR: qra64_apset returned %d\n",err);
// the following apset call is not strictly necessary
// It enables AP decoding of messages directed to our call
// also in the case we have never made a CQ
qra64_apset(pqra64codec,ncall,0,0,APTYPE_MYCALL);
ncall0=ncall;
}
*rc = qra64_decode(pqra64codec,&EbNodBEstimated,xdec,r); *rc = qra64_decode(pqra64codec,&EbNodBEstimated,xdec,r);
*snr = EbNodBEstimated - 31.0; *snr = EbNodBEstimated - 31.0;

View File

@ -8,6 +8,7 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,hiscall_12,hisgrid_6, &
character*6 mycall,hiscall,hisgrid_6 character*6 mycall,hiscall,hisgrid_6
character*4 hisgrid character*4 hisgrid
logical ltext logical ltext
integer*8 count0,count1,clkfreq
integer icos7(0:6) integer icos7(0:6)
integer ipk(1) integer ipk(1)
integer jpk(1) integer jpk(1)
@ -126,19 +127,26 @@ subroutine qra64a(dd,nf1,nf2,nfqso,ntol,mycall_12,hiscall_12,hisgrid_6, &
call packcall(hiscall,nhiscall,ltext) call packcall(hiscall,nhiscall,ltext)
call packgrid(hisgrid,nhisgrid,ltext) call packgrid(hisgrid,nhisgrid,ltext)
snr2=-99. snr2=-99.
call qra64_dec(s3,nmycall,nhiscall,nhisgrid,dat4,snr2,irc) !Attempt decoding ttot=0.
if(irc.ge.0) then do naptype=4,0,-1
call unpackmsg(dat4,decoded) !Unpack the user message call system_clock(count0,clkfreq)
call fmtmsg(decoded,iz) call qra64_dec(s3,nmycall,nhiscall,nhisgrid,naptype,dat4,snr2,irc)
nft=100 + irc if(irc.ge.0) then
nsnr=nint(snr2) call unpackmsg(dat4,decoded) !Unpack the user message
else call fmtmsg(decoded,iz)
snr2=0. nft=100 + irc
endif nsnr=nint(snr2)
else
snr2=0.
endif
call system_clock(count1,clkfreq)
tsec=float(count1-count0)/float(clkfreq)
ttot=ttot+tsec
write(78,3900) sync,snr1,snr2,snr2-snr1,dtx,nfreq,nhard,naptype,irc, &
tsec,ttot,decoded
3900 format(4f6.1,f6.2,i5,i3,i2,i3,2f6.3,1x,a22)
if(irc.ge.0) exit
enddo
900 continue 900 return
write(78,3900) sync,snr1,snr2,snr2-snr1,dtx,nfreq,nhard,irc,decoded
3900 format(4f7.1,f7.2,i6,2i4,2x,a22)
return
end subroutine qra64a end subroutine qra64a