kopia lustrzana https://github.com/ha7ilm/csdr
adjust changes to match pre-existing white space convention
rodzic
44c539c1af
commit
bdf6c8263f
36
csdr.c
36
csdr.c
|
@ -2491,32 +2491,32 @@ int main(int argc, char *argv[])
|
|||
|
||||
if(!strcmp(argv[1],"binary_decoder_f_u8"))
|
||||
{
|
||||
int samples_per_symbol;
|
||||
int min_samples_per_symbol;
|
||||
int output_size;
|
||||
int samples_per_symbol;
|
||||
int min_samples_per_symbol;
|
||||
int output_size;
|
||||
|
||||
if(argc<=2) return badsyntax("need required parameter (samples_per_symbol)");
|
||||
if(argc<=2) return badsyntax("need required parameter (samples_per_symbol)");
|
||||
sscanf(argv[2],"%d",&samples_per_symbol);
|
||||
|
||||
if(argc>3)
|
||||
{
|
||||
sscanf(argv[3],"%d",&min_samples_per_symbol);
|
||||
}
|
||||
else
|
||||
{
|
||||
min_samples_per_symbol = (samples_per_symbol*3)/4;
|
||||
}
|
||||
if(argc>3)
|
||||
{
|
||||
sscanf(argv[3],"%d",&min_samples_per_symbol);
|
||||
}
|
||||
else
|
||||
{
|
||||
min_samples_per_symbol = (samples_per_symbol*3)/4;
|
||||
}
|
||||
|
||||
if(!sendbufsize(initialize_buffers())) return -2;
|
||||
if(!sendbufsize(initialize_buffers())) return -2;
|
||||
for(;;)
|
||||
{
|
||||
FEOF_CHECK;
|
||||
FEOF_CHECK;
|
||||
if(!FREAD_R) break;
|
||||
output_size = binary_decoder_f_u8( input_buffer,
|
||||
(unsigned char*)output_buffer,
|
||||
the_bufsize,
|
||||
samples_per_symbol,
|
||||
min_samples_per_symbol);
|
||||
(unsigned char*)output_buffer,
|
||||
the_bufsize,
|
||||
samples_per_symbol,
|
||||
min_samples_per_symbol);
|
||||
fwrite(output_buffer, sizeof(unsigned char), output_size, stdout);
|
||||
TRY_YIELD;
|
||||
}
|
||||
|
|
94
libcsdr.c
94
libcsdr.c
|
@ -1277,10 +1277,10 @@ void apply_precalculated_window_c(complexf* input, complexf* output, int size, f
|
|||
|
||||
void apply_precalculated_window_f(float* input, float* output, int size, float *windowt)
|
||||
{
|
||||
for(int i=0;i<size;i++) //@apply_precalculated_window_f
|
||||
{
|
||||
output[i] = input[i] * windowt[i];
|
||||
}
|
||||
for(int i=0;i<size;i++) //@apply_precalculated_window_f
|
||||
{
|
||||
output[i] = input[i] * windowt[i];
|
||||
}
|
||||
}
|
||||
|
||||
void apply_window_f(float* input, float* output, int size, window_t window)
|
||||
|
@ -1770,62 +1770,62 @@ void binary_slicer_f_u8(float* input, unsigned char* output, int input_size)
|
|||
}
|
||||
|
||||
int binary_decoder_f_u8(float* input,
|
||||
unsigned char* output,
|
||||
int input_size,
|
||||
int samples_per_symbol,
|
||||
int min_samples_per_symbol)
|
||||
unsigned char* output,
|
||||
int input_size,
|
||||
int samples_per_symbol,
|
||||
int min_samples_per_symbol)
|
||||
{
|
||||
static float previous_sample;
|
||||
static float sample_accumulator;
|
||||
static int sample_offset;
|
||||
static float previous_sample;
|
||||
static float sample_accumulator;
|
||||
static int sample_offset;
|
||||
|
||||
int i;
|
||||
int output_size = 0;
|
||||
float sample;
|
||||
int i;
|
||||
int output_size = 0;
|
||||
float sample;
|
||||
|
||||
//notice rising edges crossing zero and assume they coincide with a symbol boundary.
|
||||
//add all samples within a symbol and base the output on whether this accumulation is overall positive or negative.
|
||||
//notice rising edges crossing zero and assume they coincide with a symbol boundary.
|
||||
//add all samples within a symbol and base the output on whether this accumulation is overall positive or negative.
|
||||
|
||||
for(i=0;i<input_size;i++)
|
||||
{
|
||||
sample = input[i];
|
||||
for(i=0;i<input_size;i++)
|
||||
{
|
||||
sample = input[i];
|
||||
|
||||
//calibrate symbol position at a cross over (could have used either edge).
|
||||
if ((previous_sample < 0) && (sample >= 0))
|
||||
{
|
||||
//if we've almost got a symbol, accept it and publish early.
|
||||
if(sample_offset >= min_samples_per_symbol)
|
||||
{
|
||||
output[output_size] = (sample_accumulator > 0);
|
||||
output_size++;
|
||||
//fprintf(stderr, "symbol (%d:%f:%d)\n", sample_offset, sample_accumulator, output[output_size]);
|
||||
}
|
||||
//calibrate symbol position at a cross over (could have used either edge).
|
||||
if ((previous_sample < 0) && (sample >= 0))
|
||||
{
|
||||
//if we've almost got a symbol, accept it and publish early.
|
||||
if(sample_offset >= min_samples_per_symbol)
|
||||
{
|
||||
output[output_size] = (sample_accumulator > 0);
|
||||
output_size++;
|
||||
//fprintf(stderr, "symbol (%d:%f:%d)\n", sample_offset, sample_accumulator, output[output_size]);
|
||||
}
|
||||
|
||||
sample_accumulator = 0;
|
||||
sample_offset = 0;
|
||||
}
|
||||
sample_accumulator = 0;
|
||||
sample_offset = 0;
|
||||
}
|
||||
|
||||
sample_accumulator += sample;
|
||||
sample_offset++;
|
||||
if(sample_offset == samples_per_symbol)
|
||||
{
|
||||
output[output_size] = (sample_accumulator > 0);
|
||||
output_size++;
|
||||
//fprintf(stderr, "symbol (%d:%f:%d)\n", sample_offset, sample_accumulator, output[output_size]);
|
||||
sample_accumulator += sample;
|
||||
sample_offset++;
|
||||
if(sample_offset == samples_per_symbol)
|
||||
{
|
||||
output[output_size] = (sample_accumulator > 0);
|
||||
output_size++;
|
||||
//fprintf(stderr, "symbol (%d:%f:%d)\n", sample_offset, sample_accumulator, output[output_size]);
|
||||
|
||||
sample_accumulator = 0;
|
||||
sample_offset = 0;
|
||||
}
|
||||
sample_accumulator = 0;
|
||||
sample_offset = 0;
|
||||
}
|
||||
|
||||
previous_sample = input[i];
|
||||
}
|
||||
previous_sample = input[i];
|
||||
}
|
||||
|
||||
return(output_size);
|
||||
return(output_size);
|
||||
}
|
||||
|
||||
void binary_to_ascii_u8_u8(unsigned char* input,
|
||||
unsigned char* output,
|
||||
int input_size)
|
||||
unsigned char* output,
|
||||
int input_size)
|
||||
{
|
||||
for(int i=0;i<input_size;i++) output[i] = input[i] ? '1' : '0';
|
||||
}
|
||||
|
|
12
libcsdr.h
12
libcsdr.h
|
@ -289,14 +289,14 @@ void serial_line_decoder_f_u8(serial_line_t* s, float* input, unsigned char* out
|
|||
void binary_slicer_f_u8(float* input, unsigned char* output, int input_size);
|
||||
|
||||
int binary_decoder_f_u8(float* input,
|
||||
unsigned char* output,
|
||||
int input_size,
|
||||
int samples_per_symbol,
|
||||
int min_samples_per_symbol);
|
||||
unsigned char* output,
|
||||
int input_size,
|
||||
int samples_per_symbol,
|
||||
int min_samples_per_symbol);
|
||||
|
||||
void binary_to_ascii_u8_u8(unsigned char* input,
|
||||
unsigned char* output,
|
||||
int input_size);
|
||||
unsigned char* output,
|
||||
int input_size);
|
||||
|
||||
typedef enum pll_type_e
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue