Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile under MacOSX (and support for Qundis Q Caloric Heat Cost Allocator) #8

Closed
kidpixo opened this issue Feb 17, 2019 · 36 comments
Closed

Comments

@kidpixo
Copy link

kidpixo commented Feb 17, 2019

Hi,
sorry for the dumb question: I compiled wmbusmeters in a docker/debian container , but docker under mac cannot pass usb device to the hypervisor.

Under mac I cannot get it to compile. Here my g++ compiler specs and the output below.

I see in the Travis tests here that you are using C++ 4.8.something, maybe my problem is there?

A side question:
I cannot find a driver for mac to expose my cheap usb SDR (a chinese Realtek RTL28380, confirmed working with rtl_sdr and rtl-wmbus) under /dev/. I guess the rtl_sdr uses directly libusb to search for the device. There is a way to pass the data from stdin? Or any suggestion for running under mac?
In the future I'll switch this to a raspberry.

Thanks!

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin16/8.2.0/lto-wrapper
Target: x86_64-apple-darwin16
Configured with: /opt/local/var/macports/build/_opt_bblocal_var_buildworker_ports_build_ports_lang_gcc8/gcc8/work/gcc-8.2.0/configure --prefix=/opt/local --build=x86_64-apple-darwin16 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc8 --includedir=/opt/local/include/gcc8 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-8 --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-8 --with-gxx-include-dir=/opt/local/include/gcc8/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-isl=/opt/local --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-build-config=bootstrap-debug --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-tls --with-pkgversion='MacPorts gcc8 8.2.0_3'
Thread model: posix
gcc version 8.2.0 (MacPorts gcc8 8.2.0_3)
 make
g++ -Os -fPIC -fmessage-length=0 -std=c++11 -Wall -Wno-maybe-uninitialized -Wno-unused-function "-DWMBUSMETERS_VERSION=\"0.8.1\"" aes.cc -c -o build/aes.o
g++ -Os -fPIC -fmessage-length=0 -std=c++11 -Wall -Wno-maybe-uninitialized -Wno-unused-function "-DWMBUSMETERS_VERSION=\"0.8.1\"" cmdline.cc -c -o build/cmdline.o
In file included from /usr/include/_wctype.h:47,
                 from /usr/include/wchar.h:92,
                 from /opt/local/include/gcc8/c++/cwchar:44,
                 from /opt/local/include/gcc8/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc8/c++/bits/char_traits.h:40,
                 from /opt/local/include/gcc8/c++/string:40,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/usr/include/_types/_wctype_t.h:31:9: error: '__darwin_wctype_t' does not name a type; did you mean '__darwin_time_t'?
 typedef __darwin_wctype_t wctype_t;
         ^~~~~~~~~~~~~~~~~
         __darwin_time_t
In file included from /usr/include/wchar.h:92,
                 from /opt/local/include/gcc8/c++/cwchar:44,
                 from /opt/local/include/gcc8/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc8/c++/bits/char_traits.h:40,
                 from /opt/local/include/gcc8/c++/string:40,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/usr/include/_wctype.h:84:22: error: 'wctype_t' has not been declared
 iswctype(wint_t _wc, wctype_t _charclass)
                      ^~~~~~~~
/usr/include/_wctype.h:171:1: error: 'wctype_t' does not name a type; did you mean 'iswctype'?
 wctype_t
 ^~~~~~~~
 iswctype
In file included from /opt/local/include/gcc8/c++/cwchar:44,
                 from /opt/local/include/gcc8/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc8/c++/bits/char_traits.h:40,
                 from /opt/local/include/gcc8/c++/string:40,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/usr/include/wchar.h:98:15: error: 'FILE' was not declared in this scope
 wint_t fgetwc(FILE *);
               ^~~~
/usr/include/wchar.h:98:15: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:93:1:
+#include <cstdio>

/usr/include/wchar.h:98:15:
 wint_t fgetwc(FILE *);
               ^~~~
/usr/include/wchar.h:98:21: error: expected primary-expression before ')' token
 wint_t fgetwc(FILE *);
                     ^
/usr/include/wchar.h:99:44: error: 'FILE' has not been declared
 wchar_t *fgetws(wchar_t * __restrict, int, FILE * __restrict);
                                            ^~~~
/usr/include/wchar.h:100:24: error: 'FILE' has not been declared
 wint_t fputwc(wchar_t, FILE *);
                        ^~~~
/usr/include/wchar.h:101:40: error: 'FILE' has not been declared
 int fputws(const wchar_t * __restrict, FILE * __restrict);
                                        ^~~~
/usr/include/wchar.h:102:11: error: 'FILE' was not declared in this scope
 int fwide(FILE *, int);
           ^~~~
/usr/include/wchar.h:102:11: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:102:17: error: expected primary-expression before ',' token
 int fwide(FILE *, int);
                 ^
/usr/include/wchar.h:102:19: error: expected primary-expression before 'int'
 int fwide(FILE *, int);
                   ^~~
/usr/include/wchar.h:102:22: error: expression list treated as compound expression in initializer [-fpermissive]
 int fwide(FILE *, int);
                      ^
/usr/include/wchar.h:103:14: error: 'FILE' was not declared in this scope
 int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
              ^~~~
/usr/include/wchar.h:103:14: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:103:31: error: expected primary-expression before ',' token
 int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
                               ^
/usr/include/wchar.h:103:33: error: expected primary-expression before 'const'
 int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
                                 ^~~~~
/usr/include/wchar.h:103:61: error: expected primary-expression before '...' token
 int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
                                                             ^~~
/usr/include/wchar.h:103:64: error: expression list treated as compound expression in initializer [-fpermissive]
 int fwprintf(FILE * __restrict, const wchar_t * __restrict, ...);
                                                                ^
/usr/include/wchar.h:104:13: error: 'FILE' was not declared in this scope
 int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
             ^~~~
/usr/include/wchar.h:104:13: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:104:30: error: expected primary-expression before ',' token
 int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
                              ^
/usr/include/wchar.h:104:32: error: expected primary-expression before 'const'
 int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
                                ^~~~~
/usr/include/wchar.h:104:60: error: expected primary-expression before '...' token
 int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
                                                            ^~~
/usr/include/wchar.h:104:63: error: expression list treated as compound expression in initializer [-fpermissive]
 int fwscanf(FILE * __restrict, const wchar_t * __restrict, ...);
                                                               ^
/usr/include/wchar.h:105:14: error: 'FILE' was not declared in this scope
 wint_t getwc(FILE *);
              ^~~~
/usr/include/wchar.h:105:14: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:105:20: error: expected primary-expression before ')' token
 wint_t getwc(FILE *);
                    ^
/usr/include/wchar.h:113:23: error: 'FILE' has not been declared
 wint_t putwc(wchar_t, FILE *);
                       ^~~~
