Skip to content

Commit

Permalink
Stats rearrangement, based on experimental branch changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
mutability committed Jan 20, 2015
1 parent e02a2cd commit b9b76da
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 191 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ all: dump1090 view1090
%.o: %.c dump1090.h
$(CC) $(CPPFLAGS) $(CFLAGS) $(EXTRACFLAGS) -c $<

dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o demod_2000.o demod_2400.o
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o demod_2000.o demod_2400.o stats.o
$(CC) -g -o dump1090 $^ $(LIBS) $(LIBS_RTL) $(LDFLAGS)

view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o net_io.o crc.o stats.o
$(CC) -g -o view1090 $^ $(LIBS) $(LDFLAGS)

clean:
Expand Down
12 changes: 6 additions & 6 deletions demod_2000.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
useModesMessage(&mm);

j += MODEAC_MSG_SAMPLES;
Modes.stat_ModeAC++;
Modes.stats_current.ModeAC++;
continue;
}
}
Expand Down Expand Up @@ -399,7 +399,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
dumpRawMessage("Too high level in samples between 10 and 15", msg, m, j);
continue;
}
Modes.stat_valid_preamble++;
Modes.stats_current.valid_preamble++;
}

else {
Expand All @@ -408,7 +408,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
// Make a copy of the Payload, and phase correct the copy
memcpy(aux, &pPreamble[-1], sizeof(aux));
applyPhaseCorrection(&aux[1]);
Modes.stat_out_of_phase++;
Modes.stats_current.out_of_phase++;
pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES];
// TODO ... apply other kind of corrections
}
Expand Down Expand Up @@ -476,7 +476,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
msglen = MODES_SHORT_MSG_BITS;
msg[0] ^= theErrs; errorsTy = 0;
errors = errors56; // revert to the number of errors prior to bit 56
Modes.stat_DF_Len_Corrected++;
Modes.stats_current.DF_Len_Corrected++;

} else if (i < MODES_LONG_MSG_BITS) {
msglen = MODES_SHORT_MSG_BITS;
Expand Down Expand Up @@ -518,7 +518,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
if (validDFbits & thisDFbit) {
// Yep, more likely, so update the main message
msg[0] = theByte;
Modes.stat_DF_Type_Corrected++;
Modes.stats_current.DF_Type_Corrected++;
errors--; // decrease the error count so we attempt to use the modified DF.
}
}
Expand Down Expand Up @@ -549,7 +549,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {

// Update statistics
if (Modes.stats) {
struct demod_stats *dstats = (use_correction ? &Modes.stat_demod_phasecorrected : &Modes.stat_demod);
struct demod_stats *dstats = (use_correction ? &Modes.stats_current.demod_phasecorrected : &Modes.stats_current.demod);

switch (errors) {
case 0: dstats->demodulated0++; break;
Expand Down
16 changes: 8 additions & 8 deletions demod_2400.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,19 @@ void demodulate2400(uint16_t *m, uint32_t mlen)
preamble[16] >= high ||
preamble[17] >= high ||
preamble[18] >= high) {
++Modes.stat_preamble_not_quiet;
++Modes.stats_current.preamble_not_quiet;
continue;
}

// Crosscorrelate against the first few bits to find a likely phase offset
initial_phase = best_phase(&preamble[19]);
if (initial_phase < 0) {
++Modes.stat_preamble_no_correlation;
++Modes.stats_current.preamble_no_correlation;
continue; // nothing satisfactory
}

Modes.stat_valid_preamble++;
Modes.stat_preamble_phase[initial_phase%MODES_MAX_PHASE_STATS]++;
Modes.stats_current.valid_preamble++;
Modes.stats_current.preamble_phase[initial_phase%MODES_MAX_PHASE_STATS]++;

try_phase = initial_phase;

Expand Down Expand Up @@ -395,7 +395,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen)
msglen = MODES_SHORT_MSG_BITS;
msg[0] ^= theErrs; errorsTy = 0;
errors = errors56; // revert to the number of errors prior to bit 56
Modes.stat_DF_Len_Corrected++;
Modes.stats_current.DF_Len_Corrected++;
} else if (i < MODES_LONG_MSG_BITS) {
msglen = MODES_SHORT_MSG_BITS;
errors = errors56;
Expand Down Expand Up @@ -435,7 +435,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen)
if (validDFbits & thisDFbit) {
// Yep, more likely, so update the main message
msg[0] = theByte;
Modes.stat_DF_Type_Corrected++;
Modes.stats_current.DF_Type_Corrected++;
errors--; // decrease the error count so we attempt to use the modified DF.
}
}
Expand Down Expand Up @@ -466,7 +466,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen)

// Update statistics
if (Modes.stats) {
struct demod_stats *dstats = (mm.phase_corrected ? &Modes.stat_demod_phasecorrected : &Modes.stat_demod);
struct demod_stats *dstats = (mm.phase_corrected ? &Modes.stats_current.demod_phasecorrected : &Modes.stats_current.demod);

switch (errors) {
case 0: dstats->demodulated0++; break;
Expand Down Expand Up @@ -508,7 +508,7 @@ void demodulate2400(uint16_t *m, uint32_t mlen)
// peak detection
if (Modes.phase_enhance && !mm.crcok && !mm.correctedbits) {
if (try_phase == initial_phase)
++Modes.stat_out_of_phase;
++Modes.stats_current.out_of_phase;
try_phase++;
if (try_phase == 9)
try_phase = 4;
Expand Down
Loading

0 comments on commit b9b76da

Please sign in to comment.