kopia lustrzana https://github.com/xaelsouth/rtl-wmbus
configurable decimation rate
rodzic
683c99e1d8
commit
4098aa84bb
13
rtl_wmbus.c
13
rtl_wmbus.c
|
@ -446,19 +446,21 @@ static void time2_algorithm(unsigned bit, unsigned rssi, struct time2_algorithm
|
||||||
|
|
||||||
static int opts_run_length_algorithm_enabled = 1;
|
static int opts_run_length_algorithm_enabled = 1;
|
||||||
static int opts_time2_algorithm_enabled = 1;
|
static int opts_time2_algorithm_enabled = 1;
|
||||||
|
static unsigned decimation_rate = 2u;
|
||||||
|
|
||||||
static void print_usage(const char *program_name)
|
static void print_usage(const char *program_name)
|
||||||
{
|
{
|
||||||
fprintf(stdout, "Usage %s:\n", program_name);
|
fprintf(stdout, "Usage %s:\n", program_name);
|
||||||
fprintf(stdout, "\t-r 0 to disable run length algorithm\n");
|
fprintf(stdout, "\t-r 0 to disable run length algorithm\n");
|
||||||
fprintf(stdout, "\t-t 0 to disable time2 algorithm\n");
|
fprintf(stdout, "\t-t 0 to disable time2 algorithm\n");
|
||||||
|
fprintf(stdout, "\t-d 2 set decimation rate to 2 (defaults to 2 if omitted)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_options(int argc, char *argv[])
|
static void process_options(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int option;
|
int option;
|
||||||
|
|
||||||
while ((option = getopt(argc, argv, "r:t:")) != -1)
|
while ((option = getopt(argc, argv, "d:r:t:")) != -1)
|
||||||
{
|
{
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
|
@ -484,6 +486,9 @@ static void process_options(int argc, char *argv[])
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
decimation_rate = strtoul(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -500,7 +505,7 @@ int main(int argc, char *argv[])
|
||||||
// configurable via command line.
|
// configurable via command line.
|
||||||
const unsigned CLOCK_LOCK_THRESHOLD = 2;
|
const unsigned CLOCK_LOCK_THRESHOLD = 2;
|
||||||
|
|
||||||
const unsigned DECIMATION_RATE = 2;
|
|
||||||
// --- parameter section end ---
|
// --- parameter section end ---
|
||||||
|
|
||||||
__attribute__((__aligned__(16))) uint8_t samples[4096];
|
__attribute__((__aligned__(16))) uint8_t samples[4096];
|
||||||
|
@ -577,7 +582,7 @@ int main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
++decimation_rate_index;
|
++decimation_rate_index;
|
||||||
if (decimation_rate_index < DECIMATION_RATE) continue;
|
if (decimation_rate_index < decimation_rate) continue;
|
||||||
decimation_rate_index = 0;
|
decimation_rate_index = 0;
|
||||||
|
|
||||||
// Demodulate.
|
// Demodulate.
|
||||||
|
@ -602,7 +607,7 @@ int main(int argc, char *argv[])
|
||||||
rssi = rssi_filter(rssi); // comment out, if rssi filtering is unwanted
|
rssi = rssi_filter(rssi); // comment out, if rssi filtering is unwanted
|
||||||
#if defined(USE_MOVING_AVERAGE)
|
#if defined(USE_MOVING_AVERAGE)
|
||||||
// If using moving average, we would have doubles of each of i- and q- signal components.
|
// If using moving average, we would have doubles of each of i- and q- signal components.
|
||||||
rssi /= DECIMATION_RATE;
|
rssi /= decimation_rate;
|
||||||
#endif
|
#endif
|
||||||
// --- rssi filtering section end ---
|
// --- rssi filtering section end ---
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue