minimodem: rx rate measurement
This commit is contained in:
parent
9002cf2694
commit
1ab9d2783c
@ -88,7 +88,6 @@ static void fsk_transmit_stdin(
|
|||||||
while ( (c = getchar()) != EOF )
|
while ( (c = getchar()) != EOF )
|
||||||
{
|
{
|
||||||
|
|
||||||
// HACK - baudot
|
|
||||||
unsigned int nwords;
|
unsigned int nwords;
|
||||||
unsigned int bits[2];
|
unsigned int bits[2];
|
||||||
nwords = framebits_encoder(bits, c);
|
nwords = framebits_encoder(bits, c);
|
||||||
@ -112,6 +111,29 @@ static void fsk_transmit_stdin(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
report_no_carrier( fsk_plan *fskp,
|
||||||
|
unsigned int sample_rate,
|
||||||
|
float bfsk_data_rate,
|
||||||
|
unsigned int nframes_decoded,
|
||||||
|
size_t carrier_nsamples,
|
||||||
|
float confidence_total )
|
||||||
|
{
|
||||||
|
unsigned long long nbits_total = nframes_decoded * (fskp->n_data_bits+2);
|
||||||
|
float throughput_rate = nbits_total * sample_rate / (float)carrier_nsamples;
|
||||||
|
float throughput_skew = (throughput_rate - bfsk_data_rate)
|
||||||
|
/ bfsk_data_rate;
|
||||||
|
fprintf(stderr, "### NOCARRIER ndata=%u confidence=%.2f throughput=%.2f (%.1f%% %s) ###\n",
|
||||||
|
nframes_decoded,
|
||||||
|
confidence_total / nframes_decoded,
|
||||||
|
throughput_rate,
|
||||||
|
fabs(throughput_skew) * 100.0,
|
||||||
|
signbit(throughput_skew) ? "slow" : "fast"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
@ -397,14 +419,19 @@ main( int argc, char*argv[] )
|
|||||||
int carrier = 0;
|
int carrier = 0;
|
||||||
float confidence_total = 0;
|
float confidence_total = 0;
|
||||||
unsigned int nframes_decoded = 0;
|
unsigned int nframes_decoded = 0;
|
||||||
|
size_t carrier_nsamples = 0;
|
||||||
|
|
||||||
unsigned int noconfidence = 0;
|
unsigned int noconfidence = 0;
|
||||||
|
size_t noconfidence_nsamples = 0;
|
||||||
unsigned int advance = 0;
|
unsigned int advance = 0;
|
||||||
|
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
|
|
||||||
debug_log("advance=%u\n", advance);
|
debug_log("advance=%u\n", advance);
|
||||||
|
|
||||||
|
if ( carrier && nframes_decoded > 0 )
|
||||||
|
carrier_nsamples += advance;
|
||||||
|
|
||||||
/* Shift the samples in samplebuf by 'advance' samples */
|
/* Shift the samples in samplebuf by 'advance' samples */
|
||||||
assert( advance <= samplebuf_size );
|
assert( advance <= samplebuf_size );
|
||||||
if ( advance == samplebuf_size ) {
|
if ( advance == samplebuf_size ) {
|
||||||
@ -526,9 +553,11 @@ main( int argc, char*argv[] )
|
|||||||
carrier_band = -1;
|
carrier_band = -1;
|
||||||
#endif
|
#endif
|
||||||
if ( carrier ) {
|
if ( carrier ) {
|
||||||
fprintf(stderr, "### NOCARRIER ndata=%u confidence=%.2f ###\n",
|
carrier_nsamples -= noconfidence_nsamples;
|
||||||
nframes_decoded, confidence_total / nframes_decoded );
|
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
||||||
|
nframes_decoded, carrier_nsamples, confidence_total);
|
||||||
carrier = 0;
|
carrier = 0;
|
||||||
|
carrier_nsamples = 0;
|
||||||
confidence_total = 0;
|
confidence_total = 0;
|
||||||
nframes_decoded = 0;
|
nframes_decoded = 0;
|
||||||
}
|
}
|
||||||
@ -538,10 +567,10 @@ main( int argc, char*argv[] )
|
|||||||
* next time around the loop we continue searching from where
|
* next time around the loop we continue searching from where
|
||||||
* we left off this time. */
|
* we left off this time. */
|
||||||
advance = try_max_nsamples;
|
advance = try_max_nsamples;
|
||||||
|
noconfidence_nsamples += advance;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( !carrier ) {
|
if ( !carrier ) {
|
||||||
if ( bfsk_data_rate >= 100 )
|
if ( bfsk_data_rate >= 100 )
|
||||||
fprintf(stderr, "### CARRIER %u @ %u Hz ###\n",
|
fprintf(stderr, "### CARRIER %u @ %u Hz ###\n",
|
||||||
@ -555,9 +584,11 @@ main( int argc, char*argv[] )
|
|||||||
bfsk_framebits_decode(0, 0, 0); /* reset the frame processor */
|
bfsk_framebits_decode(0, 0, 0); /* reset the frame processor */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
confidence_total += confidence;
|
confidence_total += confidence;
|
||||||
nframes_decoded++;
|
nframes_decoded++;
|
||||||
noconfidence = 0;
|
noconfidence = 0;
|
||||||
|
noconfidence_nsamples = 0;
|
||||||
|
|
||||||
/* Advance the sample stream forward past the decoded frame
|
/* Advance the sample stream forward past the decoded frame
|
||||||
* but not past the stop bit, since we want it to appear as
|
* but not past the stop bit, since we want it to appear as
|
||||||
@ -606,8 +637,9 @@ main( int argc, char*argv[] )
|
|||||||
} /* end of the main loop */
|
} /* end of the main loop */
|
||||||
|
|
||||||
if ( carrier ) {
|
if ( carrier ) {
|
||||||
fprintf(stderr, "### NOCARRIER ndata=%u confidence=%.2f ###\n",
|
carrier_nsamples -= noconfidence_nsamples;
|
||||||
nframes_decoded, confidence_total / nframes_decoded );
|
report_no_carrier(fskp, sample_rate, bfsk_data_rate,
|
||||||
|
nframes_decoded, carrier_nsamples, confidence_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleaudio_close(sa);
|
simpleaudio_close(sa);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user