From 6d92d1b3f150e0b609f7505e9135495fabb274fc Mon Sep 17 00:00:00 2001 From: Xael South Date: Thu, 28 Jan 2021 14:26:50 +0000 Subject: [PATCH] rx_sdr --- README.md | 7 +++++++ rtl_wmbus.c | 7 ++++++- t1_c1_packet_decoder.h | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd9f10c..9fb6c0b 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ rtl-wmbus is a software defined receiver for Wireless-M-Bus. It is written in plain C and uses RTL-SDR (https://github.com/osmocom/rtl-sdr) to interface with RTL2832-based hardware. +It can also use LimeSDR or other SDR receiver through rx_sdr (see https://github.com/rxseger/rx_tools), +which in turn is using SoapySDR to interface with underlying hardware in a vendor-neutral way. + Wireless-M-Bus is the wireless version of M-Bus ("Meter-Bus", http://www.m-bus.com), which is an European standard for remote reading of smart meters. The primary purpose of rtl-wmbus is experimenting with digital signal processing and software radio. rtl-wmbus can be used on resource constrained devices such Raspberry Pi Zero or Raspberry PI B+ overclocked to 1GHz. Any Android based tablet will do the same too. @@ -49,6 +52,10 @@ Before building Android version the SDK and NDK have to be installed. See androi * rtl_sdr -f 868.95M -s 1600000 - 2>/dev/null | build/rtl_wmbus + To run continuously with rx_sdr (or even with a higher sampling and decimation rate) + * rx_sdr -f 868.95M -s 1600000 - 2>/dev/null | build/rtl_wmbus + * rx_sdr -f 868.95M -s 4000000 - 2>/dev/null | build/rtl_wmbus -d 5 + To count "good" (no 3 out of 6 errors, no checksum errors) packets: * cat samples.bin | build/rtl_wmbus 2>/dev/null | grep "[T,C]1;1;1" | wc -l diff --git a/rtl_wmbus.c b/rtl_wmbus.c index e6cbbe2..74558e3 100644 --- a/rtl_wmbus.c +++ b/rtl_wmbus.c @@ -447,6 +447,7 @@ static void time2_algorithm(unsigned bit, unsigned rssi, struct time2_algorithm static int opts_run_length_algorithm_enabled = 1; static int opts_time2_algorithm_enabled = 1; static unsigned decimation_rate = 2u; +int show_used_algorithm = 0; static void print_usage(const char *program_name) { @@ -454,13 +455,14 @@ static void print_usage(const char *program_name) fprintf(stdout, "\t-r 0 to disable run length 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"); + fprintf(stdout, "\t-s show used algorithm in the output\n"); } static void process_options(int argc, char *argv[]) { int option; - while ((option = getopt(argc, argv, "d:r:t:")) != -1) + while ((option = getopt(argc, argv, "d:r:st:")) != -1) { switch (option) { @@ -489,6 +491,9 @@ static void process_options(int argc, char *argv[]) case 'd': decimation_rate = strtoul(optarg, NULL, 10); break; + case 's': + show_used_algorithm = 1; + break; default: print_usage(argv[0]); exit(EXIT_FAILURE); diff --git a/t1_c1_packet_decoder.h b/t1_c1_packet_decoder.h index 87261a4..4087e00 100644 --- a/t1_c1_packet_decoder.h +++ b/t1_c1_packet_decoder.h @@ -661,6 +661,8 @@ static inline uint32_t get_serial(const uint8_t *const packet) return serial; } +extern int show_used_algorithm; + static void t1_c1_packet_decoder(unsigned bit, unsigned rssi, struct t1_c1_packet_decoder_work *decoder, const char *algorithm) { decoder->current_rssi = rssi; @@ -682,7 +684,7 @@ static void t1_c1_packet_decoder(unsigned bit, unsigned rssi, struct t1_c1_packe decoder->crc_ok = check_calc_crc_wmbus(decoder->packet, decoder->L) ? 1 : 0; } - algorithm = ""; // uncomment of want to see which algorithm is executed right now + if (!show_used_algorithm) algorithm = ""; fprintf(stdout, "%s%s;%u;%u;%s;%u;%u;%08X;", algorithm, decoder->c1_packet ? "C1": "T1", decoder->crc_ok, decoder->err_3outof^1,