diff --git a/2017-05-01_Paketdefinition.xlsx b/2017-05-01_Paketdefinition.xlsx index 800db43ef1403d0a261e6f79c21007cde303f5b1..f0cb450d4fdadfbe73dd612c728cce9f78a48262 100644 Binary files a/2017-05-01_Paketdefinition.xlsx and b/2017-05-01_Paketdefinition.xlsx differ diff --git a/Vaillant.grc b/Vaillant.grc index 5dbcb6e80ea31c939a5e2ad073dde24c29fb6a05..1b1bbe3264f412fdd19bc60596a2373094931bc1 100644 --- a/Vaillant.grc +++ b/Vaillant.grc @@ -264,7 +264,7 @@ </param> <param> <key>_coordinate</key> - <value>(216, 911)</value> + <value>(80, 919)</value> </param> <param> <key>_rotation</key> @@ -370,7 +370,7 @@ </param> <param> <key>_coordinate</key> - <value>(240, 804)</value> + <value>(688, 772)</value> </param> <param> <key>_rotation</key> @@ -417,7 +417,7 @@ </param> <param> <key>_coordinate</key> - <value>(224, 873)</value> + <value>(160, 865)</value> </param> <param> <key>_rotation</key> @@ -460,7 +460,7 @@ </param> <param> <key>_coordinate</key> - <value>(424, 593)</value> + <value>(312, 593)</value> </param> <param> <key>_rotation</key> @@ -562,7 +562,7 @@ </param> <param> <key>_coordinate</key> - <value>(800, 790)</value> + <value>(816, 854)</value> </param> <param> <key>_rotation</key> @@ -660,7 +660,7 @@ </param> <param> <key>_coordinate</key> - <value>(376, 809)</value> + <value>(832, 777)</value> </param> <param> <key>_rotation</key> @@ -695,11 +695,11 @@ </param> <param> <key>_enabled</key> - <value>1</value> + <value>True</value> </param> <param> <key>_coordinate</key> - <value>(664, 692)</value> + <value>(400, 804)</value> </param> <param> <key>_rotation</key> @@ -707,7 +707,7 @@ </param> <param> <key>id</key> - <value>blocks_keep_one_in_n_1</value> + <value>blocks_keep_one_in_n_0</value> </param> <param> <key>maxoutbuf</key> @@ -801,7 +801,7 @@ </param> <param> <key>_coordinate</key> - <value>(456, 678)</value> + <value>(256, 790)</value> </param> <param> <key>_rotation</key> @@ -809,11 +809,11 @@ </param> <param> <key>high</key> - <value>0.001</value> + <value>0.005</value> </param> <param> <key>id</key> - <value>blocks_threshold_ff_1</value> + <value>blocks_threshold_ff_0</value> </param> <param> <key>init</key> @@ -821,7 +821,7 @@ </param> <param> <key>low</key> - <value>0.0005</value> + <value>0.001</value> </param> <param> <key>maxoutbuf</key> @@ -934,6 +934,69 @@ <value>44100</value> </param> </block> + <block> + <key>digital_clock_recovery_mm_xx</key> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>affinity</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(256, 688)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>gain_mu</key> + <value>0.175</value> + </param> + <param> + <key>gain_omega</key> + <value>0.0003</value> + </param> + <param> + <key>id</key> + <value>digital_clock_recovery_mm_xx_0</value> + </param> + <param> + <key>maxoutbuf</key> + <value>0</value> + </param> + <param> + <key>minoutbuf</key> + <value>0</value> + </param> + <param> + <key>mu</key> + <value>0.5</value> + </param> + <param> + <key>omega_relative_limit</key> + <value>0.005</value> + </param> + <param> + <key>omega</key> + <value>samp_rate/baud_rate/2</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + </block> <block> <key>import</key> <param> @@ -1001,7 +1064,7 @@ </param> <param> <key>_coordinate</key> - <value>(232, 458)</value> + <value>(40, 442)</value> </param> <param> <key>_rotation</key> @@ -3334,7 +3397,7 @@ </param> <param> <key>_coordinate</key> - <value>(848, 567)</value> + <value>(512, 567)</value> </param> <param> <key>_rotation</key> @@ -3421,7 +3484,7 @@ </param> <param> <key>_coordinate</key> - <value>(856, 671)</value> + <value>(856, 575)</value> </param> <param> <key>_rotation</key> @@ -3522,7 +3585,13 @@ </connection> <connection> <source_block_id>blocks_complex_to_mag_squared_1</source_block_id> - <sink_block_id>blocks_threshold_ff_1</sink_block_id> + <sink_block_id>blocks_threshold_ff_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_complex_to_mag_squared_1</source_block_id> + <sink_block_id>digital_clock_recovery_mm_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -3545,17 +3614,11 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_keep_one_in_n_1</source_block_id> + <source_block_id>blocks_keep_one_in_n_0</source_block_id> <sink_block_id>blocks_add_const_vxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> - <connection> - <source_block_id>blocks_keep_one_in_n_1</source_block_id> - <sink_block_id>wxgui_scopesink2_1_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> <connection> <source_block_id>blocks_multiply_xx_0</source_block_id> <sink_block_id>low_pass_filter_0</sink_block_id> @@ -3563,8 +3626,8 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_threshold_ff_1</source_block_id> - <sink_block_id>blocks_keep_one_in_n_1</sink_block_id> + <source_block_id>blocks_threshold_ff_0</source_block_id> + <sink_block_id>blocks_keep_one_in_n_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> @@ -3574,6 +3637,18 @@ <source_key>0</source_key> <sink_key>0</sink_key> </connection> + <connection> + <source_block_id>digital_clock_recovery_mm_xx_0</source_block_id> + <sink_block_id>blocks_add_const_vxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_clock_recovery_mm_xx_0</source_block_id> + <sink_block_id>wxgui_scopesink2_1_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> <connection> <source_block_id>low_pass_filter_0</source_block_id> <sink_block_id>analog_am_demod_cf_0</sink_block_id> diff --git a/Vaillant_decode_bitstuff_hex b/Vaillant_decode_bitstuff_hex new file mode 100755 index 0000000000000000000000000000000000000000..2c743beac31b2dc9b3190362b8e9d4cdd6e6a5c7 Binary files /dev/null and b/Vaillant_decode_bitstuff_hex differ diff --git a/Vaillant_decode_bitstuff_hex.c b/Vaillant_decode_bitstuff_hex.c new file mode 100644 index 0000000000000000000000000000000000000000..ed7c98b4441a5298341f7914f84117c0720fffb3 --- /dev/null +++ b/Vaillant_decode_bitstuff_hex.c @@ -0,0 +1,146 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <time.h> +#include <sys/time.h> +#include <math.h> + +// Vaillant_decode_bitstuff_hex.c Copyright 2017 Reinhold Kainhofer +// License: GNU GPL 3.0 +// +// +// Compile with: +// gcc Vaillant_decode_bitstuff_hex.c -o Vaillant_decode_bitstuff_hex +// +// Reads a string of 0 and 1 from STDIN, tries to decode it as Vaillant-encoded +// applies bit-unstaffing (i.e. if 5 consecutive one bits are followed by a +// zero bit, the zero bit is discarded and prints the converted result to +// STDOUT (prefixed with current date/time). +// Decoding errors (i.e. no amplitude switch at the pulse mid-point) are +// indicated by a ? +// +// This app is purely pipe-through, i.e. its usage is: +// +// cat signalfile.txt | Vaillant_decode_bitstuff_hex > decoded_signalfile.txt +// +// To process an output file while it is still written to, you can use tail. This +// will print the proper timestamps for the signals: +// +// tail -n +1 -f signalfile.txt | ./Vaillant_decode_bitstuff_hex + +typedef int bool; +#define true 1 +#define false 0 + +void main(int argc, char *argv[]) +{ + setbuf(stdout, NULL); + + bool insideZeroes = true; + unsigned int zeroes = 0; + + unsigned int ones = 0; // Count the number of consecutive ones in the output (for bit-unstuffing) + unsigned int pos = 0; // Current output count in octet (to space bytes) + + unsigned int validPos = 0; + unsigned int comment = 0; + + unsigned char ch, prev; + unsigned char currVal = 0; + while(read(STDIN_FILENO, &ch, 1) > 0) { + // Everything starting with # is a comment until the end of line + if (ch == '#') { + comment = true; +// if (!insideZeroes) printf("\n"); +// insideZeroes = 1; + continue; + } + // Ignore all line breaks and spaces (so output can be formatted before running through this app): + if (ch == '\n' || ch == '\r') { + comment = false; + continue; + } + // Ignore all spaces (so output can be formatted before running through this app) and comments: + if (comment || ch == ' ') { + continue; + } + + // Keep track of how many zeroes we have (count at most up to 1000!) + if (ch == '0') { + if (zeroes++ > 1000) zeroes = 1000; + } else { + zeroes = 0; + } + // We have zeroes, so jump to the next char if we have another 0, reset otherwise + if (insideZeroes) { + if (ch == '0') { + prev = ch; + continue; + } else { + insideZeroes = false; + validPos = 0; + // A '1' after a long sequence of '0' means some kind of signal + // (valid or invalid), so print the current date/time to start + // a new line: + struct timeval tv; + gettimeofday(&tv, NULL); + int millisec = tv.tv_usec/1000; + + char fmt[64], s[64]; + struct tm *tm; + if((tm = localtime(&tv.tv_sec)) != NULL) { + strftime(fmt, sizeof fmt, "%F %T", tm); + snprintf(s, sizeof s, "%s.%03d", fmt, millisec); + printf("%s 0x", s); + } + currVal = 0; + } + } + if (ch != '0' && ch != '1') { + printf("["); + fwrite(&ch, 1, 1, stdout); + printf("]"); + } + + // Inside the pulse => if state changed, it's a 1, if it stayed, it's a 0 + if (validPos == 1) { + // bit-unstuffing: Ignore a 0 after exactly five consecutive 1 bits: + if (ch != prev) { // a transition indicates a one + ones++; + currVal |= (1<<pos); + pos++; + } else { // no transition indicates a zero + if (ones!=5) { + pos++; + } + ones = 0; + } + } else { // validPos == 0 + // If 0/1 does not change => INVALID, unless it stays 0, which indicates end of signal + if (ch == prev) { + if (ch == '0') { + insideZeroes = true; + zeroes = true; + if (pos>0) { + printf("(%X)", currVal); + } + printf("\n"); + pos = 0; + } else { + printf("?"); + pos++; + } + } + } + if (pos == 8) { // A full byte was printed, so add a space + pos = 0; + printf("%02X", currVal); + printf(" "); + currVal = 0; + } + // Switch validPos: + validPos = (validPos + 1) % 2; + prev = ch; + } + printf("\r\n"); +}