/usr/include/wchar.h:117:24: error: 'FILE' has not been declared
 wint_t ungetwc(wint_t, FILE *);
                        ^~~~
/usr/include/wchar.h:118:15: error: 'FILE' was not declared in this scope
 int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
               ^~~~
/usr/include/wchar.h:118:15: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:118:32: error: expected primary-expression before ',' token
 int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
                                ^
/usr/include/wchar.h:118:34: error: expected primary-expression before 'const'
 int vfwprintf(FILE * __restrict, const wchar_t * __restrict,
                                  ^~~~~
/usr/include/wchar.h:119:22: error: expected primary-expression before ')' token
      __darwin_va_list);
                      ^
/usr/include/wchar.h:119:22: error: expression list treated as compound expression in initializer [-fpermissive]
/usr/include/wchar.h:170:14: error: 'FILE' was not declared in this scope
 int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
              ^~~~
/usr/include/wchar.h:170:14: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:170:31: error: expected primary-expression before ',' token
 int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
                               ^
/usr/include/wchar.h:170:33: error: expected primary-expression before 'const'
 int vfwscanf(FILE * __restrict, const wchar_t * __restrict,
                                 ^~~~~
/usr/include/wchar.h:171:22: error: expected primary-expression before ')' token
      __darwin_va_list);
                      ^
/usr/include/wchar.h:171:22: error: expression list treated as compound expression in initializer [-fpermissive]
/usr/include/wchar.h:214:18: error: 'FILE' was not declared in this scope
 wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
                  ^~~~
/usr/include/wchar.h:214:18: note: 'FILE' is defined in header '<cstdio>'; did you forget to '#include <cstdio>'?
/usr/include/wchar.h:214:35: error: expected primary-expression before ',' token
 wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
                                   ^
/usr/include/wchar.h:214:44: error: expected primary-expression before '*' token
 wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
                                            ^
