diff --git a/README.md b/README.md index 90445c3..576e757 100755 --- a/README.md +++ b/README.md @@ -828,6 +828,23 @@ For this input, the output of `psk31_varicode_encoder_u8_u8` will be the followi ---- +### [repeat_u8](#repeat_u8) + +Syntax: + + repeat_u8 [resonator_rate × N]\n" + +It repeatedly outputs a set of data bytes (given with decimal numbers). + +For example, `csdr repeat_u8 1 1 0 0` will output: + +``` +01 01 00 00 01 01 00 00 +01 01 00 00 01 01 00 00 +``` + +---- + ### [?](#search_the_function_list) Syntax: diff --git a/csdr.c b/csdr.c index 1283254..4e3aec8 100755 --- a/csdr.c +++ b/csdr.c @@ -139,6 +139,7 @@ char usage[]= " simple_agc_cc [reference [max_gain]]\n" " firdes_resonator_c [window [--octave]]\n" " resonators_fir_cc [resonator_rate × N]\n" +" repeat_u8 \n" " ?\n" " =\n" " \n" @@ -2516,7 +2517,7 @@ int main(int argc, char *argv[]) } } - if(!strcmp(argv[1],"timing_recovery_cc")) // [--add_q [--octave ]] + if(!strcmp(argv[1],"timing_recovery_cc")) // [--add_q [--output_error | --octave ]] { if(argc<=2) return badsyntax("need required parameter (algorithm)"); timing_recovery_algorithm_t algorithm = timing_recovery_get_algorithm_from_string(argv[2]); @@ -2530,8 +2531,12 @@ int main(int argc, char *argv[]) int add_q = (argc>=5 && !strcmp(argv[4], "--add_q")); int debug_n = 0; + int output_error = 0; if(argc>=7 && !strcmp(argv[5], "--octave")) debug_n = atoi(argv[6]); if(debug_n<0) badsyntax("debug_n should be >= 0"); + if(argc>=6 && !strcmp(argv[5], "--output_error")) output_error = 1; + float* timing_error = NULL; + if(output_error) timing_error = (float*)malloc(sizeof(float)*the_bufsize); if(!initialize_buffers()) return -2; sendbufsize(the_bufsize/decimation); @@ -2546,9 +2551,10 @@ int main(int argc, char *argv[]) { FEOF_CHECK; if(debug_n && ++debug_i%debug_n==0) timing_recovery_trigger_debug(&state, 3); - timing_recovery_cc((complexf*)input_buffer, (complexf*)output_buffer, the_bufsize, &state); + timing_recovery_cc((complexf*)input_buffer, (complexf*)output_buffer, the_bufsize, timing_error, &state); //fprintf(stderr, "trcc is=%d, os=%d, ip=%d\n",the_bufsize, state.output_size, state.input_processed); - fwrite(output_buffer, sizeof(complexf), state.output_size, stdout); + if(timing_error) fwrite(timing_error, sizeof(float), state.output_size, stdout); + else fwrite(output_buffer, sizeof(complexf), state.output_size, stdout); TRY_YIELD; //fprintf(stderr, "state.input_processed = %d\n", state.input_processed); memmove((complexf*)input_buffer,((complexf*)input_buffer)+state.input_processed,(the_bufsize-state.input_processed)*sizeof(complexf)); //memmove lets the source and destination overlap @@ -2867,6 +2873,19 @@ int main(int argc, char *argv[]) } } + if(!strcmp(argv[1], "repeat_u8")) + { + if(argc<=2) badsyntax("no data to repeat"); + unsigned char* repeat_buffer = (unsigned char*)malloc(sizeof(unsigned char)*(argc-2)); + for(int i=0;i2) error=2; if(error<-2) error=-2; diff --git a/libcsdr.h b/libcsdr.h index 0a0febf..8617282 100644 --- a/libcsdr.h +++ b/libcsdr.h @@ -334,7 +334,7 @@ typedef struct timing_recovery_state_s } timing_recovery_state_t; timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorithm, int decimation_rate, int use_q); -void timing_recovery_cc(complexf* input, complexf* output, int input_length, timing_recovery_state_t* state); +void timing_recovery_cc(complexf* input, complexf* output, int input_size, float* timing_error, timing_recovery_state_t* state); timing_recovery_algorithm_t timing_recovery_get_algorithm_from_string(char* input); char* timing_recovery_get_string_from_algorithm(timing_recovery_algorithm_t algorithm); void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_phase);