Update to latest dft_detect, use no-C34/C50 option.

pull/123/head
Mark Jessop 2019-02-28 19:40:44 +10:30
rodzic 04c8e983e7
commit d364cc97f8
3 zmienionych plików z 38 dodań i 23 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
# Build rs_detect.
echo "Building rs_detect"
cd ../scan/
gcc dft_detect.c -lm -o dft_detect
gcc dft_detect.c -lm -o dft_detect -DNOC34C50
echo "Building RS92/RS41/DFM Demodulators"
cd ../demod/

Wyświetl plik

@ -10,6 +10,7 @@ import glob
import argparse
import os
import sys
import time
import subprocess
@ -97,7 +98,7 @@ processing_type = {
# Decimate to a 24 kHz bandwidth, demodulator, then interpolate back up to 48 kHz.
'demod' : "| csdr fir_decimate_cc 4 0.005 HAMMING 2>/dev/null | csdr fmdemod_quadri_cf | csdr limit_ff | csdr rational_resampler_ff 2 1 0.005 HAMMING | csdr convert_f_s16 | sox -t raw -r 48k -e signed-integer -b 16 -c 1 - -r 48000 -t wav - highpass 20 2>/dev/null| ",
# Decode using rs41ecc
'decode': "../dft_detect 2>/dev/null",
'decode': "../dft_detect3 2>/dev/null",
# Grep out the line containing the detected sonde type.
"post_process" : " | grep \:"
},
@ -134,7 +135,7 @@ processing_type = {
def run_analysis(mode, file_list, shift=0.0):
def run_analysis(mode, file_list, shift=0.0, verbose=False):
_mode = processing_type[mode]
@ -163,12 +164,18 @@ def run_analysis(mode, file_list, shift=0.0):
# Run the command.
try:
_start = time.time()
_output = subprocess.check_output(_cmd, shell=True, stderr=None)
except:
_output = "error"
_runtime = time.time() - _start
print("%s, %s" % (os.path.basename(_file), _output.strip()))
if verbose:
print("Runtime: %.1d" % _runtime)
@ -176,6 +183,7 @@ if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-m", "--mode", type=str, default="rs41_csdr_fm_decode", help="Operation mode.")
parser.add_argument("-f", "--files", type=str, default="./generated/*.bin", help="Glob-path to files to run over.")
parser.add_argument("-v", "--verbose", action='store_true', default=False, help="Show additional debug info.")
parser.add_argument("--shift", type=float, default=0.0, help="Shift the signal-under test by x Hz. Default is 0.")
args = parser.parse_args()
@ -195,4 +203,4 @@ if __name__ == "__main__":
# Sort the list of files.
_file_list.sort()
run_analysis(args.mode, _file_list, shift=args.shift)
run_analysis(args.mode, _file_list, shift=args.shift, verbose=args.verbose)

Wyświetl plik

@ -238,8 +238,12 @@ static int getCorrDFT(int abs, int K, unsigned int pos, float *maxv, unsigned in
dc = 0.0;
#ifdef ZEROPAD
if (rshd.N + K > N_DFT/2 - 2) return -1;
if (sample_in < delay+rshd.N+K) return -2;
#else
if (rshd.N + K > N_DFT) return -1;
#endif
// if (sample_in < delay+rshd.N+K) return -2;
if (pos == 0) pos = sample_out;
@ -379,7 +383,7 @@ static int f32read_sample(FILE *fp, float *s) {
}
static int f32buf_sample(FILE *fp, int inv, int cm) {
static int f32buf_sample(FILE *fp, int inv) {
float s = 0.0;
float xneu, xalt;
@ -398,11 +402,6 @@ static int f32buf_sample(FILE *fp, int inv, int cm) {
qs[sample_in % M] = qsum;
*/
if (0 && cm) {
// direct correlation
}
sample_out = sample_in - delay;
sample_in += 1;
@ -510,6 +509,7 @@ static int init_buffers() {
double b0, b1, b2, b;
float normMatch;
int p2 = 1;
int K, NN;
int n, k;
float *match = NULL;
@ -532,22 +532,26 @@ static int init_buffers() {
NN = hLen * sample_rate/2500.0 + 0.5; // max(hLen*spb)
M = 3*NN;
M = 2*NN;
//if (samples_per_bit < 6) M = 6*N;
delay = NN/16;
sample_in = 0;
p2 = 1;
while (p2 < M) p2 <<= 1;
while (p2 < 0x2000) p2 <<= 1; // or 0x4000, if sample not too short
M = p2;
N_DFT = p2;
#ifdef ZEROPAD
M -= 1;
N_DFT <<= 1;
#endif
LOG2N = log(N_DFT)/log(2);
//while ((1 << LOG2N) < N_DFT) LOGN++;
K = M-NN - delay; // N+K < M
LOG2N = 2 + (int)(log(NN+K)/log(2));
N_DFT = 1 << LOG2N;
while (NN + K > N_DFT/2 - 2) {
LOG2N += 1;
N_DFT <<= 1;
}
Nvar = NN; // wenn Nvar fuer xnorm, dann Nvar=rshd.N
rawbits = (char *)calloc( hLen+1, sizeof(char)); if (rawbits == NULL) return -100;
@ -736,7 +740,7 @@ int main(int argc, char **argv) {
k = 0;
while ( f32buf_sample(fp, option_inv, 1) != EOF ) {
while ( f32buf_sample(fp, option_inv) != EOF ) {
if (tl > 0 && sample_in > (tl+1)*sample_rate) break; // (int)sample_out < 0
@ -744,6 +748,9 @@ int main(int argc, char **argv) {
if (k >= K-4) {
for (j = 0; j < Nrs-2; j++) {
#ifdef NOC34C50
if ( strncmp(rs_hdr[j].type, "C34C50", 6) == 0 ) continue;
#endif
mv0_pos[j] = mv_pos[j];
mp[j] = getCorrDFT(-1, K, 0, mv+j, mv_pos+j, rs_hdr[j]);
}
@ -779,7 +786,7 @@ int main(int argc, char **argv) {
n = 0;
while (n < sample_rate) { // 1 sec
if (f32buf_sample(fp, option_inv, 1) == EOF) break;//goto ende;
if (f32buf_sample(fp, option_inv) == EOF) break;//goto ende;
xn[n % D] = bufs[sample_out % M];
n++;
@ -821,7 +828,7 @@ int main(int argc, char **argv) {
// detect header/polarity
k = 0;
while ( n < 4*sample_rate && f32buf_sample(fp, option_inv, 1) != EOF ) {
while ( n < 4*sample_rate && f32buf_sample(fp, option_inv) != EOF ) {
n += 1;
k += 1;