/usr/include/wchar.h:214:45: error: expected primary-expression before ')' token
 wchar_t *fgetwln(FILE * __restrict, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
                                             ^
/usr/include/wchar.h:214:45: error: expression list treated as compound expression in initializer [-fpermissive]
In file included from /usr/include/wchar.h:92,
                 from /opt/local/include/gcc8/c++/cwchar:44,
                 from /opt/local/include/gcc8/c++/bits/postypes.h:40,
                 from /opt/local/include/gcc8/c++/bits/char_traits.h:40,
                 from /opt/local/include/gcc8/c++/string:40,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/opt/local/include/gcc8/c++/bits/char_traits.h: In static member function 'static constexpr std::char_traits<wchar_t>::int_type std::char_traits<wchar_t>::eof()':
/opt/local/include/gcc8/c++/bits/char_traits.h:487:38: error: '__DARWIN_WEOF' was not declared in this scope
       { return static_cast<int_type>(WEOF); }
                                      ^~~~
In file included from /opt/local/include/gcc8/c++/string:40,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/opt/local/include/gcc8/c++/bits/char_traits.h:487:45: error: body of 'constexpr' function 'static constexpr std::char_traits<wchar_t>::int_type std::char_traits<wchar_t>::eof()' not a return-statement
       { return static_cast<int_type>(WEOF); }
                                             ^
In file included from /opt/local/include/gcc8/c++/ext/string_conversions.h:43,
                 from /opt/local/include/gcc8/c++/bits/basic_string.h:6391,
                 from /opt/local/include/gcc8/c++/string:52,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/opt/local/include/gcc8/c++/cstdio: At global scope:
/opt/local/include/gcc8/c++/cstdio:98:11: error: '::FILE' has not been declared
   using ::FILE;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:99:11: error: '::fpos_t' has not been declared
   using ::fpos_t;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:101:11: error: '::clearerr' has not been declared
   using ::clearerr;
           ^~~~~~~~
/opt/local/include/gcc8/c++/cstdio:102:11: error: '::fclose' has not been declared
   using ::fclose;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:103:11: error: '::feof' has not been declared
   using ::feof;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:104:11: error: '::ferror' has not been declared
   using ::ferror;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:105:11: error: '::fflush' has not been declared
   using ::fflush;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:106:11: error: '::fgetc' has not been declared
   using ::fgetc;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:107:11: error: '::fgetpos' has not been declared
   using ::fgetpos;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:108:11: error: '::fgets' has not been declared
   using ::fgets;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:109:11: error: '::fopen' has not been declared
   using ::fopen;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:110:11: error: '::fprintf' has not been declared
   using ::fprintf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:111:11: error: '::fputc' has not been declared
   using ::fputc;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:112:11: error: '::fputs' has not been declared
   using ::fputs;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:113:11: error: '::fread' has not been declared
   using ::fread;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:114:11: error: '::freopen' has not been declared
   using ::freopen;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:115:11: error: '::fscanf' has not been declared
   using ::fscanf;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:116:11: error: '::fseek' has not been declared
   using ::fseek;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:117:11: error: '::fsetpos' has not been declared
   using ::fsetpos;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:118:11: error: '::ftell' has not been declared
   using ::ftell;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:119:11: error: '::fwrite' has not been declared
   using ::fwrite;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:120:11: error: '::getc' has not been declared
   using ::getc;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:121:11: error: '::getchar' has not been declared
   using ::getchar;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:124:11: error: '::gets' has not been declared
   using ::gets;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:126:11: error: '::perror' has not been declared
   using ::perror;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:127:11: error: '::printf' has not been declared
   using ::printf;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:128:11: error: '::putc' has not been declared
   using ::putc;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:129:11: error: '::putchar' has not been declared
   using ::putchar;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:130:11: error: '::puts' has not been declared
   using ::puts;
           ^~~~
/opt/local/include/gcc8/c++/cstdio:131:11: error: '::remove' has not been declared
   using ::remove;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:132:11: error: '::rename' has not been declared
   using ::rename;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:133:11: error: '::rewind' has not been declared
   using ::rewind;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:134:11: error: '::scanf' has not been declared
   using ::scanf;
           ^~~~~
/opt/local/include/gcc8/c++/cstdio:135:11: error: '::setbuf' has not been declared
   using ::setbuf;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:136:11: error: '::setvbuf' has not been declared
   using ::setvbuf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:137:11: error: '::sprintf' has not been declared
   using ::sprintf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:138:11: error: '::sscanf' has not been declared
   using ::sscanf;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:139:11: error: '::tmpfile' has not been declared
   using ::tmpfile;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:141:11: error: '::tmpnam' has not been declared
   using ::tmpnam;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:143:11: error: '::ungetc' has not been declared
   using ::ungetc;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:144:11: error: '::vfprintf' has not been declared
   using ::vfprintf;
           ^~~~~~~~
/opt/local/include/gcc8/c++/cstdio:145:11: error: '::vprintf' has not been declared
   using ::vprintf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:146:11: error: '::vsprintf' has not been declared
   using ::vsprintf;
           ^~~~~~~~
/opt/local/include/gcc8/c++/cstdio:175:11: error: '::snprintf' has not been declared
   using ::snprintf;
           ^~~~~~~~
/opt/local/include/gcc8/c++/cstdio:176:11: error: '::vfscanf' has not been declared
   using ::vfscanf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:177:11: error: '::vscanf' has not been declared
   using ::vscanf;
           ^~~~~~
/opt/local/include/gcc8/c++/cstdio:178:11: error: '::vsnprintf' has not been declared
   using ::vsnprintf;
           ^~~~~~~~~
/opt/local/include/gcc8/c++/cstdio:179:11: error: '::vsscanf' has not been declared
   using ::vsscanf;
           ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:185:22: error: '__gnu_cxx::snprintf' has not been declared
   using ::__gnu_cxx::snprintf;
                      ^~~~~~~~
/opt/local/include/gcc8/c++/cstdio:186:22: error: '__gnu_cxx::vfscanf' has not been declared
   using ::__gnu_cxx::vfscanf;
                      ^~~~~~~
/opt/local/include/gcc8/c++/cstdio:187:22: error: '__gnu_cxx::vscanf' has not been declared
   using ::__gnu_cxx::vscanf;
                      ^~~~~~
/opt/local/include/gcc8/c++/cstdio:188:22: error: '__gnu_cxx::vsnprintf' has not been declared
   using ::__gnu_cxx::vsnprintf;
                      ^~~~~~~~~
/opt/local/include/gcc8/c++/cstdio:189:22: error: '__gnu_cxx::vsscanf' has not been declared
   using ::__gnu_cxx::vsscanf;
                      ^~~~~~~
In file included from /opt/local/include/gcc8/c++/string:52,
                 from /opt/local/include/gcc8/c++/stdexcept:39,
                 from /opt/local/include/gcc8/c++/array:39,
                 from /opt/local/include/gcc8/c++/tuple:39,
                 from /opt/local/include/gcc8/c++/functional:54,
                 from util.h:23,
                 from meters.h:21,
                 from cmdline.h:21,
                 from cmdline.cc:18:
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6445:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int),
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6445:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int),
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(unsigned int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6450:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6450:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(long int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6456:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(long),
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6456:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(long),
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(long unsigned int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6461:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6461:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(long long int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6467:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6467:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(long long unsigned int)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6473:50: error: 'vsnprintf' is not a member of 'std'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6473:50: note: suggested alternative: 'isprint'
   { return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(float)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6482:50: error: 'vsnprintf' is not a member of 'std'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6482:50: note: suggested alternative: 'isprint'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(double)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6491:50: error: 'vsnprintf' is not a member of 'std'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6491:50: note: suggested alternative: 'isprint'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
                                                  isprint
/opt/local/include/gcc8/c++/bits/basic_string.h: In function 'std::__cxx11::string std::__cxx11::to_string(long double)':
/opt/local/include/gcc8/c++/bits/basic_string.h:6500:50: error: 'vsnprintf' is not a member of 'std'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
/opt/local/include/gcc8/c++/bits/basic_string.h:6500:50: note: suggested alternative: 'isprint'
     return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
                                                  ^~~~~~~~~
                                                  isprint
make: *** [build/cmdline.o] Error 1
@weetmuts
Copy link
Member

This looks fun! From what you write, it seems that it should be possible to receive the meter wmbus messages using a generic RTL-SDR usb dongle and the software rtl-wmbus. (wmbusmeters currently expects you to have either an im871A or an amber usb stick.)

If you can send me some example output from running the "rtl_sdr | rtl-wmbus" software when it captures your meter using the RTL-SDR dongle, then I can add a generic way of piping the output from rtl-wmbus into wmbusmeters. Please also send the command line you use to capture the wmbus data.
The /dev/ttyUSB0 device is used to talk to the radiochip in the im871A/amber dongles, so
there is no need to simulate a whole /dev/tty device for this new functionality.

I will take a look at compiling for macosx as well.

@kidpixo
Copy link
Author

kidpixo commented Feb 17, 2019

Wow, your are super quick! Thanks!

I'm not sure if I understand the /dev/ttyUSB0 part, under mac seems to be slightly different from *NIX

First, my exact HW is :

Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: 00000001

Using device 0: Generic RTL2832U OEM
Found Fitipower FC0012 tuner
Supported gain values (5): -9.9 -4.0 7.1 17.9 19.2
Sampling at 2048000 S/s.No E4000 tuner found, aborting.

My output (truncated and filtered only lines with ^[TC]1;1;1):

$ rtl_sdr -f 868.9M -s 1600000 - 2>/dev/null | ./rtl_wmbus

C1;1;1;2019-02-09 07:14:18.000;117;102;94740459;0x49449344590474943508780dff5f3500827f0000f10007b06effff530100005f2c620100007f2118010000008000800080008000000000000000000e003f005500d4ff2f046d10086922
C1;1;1;2019-02-09 07:14:39.000;127;116;94740258;0x49449344580274943508780dff5f350082190000ef0007b06effff070100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d10086922
C1;1;1;2019-02-09 07:14:48.000;141;128;94740406;0x49449344060474943508780dff5f350082240000810007b06effff160100005f2c630100007f219100000000800080008000800000000000000000120040005100b8ff2f046d10086922```

EDIT : Too much data.

@weetmuts
Copy link
Member

Thanks, wmbusmeters seems to parse (at least part of) that output. I added a work-in-progress
meter qcaloric (which I guess that you are reading?) to wmbusmeters and pushed to github.

Take the bytes you posted:
C1;1;1;2019-02-09 07:14:18.000;117;102;94740459;0x49449344590474943508780dff5f3500827f0000f10007b06effff530100005f2c620100007f2118010000008000800080008000000000000000000e003f005500d4ff2f046d10086922
and store only the data bytes in a file simulation_kidpixo.txt like this:
telegram=|49449344590474943508780dff5f3500827f0000f10007b06effff530100005f2c620100007f2118010000008000800080008000000000000000000e003f005500d4ff2f046d10086922|

Now run: ./build/wmbusmeters --c1 --debug simulation_kidpixo.txt HeatMe qcaloric 94740459 ""
and you will get the following output:
(cmdline) using usb device: simulation_kidpixo.txt
(cmdline) number of meters: 1
(simulator) found simulation_kidpixo.txt
(simulator) set link mode 00
(simulator) set link mode completed
(simulator) get link mode
(simulator) config: link mode 00
(cmdline) using link mode: C1
(qcaloric) configured "HeatMe" "qcaloric" "94740459" not-encrypted
(simulator) from file "49449344590474943508780dff5f3500827f0000f10007b06effff530100005f2c620100007f2118010000008000800080008000000000000000000e003f005500d4ff2f046d10086922"
(wmbus) received telegram 94740459 C-field=44 M-field=4493 (QDS) A-field-version=35 A-field-dev-type=08 (Heat Cost Allocator) Ci-field=78 (EN 13757-3 Application Layer without Transport Layer (to be defined))
(wmbus) frame "49449344590474943508780DFF5F3500827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F046D10086922"
(wmbus) payload "0DFF5F3500827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F046D10086922"
(wmbus) 00: 49 length (73 bytes)
(wmbus) 01: 44 c-field (SND_NR)
(wmbus) 02: 9344 m-field (4493=QDS)
(wmbus) 04: 59047494 a-field-addr (94740459)
(wmbus) 08: 35 a-field-version
(wmbus) 09: 08 a-field-type (Heat Cost Allocator)
(wmbus) 0a: 78 ci-field (EN 13757-3 Application Layer without Transport Layer (to be defined))
(wmbus) 4944934459047494350878
(qcaloric) HeatMe 94740459 (qcaloric) log "telegram=|4944934459047494350878|0DFF5F3500827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F046D10086922|+0"
(dvparser) found new format "0DFF5F046D" with hash 3cd3, remembering!
(qcaloric) 0b: 0D dif (variable length Instantaneous value)
(qcaloric) 0c: FF vif (Vendor extension)
(qcaloric) 0d: 5F vife (?)
(qcaloric) 0e: 00827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F
(qcaloric) 43: 04 dif (32 Bit Integer/Binary Instantaneous value)
(qcaloric) 44: 6D vif (Date and time type)
(qcaloric) 45: 10086922
(qcaloric) 49449344590474943508780DFF5F00827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F046D10086922
HeatMe 94740459 0.000 kwh 2019-02-17 21:54.19
(serial) event loop stopped!

@weetmuts
Copy link
Member

Assuming that my mbus parser works correctly, it looks like the meter produces a large chunk
of variable length instantaneous data, followed by a datetime.
If this is correct, then the meter sends most of its data as a binary blob, that we need to decode somehow.

If you have some known readings from the meter, that would help in decoding...

@kidpixo
Copy link
Author

kidpixo commented Feb 17, 2019

Wow! I'm impressed! Thanks!

You're right, it is indeed the Qcaloric5.5 Heat cost allocators – QUNDIS EN . As far I understood, the data could be send AES-128 encrypted, the binary blob could indicate that it is the case.

I can try to get some reading from the cost allocator display directly, but I cannot sync it directly with a telegram.

I must ask the producer for the AES key I guess...

@kidpixo
Copy link
Author

kidpixo commented Feb 17, 2019

I found a reference to their wmbus protocol also in OpenHub (search THING_TYPE_NAME_QUNDIS_QCALORIC_5_5 ) > openhab-binding-wmbus/WMBusHKVDiscoveryService.java at 4cbc7257285e815bb4b837b9814e6f07603615f5 · pokerazor/openhab-binding-wmbus

@weetmuts
Copy link
Member

I do not think it is encrypted, as you can see the data here:
00827F0000F10007B06EFFFF530100005F2C620100007F2118010000008000800080008000000000000000000E003F005500D4FF2F
encrypted data would be much more random.

Thanks for the link, I will take a look, and also take a look at the macosx build problem.

@weetmuts
Copy link
Member

I can try to get some reading from the cost allocator display directly, but I cannot sync it directly with a telegram.

That is ok, as long as it is relatively close, it would help a lot. I am also interested in which
unit (kw/calories/...) the qcaloric reports the values.

@kidpixo
Copy link
Author

kidpixo commented Feb 19, 2019

Sorry for the delay, here some data I got from the sensor and from the datasheet Data-sheet_Q-caloric-5.5_DST2-QCAL-GB0-P2P3_Qcal_55_070518_V260_FINAL.pdf

EDIT : This should be the ID of the sensor : 94740407

Those the data I got from reading the display directly :

Key (ENG) Value (20. Feb 2019)
Current consumption 00127
Display test: Everything on
Display test: Everything off
Due date MD 31.12
Due date value M 00145
Checksum M c03250P
Evaluation level K-level k 060
Variable display FC-22s

Current consumption could be Watts or Calories?

Variable display shows the actual sensor configuration:

  • FC = Code for Q walk-by & Q AMR, C-mode
  • 2 = Code for the 20x algorithm
  • 2 = Code for 2-sensor measuring system

Measuring system table from the datasheet:

Scaling Product or unit scale
Radiator output range Algorithm 2: 21 - 9999 Watts
Temperature sensor NTC (pre-aged)
2 sensors 1 sensor for radiator temperature and
1 sensor for room air temperature
Sensor temperature range 0 °C - 105 °C
tm-max 105 °C
tm-min(*) 35 °C (2-sensor system)
Algorithm 2 2-sensor measuring system 999 values (basis: K-level 60)

Seems that we should find the Current consumption value + 2 temperatures.

One of the temperature should be around 20-ish degree C (room temp).

Searching around seems that the values from the sensor should be adjusted with some "magic" factor from the producer (this take in account the temperature gradient between the sensor and the heater), that obviously behind a customer login for Qundis.
This is German, the English version is not working > Kc-Werte-Datenbank für QUNDIS-Heizkostenverteiler erweitert - QUNDIS

How did you find out the Manufacturer ID ? I was searching for the data but I found nothing!

I extracted only some the telegrams for the sensor ID I found above:

C1;1;1;2019-02-20 10:31:20.000;139;135;94740258;0x49449344580274943508780dff5f3500827300000f0007b06effff270100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d200b7422
C1;1;1;2019-02-20 10:31:36.000;171;128;94740258;0x314493445802749435087a740000200b6e2701004b6e450100426c5f2ccb086e790000c2086c7f21326cffff046d200b7422
C1;1;1;2019-02-20 10:34:56.000;128;127;94740258;0x49449344580274943508780dff5f350082740000ee0007b06effff270100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d240b7422
C1;1;1;2019-02-20 10:38:37.000;147;151;94740258;0x49449344580274943508780dff5f350082740000110007b06effff270100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d280b7422
C1;1;1;2019-02-20 10:38:55.000;140;145;94740258;0x314493445802749435087a750000200b6e2701004b6e450100426c5f2ccb086e790000c2086c7f21326cffff046d280b7422
C1;1;1;2019-02-20 10:40:23.000;130;134;94740258;0x49449344580274943508780dff5f3500827500005e0107b06effff270100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d290b7422
C1;1;1;2019-02-20 10:44:03.000;136;140;94740258;0x49449344580274943508780dff5f350082750000810007b06effff270100005f2c450100007f2179000000008000800080008000000000000000000c002e005700beff2f046d2d0b7422

@weetmuts
Copy link
Member

Thanks Kidpixo! I got myself a rtl-sdr dongle and I can listen to FM radio using gqrx. But I have trouble receiving wmbus messages. Do I need to do something special or have a special antenna for it to work?

@weetmuts
Copy link
Member

weetmuts commented Feb 22, 2019

How did you find out the Manufacturer ID ? I was searching for the data but I found nothing!

The decode of the telegram reported the QDS as the triplet that identifies the manufacturer, this was not in my list, but simply googling for heat cost allocators and qds will give you Qundis, which clearly is the only manufacturer that would choose the abbreviation QDS. :-)

@kidpixo
Copy link
Author

kidpixo commented Feb 22, 2019

Thanks Kidpixo! I got myself a rtl-sdr dongle and I can listen to FM radio using gqrx. But I have trouble receiving wmbus messages. Do I need to do something special or have a special antenna for it to work?

Uhm I did nothing special: on a Mac, just plugged in and rtl_sdr or rtl_test could use it.
For wmbus I just use the command above rtl_sdr -f 868.9M -s 1600000 - 2>/dev/null | rtl_wmbus.

The same cheap antenna I got with the stick is working fine, I receive also a loto of AMR readings via https://github.com/bemasher/rtlamr
I cannot test wmbusmeters because mac don't expose it as device under /dev/ and standard docker cannot handle devices.
I'm using docker for wmbusmeters and pass the data from mac rtl_sdr in the container.

@kidpixo
Copy link
Author

kidpixo commented Feb 22, 2019

How did you find out the Manufacturer ID ? I was searching for the data but I found nothing!

The decode of the telegram reported the QDS as the triplet that identifies the manufacturer, this was not in my list, but simply googling for heat cost allocators and qds will give you Qundis, which clearly is the only manufacturer that would choose the abbreviation QDS. :-)

Clever :-D 👍

@kidpixo
Copy link
Author

kidpixo commented Feb 22, 2019

About my data, I do think they are encoded, and I have a crazy idea about the encryption.

Above I posted the photo of one sensor and the ID printed on the cover is 94740407.
I was curious about the bar code and scan it gives me 0947404077 ( or 0[SensorID]7 ).
The same happens for all other 6 sensor in my flat.
Reading documentation on WMbus, I read that Manufacturer (4 Hex)+Sensor ID (8Hex)+Version (2Hex) is an unambiguous address for a particular sensor.
Those are all data anyone can read from the data packet on air, BUT those 2 character extra in the bar code are available only to people with physical access to the device: the technician that install them.

Would make sense that each device use a different encryption key?
Something like a combination of [Manufacturer (4 Hex), Barcode Sensor ID (10Hex) , Version (2Hex) ] = 16 Hex ?

I figure something like this : the technician install the device, scan the code and add is to the client pool with a dedicated encryption key unique to the device.

Maybe I'm just in a scifi movie and the real key is 0000000000000000 ...

@weetmuts
Copy link
Member

It now compiles under MacOSX 10.14.3 with a recent XCode. (clang-1000.10.44.4)
But I have compiled on a virtual mac, so I have no access to the physical usb ports.
Can you try if it works?

@kidpixo
Copy link
Author

kidpixo commented Feb 23, 2019

EDIT : the debug mode works, but the USB is not detected.

@kidpixo
Copy link
Author

kidpixo commented Feb 23, 2019

Another thing I notice:
$ ./build_debug/wmbusmeters --c1 --debug simulation_kidpixo.txt HeatMe qcaloric 94740459 ""
is fine , but

$ ./wmbusmeters --c1 --debug ../simulation_kidpixo.txt HeatMe qcaloric 94740459 ""
(cmdline) using usb device: ../simulation_kidpixo.txt
(cmdline) number of meters: 1
Device ../simulation_kidpixo.txt is not a character device.

That comes from this check if (!S_ISCHR(info.st_mode)) in util.cc .

Shouldn't it work anyway?

@kidpixo
Copy link
Author

kidpixo commented Feb 23, 2019

A last question, do you think the messages are encrypted now? Or you think it is possible to decode them?

@weetmuts
Copy link
Member

Just committed a fix, so that the file simulation_yyy.txt can be located in some other directory than cwd.
Please test.

I have not yet had time to examine the messages. But I still do not believe that they are encrypted per se. But lets see! :-)

@weetmuts
Copy link
Member

Now there is support for receiving data from rtlwmbus. Try this command line,
and make sure rtl_srd and rtl_wmbus is in /usr/bin
wmbusmeters --debug rtlwmbus Heater qcaloric 94740459 ""
rtlwmbus defaults to "/usr/bin/rtl_sdr -f 868.9M -s 16000000 | /usr/bin/rtl_wmbus"
If you want a different command, do:
wmbusmeters --debug 'rtlwmbus:rtl_sdr f 12345 | rtl_wmbus' Heater qcaloric 94740459 ""

Please test! It should work for you on macosx.

@kidpixo
Copy link
Author

kidpixo commented Feb 26, 2019

Thanks! You're surely really active!
I'll test it later this week, I have a huge pile of crumbling work to deal with.

I think this latest push could be useful to a lot of users.

Now there is support for receiving data from rtlwmbus. Try this command line,
and make sure rtl_srd and rtl_wmbus is in /usr/bin
wmbusmeters --debug rtlwmbus Heater qcaloric 94740459 ""
rtlwmbus defaults to "/usr/bin/rtl_sdr -f 868.9M -s 16000000 | /usr/bin/rtl_wmbus"
If you want a different command, do:
wmbusmeters --debug 'rtlwmbus:rtl_sdr f 12345 | rtl_wmbus' Heater qcaloric 94740459 ""

I have some problem with installing stuff system wide (laptop provided from my work, nice IT , the usual) and normally symlink the self-compiled stuff in ~/.local/bin/ or I just leave them where they are built.

Would be a huge deal to :

  • accept the executable path (I look in your implementation, seems impractical) OR
  • call trl_sdr/rtl_wmbus without complete path, praying the Old Ones that they are in user's PATH OR
  • pipe from stdin ?

@weetmuts
Copy link
Member

Ok, I made the following changes and pushed the code to github.

wmbusmeters rtlwmbus Heater qcaloric 12345678 ""
will use no prefix for rtl_sdr and rtl_wmbus.
but using config files in daemon mode will prefix with /usr/bin/
it will also default to 868.95M for the frequency.

You can also specify
wmbusmeters rtlwmbus:868.9M Heater qcaloric 12345678 ""
and it will use this slightly off frequency instead.

Or you can specify the entire command line:
wmbusmeters 'rtlwmbus:/bar/rtl_sdr -special | /foo/rtl_wmbus -specials' Heater qcaloric 12345678 ""

Add --verbose to see the command line it uses.

@pulsejets
Copy link

Hi Fredrik

Would wmbusmeters rtlwmbus work with Kampstup watermeter ?

/Kenneth

@weetmuts
Copy link
Member

Yes, I am assuming and hoping it should work with with Kamstrup watermeters.

But I have not yet got my rtl-sdr.com dongle to work with my multical21, but it could be a faulty antenna connecter. I have ordered another dvb-t dongle, compatible with rtl_sdr, to see if I can get that working.
I'll let you know when/if I succeed.

@pulsejets
Copy link

Hi
I have a rtl-sdr (working) , so if you want me to test please say so!!

so rtlwmbus instead of usbdevice ?

@weetmuts
Copy link
Member

Cool! Yes, please test!

You build https://github.com/xaelsouth/rtl-wmbus and put the rtl_wmbus binary in your path.
(/usr/bin if you intend to run wmbusmeters as a daemon).

If you have such a water meter nearby, you can listen to it without having the key, simply
by running: "wmbusmeters rtlwmbus" or "wmbusmeters rtlwmbus:868.9M" if you need to
adjust the freq depending on your dongle.

You will get output like:

No meters configured. Printing id:s of all telegrams heard!

Received telegram from: 12345678
manufacturer: (KAM) Kamstrup Energie A/S
device type: Cold water meter
Received telegram from: 12345678
manufacturer: (KAM) Kamstrup Energie A/S
device type: Cold water meter

@pulsejets
Copy link

Hi
I have the key for my own meter, so

wmbusmeters --c1 rtlwmbus Watermeter multical21 57722892 1B83B875A45F97A35XXXXXXXXXXXXX

?

@weetmuts
Copy link
Member

Yep. You do not need --c1 when you know the meter. Also rtlwmbus can listen to both C1 and T1 traffic at the same time.

@weetmuts
Copy link
Member

Aha! @kidpixo your heat cost allocator sends two kinds of wmbus messages interleaved.
One is a couple of proprietary bytes, not yet understood.
But the other is plain wmbus data.

So I just pushed code to github that makes it possible for you to do:
./build/wmbusmeters simulations/simulation_kidpixo.txt MyElement qcaloric 78563412 ""
MyElement 78563412 127.000 hca 2019-02-28 19:39.27

./build/wmbusmeters --format=json simulations/simulation_kidpixo.txt MyElement qcaloric 78563412 ""
{"media":"heat_cost_allocation","meter":"qcaloric","name":"MyElement","id":"78563412","current_consumption_hca":127.000000,"timestamp":"2019-02-28T18:41:36Z"}

I invented the unit hca, since I do not know what heat cost allocation is actually reported as.
In fact, other wmbus implementations list it as "Units for H.C.A." so there.... :-)

If you run with --debug you see those telegrams decoded as:
(qcaloric) 0f: 0B dif (6 digit BCD Instantaneous value)
(qcaloric) 10: 6E vif (Units for H.C.A.)
(qcaloric) 11: 270100 current consumption (127.000000 hca)
(qcaloric) 14: 4B dif (6 digit BCD Instantaneous value storagenr=1)
(qcaloric) 15: 6E vif (Units for H.C.A.)
(qcaloric) 16: 450100
(qcaloric) 19: 42 dif (16 Bit Integer/Binary Instantaneous value storagenr=1)
(qcaloric) 1a: 6C vif (Date type G)
(qcaloric) 1b: 5F2C
(qcaloric) 1d: CB dif (6 digit BCD Instantaneous value storagenr=1)
(qcaloric) 1e: 08 dife (subunit=0 tariff=0 storagenr=17)
(qcaloric) 1f: 6E vif (Units for H.C.A.)
(qcaloric) 20: 790000
(qcaloric) 23: C2 dif (16 Bit Integer/Binary Instantaneous value storagenr=1)
(qcaloric) 24: 08 dife (subunit=0 tariff=0 storagenr=17)
(qcaloric) 25: 6C vif (Date type G)
(qcaloric) 26: 7F21
(qcaloric) 28: 32 dif (16 Bit Integer/Binary Value during error state)
(qcaloric) 29: 6C vif (Date type G)
(qcaloric) 2a: FFFF
(qcaloric) 2c: 04 dif (32 Bit Integer/Binary Instantaneous value)
(qcaloric) 2d: 6D vif (Date and time type)
(qcaloric) 2e: 200B7422

I'll try to fix the date time extraction code. Please check if you
are intersted in any of the other values reported.

@weetmuts weetmuts changed the title Compile under MacOSX Compile under MacOSX (and support for Qundis Q Caloric Heat Cost Allocator) Feb 28, 2019
@weetmuts
Copy link
Member

So in the above telegram we got:
127 hca (currently shown by wmbusmeters as current consumption)
145 hca
17 hca
79 hca
(but what are the others...)

@kidpixo
Copy link
Author

kidpixo commented Mar 1, 2019

Thank you so much @weetmuts !
I let it running last night and it got the right reading in hca units from the Allocator : 145 Whatever, it is going up!
:-)

I'm less and less happy with non-standard standard and industry not making open their stuff based on open standard/projects....

I would really like to crack open those telegrams, thank a lot for your work!

I remember that project like FHEM should already have some wmbus device integrated, maybe QDS is somewhere...

I found some reference to QDS heat allocator in :

  1. TR-03109-1_Anlage_Feinspezifikation_Drahtlose_LMN-Schnittstelle.pdf
  2. WHE542-D291S – Heat Cost Allocation with W.M-Bus communication – Equobox

No. 1. has a whole telegram from QDS decoded, but it is encrypted...

From 1. the telegram should contain:

  • current cunsumption value 1234 HCA units
  • set date 30.04.2007
  • consumption at set date 23456 HCA units
  • current temperature at sensor 25 °C
  • another temperature ? My allocator (see above) are using Algorithm 2:2-sensor measuring system.

Cheers

@weetmuts
Copy link
Member

weetmuts commented Mar 1, 2019

Cool does this mean that you have succesfully run wmbusmeters on MacOSX using rtl_wmbus?

Thanks for the links to the docs. It seems like your meter outputs exactly the data in your second link.
I have now written code to extract all the data that was found in your telegrams, and pushed it to github. The json output looks like this (and is identical to the Equobox doc).

{"media":"heat_cost_allocation","meter":"qcaloric","name":"Element","id":"94740258","current_consumption_hca":127.000000,"set_date":"2018-12-31","consumption_at_set_date_hca":145.000000,"set_date_17":"2019-01-31","consumption_at_set_date_17_hca":79.000000,"error_date":"2127-15-31","device_date_time":"2019-02-20 11:45","timestamp":"2019-03-01T14:41:59Z"}

And then, there is the raw vendor specific string, but it is only shown in the debug output for the moment. But if you run with --debug and grep "vendor extension data", then you will see those.
However, if all the data you need is in the data above, I do not think we need to reverse engineer that stuff.

@kidpixo
Copy link
Author

kidpixo commented Mar 2, 2019

Yes, I did it! Thanks a lot! Here an example of visualisation with python+pandas

screen shot 2019-03-02 at 20 49 51

I feel we over used this github issue, this thread should have been cut in 2-3 different issues. If you want, I can cut this answer and start a new issue.

For the data itself, I would like to see if I can decode the private packets, I'll search around. Thanks a lot!!

My latest question is, now that I have a working chain to get the radio signal (rtl_sdr) > extract wmbus packet (rtl-wmbus) > decode my HCA sensors (wmbusmeters) :
is there a way to tell wmbusmeters to decode all sensors? something like specify * as sensor ID?

I would like to run a single instance of wmbusmeters to get all my sensor , normally I use a grep regex in the rtl_sdr | rtl-wmbus | grep 'IDS' chain.

@xaelsouth
Copy link
Contributor

Hi weetmuts and kidpixo,

really nice work that you both are doing here. :)

weetmuts, i have found your project more than a year ago, just after rtl-wmbus was on github, but have not had enough elan to participate in wmbusmeters.

Anyway, some of wireless MBus devices are reverse engineered by FHEM people. These devices use proprietary but unencrypted dataformat. Last time more and more manufacturers shift to Open Metering (OMS) and using encrypted datagrams only.

https://github.com/mhop/fhem-mirror/tree/master/fhem/FHEM

Another interesting link for you is (probably) https://github.com/rscada/libmbus , see for wired M-Bus datagram examples. You can test your own software by converting these into wireless M-Bus datagrams: first cut the M-Bus trailer and replace the M-Bus header with the wireless one.

Just in case, you will find windows port of libmbus https://github.com/xaelsouth/libmbus-winport

Xael

@weetmuts
Copy link
Member

weetmuts commented Mar 3, 2019

Thanks @xaelsouth!

@kidpixo yep, I think we can safely close this issue and open up new ones. :-) Please do so!

@kidpixo
Copy link
Author

kidpixo commented Mar 3, 2019

Hi @xaelsouth , thanks but I did absolutely nothing, apart more workload for @weetmuts :-D

I'm aware of FHEM, but personally using HomeAssistant, that's why I was searching for a more modular *NIX style solution : testing my sensors and maybe integrate in hass.

They use a docker container instead of a plugin architecture, I find it really nice.

Thanks for the link!

@weetmuts doing it!

@kidpixo kidpixo closed this as completed Mar 3, 2019
dwrobel added a commit to dwrobel/wmbusmeters that referenced this issue Mar 2, 2020
Fixes the following crash:
 (gdb) bt
 #0  0x00005555555738d0 in abort@plt ()
  wmbusmeters#1  0x0000555555589888 in std::__replacement_assert (__file=<optimized out>, __line=<optimized out>, __function=<optimized out>, __condition=<optimized out>) at /usr/include/c++/9/x86_64-redhat-linux/bits/c++config.h:2533
 wmbusmeters#2  0x00005555555d1e37 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::front (this=0x7ffff7a226d0) at /usr/include/c++/9/bits/basic_string.h:1123
 wmbusmeters#3  0x00005555555ce8c5 in doesIdMatchExpression (id=..., match=...) at src/util.cc:513
 wmbusmeters#4  0x00005555555cea92 in doesIdMatchExpressions (id=..., mes=...) at src/util.cc:560
 wmbusmeters#5  0x000055555558aa56 in MeterCommonImplementation::isTelegramForMe (this=0x555555661c28, t=0x7ffff7a227b0) at src/meters.cc:188
 wmbusmeters#6  0x000055555558c0e0 in MeterCommonImplementation::handleTelegram (this=0x555555661c28, input_frame=...) at src/meters.cc:289
 wmbusmeters#7  0x000055555558c87a in MeterCommonImplementation::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)>::operator() (__closure=<optimized out>, input_frame=...) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#8  std::_Function_handler<bool(std::vector<unsigned char, std::allocator<unsigned char> >), MeterCommonImplementation::MeterCommonImplementation(WMBus*, MeterInfo&, MeterType, int)::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)> >::_M_invoke(const std::_Any_data &, std::vector<unsigned char, std::allocator<unsigned char> > &&) (__functor=..., __args#0=...) at /usr/include/c++/9/bits/std_function.h:285
 wmbusmeters#9  0x00005555555da01f in std::function<bool (std::vector<unsigned char, std::allocator<unsigned char> >)>::operator()(std::vector<unsigned char, std::allocator<unsigned char> >) const (__args#0=..., this=0x7ffff7a22c70) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#10 WMBusCommonImplementation::handleTelegram (this=this@entry=0x555555661b40, frame=...) at src/wmbus.cc:3328
 wmbusmeters#11 0x00005555555fbf7b in WMBusRTLWMBUS::processSerialData (this=0x555555661ad0) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#12 0x00005555555cb001 in std::function<void ()>::operator()() const (this=<optimized out>) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#13 SerialCommunicationManagerImp::eventLoop (this=0x5555556617c0) at src/serial.cc:795
 wmbusmeters#14 0x00007ffff7f554e2 in ?? ()
 wmbusmeters#15 0x0000000000000000 in ?? ()

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
dwrobel added a commit to dwrobel/wmbusmeters that referenced this issue Mar 2, 2020
Fixes the following crash:
 (gdb) bt
 #0  0x00005555555738d0 in abort@plt ()
  wmbusmeters#1  0x0000555555589888 in std::__replacement_assert (__file=<optimized out>, __line=<optimized out>, __function=<optimized out>, __condition=<optimized out>) at /usr/include/c++/9/x86_64-redhat-linux/bits/c++config.h:2533
 wmbusmeters#2  0x00005555555d1e37 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::front (this=0x7ffff7a226d0) at /usr/include/c++/9/bits/basic_string.h:1123
 wmbusmeters#3  0x00005555555ce8c5 in doesIdMatchExpression (id=..., match=...) at src/util.cc:513
 wmbusmeters#4  0x00005555555cea92 in doesIdMatchExpressions (id=..., mes=...) at src/util.cc:560
 wmbusmeters#5  0x000055555558aa56 in MeterCommonImplementation::isTelegramForMe (this=0x555555661c28, t=0x7ffff7a227b0) at src/meters.cc:188
 wmbusmeters#6  0x000055555558c0e0 in MeterCommonImplementation::handleTelegram (this=0x555555661c28, input_frame=...) at src/meters.cc:289
 wmbusmeters#7  0x000055555558c87a in MeterCommonImplementation::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)>::operator() (__closure=<optimized out>, input_frame=...) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#8  std::_Function_handler<bool(std::vector<unsigned char, std::allocator<unsigned char> >), MeterCommonImplementation::MeterCommonImplementation(WMBus*, MeterInfo&, MeterType, int)::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)> >::_M_invoke(const std::_Any_data &, std::vector<unsigned char, std::allocator<unsigned char> > &&) (__functor=..., __args#0=...) at /usr/include/c++/9/bits/std_function.h:285
 wmbusmeters#9  0x00005555555da01f in std::function<bool (std::vector<unsigned char, std::allocator<unsigned char> >)>::operator()(std::vector<unsigned char, std::allocator<unsigned char> >) const (__args#0=..., this=0x7ffff7a22c70) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#10 WMBusCommonImplementation::handleTelegram (this=this@entry=0x555555661b40, frame=...) at src/wmbus.cc:3328
 wmbusmeters#11 0x00005555555fbf7b in WMBusRTLWMBUS::processSerialData (this=0x555555661ad0) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#12 0x00005555555cb001 in std::function<void ()>::operator()() const (this=<optimized out>) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#13 SerialCommunicationManagerImp::eventLoop (this=0x5555556617c0) at src/serial.cc:795
 wmbusmeters#14 0x00007ffff7f554e2 in ?? ()
 wmbusmeters#15 0x0000000000000000 in ?? ()

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
dwrobel added a commit to dwrobel/wmbusmeters that referenced this issue Mar 2, 2020
Fixes the following crash:
 (gdb) bt
 #0  0x00005555555738d0 in abort@plt ()
  wmbusmeters#1  0x0000555555589888 in std::__replacement_assert (__file=<optimized out>, __line=<optimized out>, __function=<optimized out>, __condition=<optimized out>) at /usr/include/c++/9/x86_64-redhat-linux/bits/c++config.h:2533
 wmbusmeters#2  0x00005555555d1e37 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::front (this=0x7ffff7a226d0) at /usr/include/c++/9/bits/basic_string.h:1123
 wmbusmeters#3  0x00005555555ce8c5 in doesIdMatchExpression (id=..., match=...) at src/util.cc:513
 wmbusmeters#4  0x00005555555cea92 in doesIdMatchExpressions (id=..., mes=...) at src/util.cc:560
 wmbusmeters#5  0x000055555558aa56 in MeterCommonImplementation::isTelegramForMe (this=0x555555661c28, t=0x7ffff7a227b0) at src/meters.cc:188
 wmbusmeters#6  0x000055555558c0e0 in MeterCommonImplementation::handleTelegram (this=0x555555661c28, input_frame=...) at src/meters.cc:289
 wmbusmeters#7  0x000055555558c87a in MeterCommonImplementation::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)>::operator() (__closure=<optimized out>, input_frame=...) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#8  std::_Function_handler<bool(std::vector<unsigned char, std::allocator<unsigned char> >), MeterCommonImplementation::MeterCommonImplementation(WMBus*, MeterInfo&, MeterType, int)::<lambda(std::vector<unsigned char, std::allocator<unsigned char> >)> >::_M_invoke(const std::_Any_data &, std::vector<unsigned char, std::allocator<unsigned char> > &&) (__functor=..., __args#0=...) at /usr/include/c++/9/bits/std_function.h:285
 wmbusmeters#9  0x00005555555da01f in std::function<bool (std::vector<unsigned char, std::allocator<unsigned char> >)>::operator()(std::vector<unsigned char, std::allocator<unsigned char> >) const (__args#0=..., this=0x7ffff7a22c70) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#10 WMBusCommonImplementation::handleTelegram (this=this@entry=0x555555661b40, frame=...) at src/wmbus.cc:3328
 wmbusmeters#11 0x00005555555fbf7b in WMBusRTLWMBUS::processSerialData (this=0x555555661ad0) at /usr/include/c++/9/bits/stl_algobase.h:465
 wmbusmeters#12 0x00005555555cb001 in std::function<void ()>::operator()() const (this=<optimized out>) at /usr/include/c++/9/bits/std_function.h:685
 wmbusmeters#13 SerialCommunicationManagerImp::eventLoop (this=0x5555556617c0) at src/serial.cc:795
 wmbusmeters#14 0x00007ffff7f554e2 in ?? ()
 wmbusmeters#15 0x0000000000000000 in ?? ()

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
dwrobel added a commit to dwrobel/wmbusmeters that referenced this issue Oct 31, 2020
Fixes the following crash:

 Thread 1 "wmbusmeters" received signal SIGABRT, Aborted.
 [Switching to Thread 0x7ffff7a16e00 (LWP 33345)]
 0x00007ffff7a9d9e5 in raise () from /lib64/libc.so.6
 (gdb) bt
 #0  0x00007ffff7a9d9e5 in raise () from /lib64/libc.so.6
 wmbusmeters#1  0x00007ffff7a86895 in abort () from /lib64/libc.so.6
 wmbusmeters#2  0x00005555555962cc in std::__replacement_assert (__file=0x5555556af910 "/usr/include/c++/10/bits/stl_vector.h", __line=1045,
     __function=0x5555556af7f0 "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = unsigned char; _Alloc = std::allocator<unsigned char>; std::vector<_Tp, _Alloc"...,
     __condition=0x5555556af7c0 "__builtin_expect(__n < this->size(), true)") at /usr/include/c++/10/x86_64-redhat-linux/bits/c++config.h:2560
 wmbusmeters#3  0x000055555559dbe5 in std::vector<unsigned char, std::allocator<unsigned char> >::operator[] (this=0x7fffffffd9e0, __n=0) at /usr/include/c++/10/bits/stl_vector.h:1045
 wmbusmeters#4  0x000055555569191f in detectRC1180 (detected=0x7fffffffdba0, manager=std::shared_ptr<SerialCommunicationManager> (use count 3, weak count 0) = {...}) at src/wmbus_rc1180.cc:344
 wmbusmeters#5  0x0000555555674e7c in detectWMBusDeviceOnTTY (tty="/dev/ttyS0", handler=std::shared_ptr<SerialCommunicationManager> (use count 3, weak count 0) = {...}) at src/wmbus.cc:4201
 wmbusmeters#6  0x00005555556a1d3c in perform_auto_scan_of_serial_devices (config=0x555555769790) at src/main.cc:870
 wmbusmeters#7  0x00005555556a1b11 in perform_auto_scan_of_devices (config=0x555555769790) at src/main.cc:845
 wmbusmeters#8  0x00005555556997d3 in detect_and_configure_wmbus_devices (config=0x555555769790) at src/main.cc:557
 wmbusmeters#9  0x00005555556a322a in start (config=0x555555769790) at src/main.cc:1104
 wmbusmeters#10 0x0000555555694796 in main (argc=3, argv=0x7fffffffe228) at src/main.cc:192
 (gdb) fr 4
 wmbusmeters#4  0x000055555569191f in detectRC1180 (detected=0x7fffffffdba0, manager=std::shared_ptr<SerialCommunicationManager> (use count 3, weak count 0) = {...}) at src/wmbus_rc1180.cc:344
 344	    if (data[0] != '>')
 (gdb) p data
 $1 = std::vector of length 0, capacity 1024

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants