From 4a1eebd1bcc9818227140e8d2139323834635fd6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Thu, 22 Feb 2018 10:19:16 +0100 Subject: [PATCH 001/238] replay all changees (JSon functions and 0.9.0) from samkrew/libmbus to current libmbus --- build.sh | 3 +- configure.ac | 14 +- mbus/mbus-protocol.c | 513 +++++++++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol.h | 16 +- 4 files changed, 537 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 34c2799b..40874a5c 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,8 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure + && ./configure \ + && autoreconf fi make diff --git a/configure.ac b/configure.ac index fd8497cc..37968448 100644 --- a/configure.ac +++ b/configure.ac @@ -2,26 +2,26 @@ dnl ---------------------------------------------------------------------------- dnl Copyright (C) 2010, Raditex AB dnl All rights reserved. dnl -dnl rSCADA +dnl rSCADA dnl http://www.rSCADA.se dnl info@rscada.se -dnl +dnl dnl ---------------------------------------------------------------------------- LT_CONFIG_LTDL_DIR([libltdl]) -AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) -AM_PROG_LIBTOOL # fix for automake 1.11 & 1.12 -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +AM_PROG_LIBTOOL -LDFLAGS="$LDFLAGS -version-info 0:8:0" +LDFLAGS="$LDFLAGS -version-info 0:9:0" dnl ---------------------- -dnl +dnl AC_PROG_CC AC_CONFIG_HEADERS([config.h]) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 03bd5d2b..35789223 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3767,6 +3767,519 @@ mbus_data_error_print(int error) return -1; } +//------------------------------------------------------------------------------ +// +// JSON RELATED FUNCTIONS +// +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// +/// Encode string to JSON +/// +//------------------------------------------------------------------------------ +int +mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len) +{ + size_t i, len; + + i = 0; + len = 0; + + if (dst == NULL) + { + return -1; + } + + if (src == NULL) + { + dst[len] = '\0'; + return -2; + } + + while((len+6) < max_len) + { + if (src[i] == '\0') + { + break; + } + + if (iscntrl(src[i])) + { + // convert all control chars into spaces + dst[len++] = ' '; + } + else + { + switch (src[i]) + { + case '"': + len += snprintf(&dst[len], max_len - len, "\\\""); + break; + default: + dst[len++] = src[i]; + break; + } + } + + i++; + } + + dst[len] = '\0'; + return 0; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for the variable-length data header +//------------------------------------------------------------------------------ +char * +mbus_data_variable_header_json(mbus_data_variable_header *header) +{ + static char buff[8192]; + char str_encoded[768]; + size_t len = 0; + int val; + + if (header) + { + len += snprintf(&buff[len], sizeof(buff) - len, "\"SlaveInformation\":{"); + + val = (int)mbus_data_bcd_decode(header->id_bcd, 4); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"Id\":%d,", val); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Manufacturer\":\"%s\",", + mbus_decode_manufacturer(header->manufacturer[0], header->manufacturer[1])); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Version\":%d,", header->version); + + mbus_str_json_encode(str_encoded, mbus_data_product_name(header), sizeof(str_encoded)); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"ProductName\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_variable_medium_lookup(header->medium), sizeof(str_encoded)); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"Medium\":\"%s\",", str_encoded); + len += snprintf(&buff[len], sizeof(buff) - len, "\"AccessNumber\":%d,", header->access_no); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Status\":\"%.2X\",", header->status); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Signature\":\"%.2X%.2X\"", header->signature[1], header->signature[0]); + + len += snprintf(&buff[len], sizeof(buff) - len, "}"); + + return buff; + } + + return ""; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for a single variable-length data record +//------------------------------------------------------------------------------ +char * +mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int frame_cnt, mbus_data_variable_header *header) +{ + static char buff[8192]; + char str_encoded[768]; + size_t len = 0; + struct tm * timeinfo; + char timestamp[21]; + long tariff; + + if (record) + { + if (frame_cnt >= 0) + { + len += snprintf(&buff[len], sizeof(buff) - len, + "{\"id\":%d,\"frame\":%d,", + record_cnt, frame_cnt); + } + else + { + len += snprintf(&buff[len], sizeof(buff) - len, + "{\"id\":%d,", record_cnt); + } + + if (record->drh.dib.dif == MBUS_DIB_DIF_MANUFACTURER_SPECIFIC) // MBUS_DIB_DIF_VENDOR_SPECIFIC + { + len += snprintf(&buff[len], sizeof(buff) - len, + " \"Function\":\"Manufacturer specific\","); + } + else if (record->drh.dib.dif == MBUS_DIB_DIF_MORE_RECORDS_FOLLOW) + { + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Function\"\"More records follow\","); + } + else + { + mbus_str_json_encode(str_encoded, mbus_data_record_function(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Function\":\"%s\",", str_encoded); + + len += snprintf(&buff[len], sizeof(buff) - len, + "\"StorageNumber\":%ld,", + mbus_data_record_storage_number(record)); + + if ((tariff = mbus_data_record_tariff(record)) >= 0) + { + len += snprintf(&buff[len], sizeof(buff) - len, "\"Tariff\":%ld,", + tariff); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Device\":%d,", + mbus_data_record_device(record)); + } + + mbus_str_json_encode(str_encoded, mbus_data_record_unit(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Unit\":\"%s\",", str_encoded); + } + + mbus_str_json_encode(str_encoded, mbus_data_record_value(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Value\":\"%s\",", str_encoded); + + if (record->timestamp > 0) + { + timeinfo = gmtime (&(record->timestamp)); + strftime(timestamp,20,"%Y-%m-%dT%H:%M:%SZ",timeinfo); + // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Timestamp\":\"%s\"", timestamp); + } + + len += snprintf(&buff[len], sizeof(buff) - len, "},"); + + return buff; + } + + return ""; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for variable-length data +//------------------------------------------------------------------------------ +char * +mbus_data_variable_json(mbus_data_variable *data) +{ + mbus_data_record *record; + char *buff = NULL, *new_buff; + size_t len = 0, buff_size = 8192; + int i; + + if (data) + { + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "%s,", + mbus_data_variable_header_json(&(data->header))); + + len += snprintf(&buff[len], buff_size - len, "%s","\"DataRecords\":["); + + for (record = data->record, i = 0; record; record = record->next, i++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, i, -1, &(data->header))); + } + len += snprintf(&buff[len-1], buff_size - len + 1, "]}}"); + + return buff; + } + + return NULL; +} + +//------------------------------------------------------------------------------ +/// Generate JSON representation of fixed-length frame. +//------------------------------------------------------------------------------ +char * +mbus_data_fixed_json(mbus_data_fixed *data) +{ + char *buff = NULL; + char str_encoded[256]; + size_t len = 0, buff_size = 8192; + int val; + + if (data) + { + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); + len += snprintf(&buff[len], buff_size - len, "\"Id\":%d,", (int)mbus_data_bcd_decode(data->id_bcd, 4)); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_medium(data), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Medium\":\"%s\",", str_encoded); + + len += snprintf(&buff[len], buff_size - len, "\"AccessNumber\":%d,", data->tx_cnt); + len += snprintf(&buff[len], buff_size - len, "\"Status\":\"%.2X\"", data->status); + len += snprintf(&buff[len], buff_size - len, "},"); + + len += snprintf(&buff[len], buff_size - len, "\"DataRecord\":[{"); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt1_type), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); + if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) + { + val = mbus_data_bcd_decode(data->cnt1_val, 4); + } + else + { + mbus_data_int_decode(data->cnt1_val, 4, &val); + } + len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); + + len += snprintf(&buff[len], buff_size - len, "},{"); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt2_type), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); + if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) + { + val = mbus_data_bcd_decode(data->cnt2_val, 4); + } + else + { + mbus_data_int_decode(data->cnt2_val, 4, &val); + } + len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); + + len += snprintf(&buff[len], buff_size - len, "}]"); + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; + } + + return NULL; +} + +//------------------------------------------------------------------------------ +/// Generate JSON representation of a general application error. +//------------------------------------------------------------------------------ +char * +mbus_data_error_json(int error) +{ + char *buff = NULL; + char str_encoded[256]; + size_t len = 0, buff_size = 8192; + + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); + + mbus_str_json_encode(str_encoded, mbus_data_error_lookup(error), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Error\"\"%s\"", str_encoded); + + len += snprintf(&buff[len], buff_size - len, "}"); + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; +} + +//------------------------------------------------------------------------------ +/// Return a string containing an JSON representation of the M-BUS frame data. +//------------------------------------------------------------------------------ +char * +mbus_frame_data_json(mbus_frame_data *data) +{ + if (data) + { + if (data->type == MBUS_DATA_TYPE_ERROR) + { + return mbus_data_error_json(data->error); + } + + if (data->type == MBUS_DATA_TYPE_FIXED) + { + return mbus_data_fixed_json(&(data->data_fix)); + } + + if (data->type == MBUS_DATA_TYPE_VARIABLE) + { + return mbus_data_variable_json(&(data->data_var)); + } + } + + return NULL; +} + + +//------------------------------------------------------------------------------ +/// Return an JSON representation of the M-BUS frame. +//------------------------------------------------------------------------------ +char * +mbus_frame_json(mbus_frame *frame) +{ + mbus_frame_data frame_data; + mbus_frame *iter; + + mbus_data_record *record; + char *buff = NULL, *new_buff; + + size_t len = 0, buff_size = 8192; + int record_cnt = 0, frame_cnt; + + if (frame) + { + memset((void *)&frame_data, 0, sizeof(mbus_frame_data)); + + if (mbus_frame_data_parse(frame, &frame_data) == -1) + { + mbus_error_str_set("M-bus data parse error."); + return NULL; + } + + if (frame_data.type == MBUS_DATA_TYPE_ERROR) + { + // + // generate JSON for error + // + return mbus_data_error_json(frame_data.error); + } + + if (frame_data.type == MBUS_DATA_TYPE_FIXED) + { + // + // generate JSON for fixed data + // + return mbus_data_fixed_json(&(frame_data.data_fix)); + } + + if (frame_data.type == MBUS_DATA_TYPE_VARIABLE) + { + // + // generate JSON for a sequence of variable data frames + // + + buff = (char*) malloc(buff_size); + + if (buff == NULL) + { + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + // include frame counter in JSON output if more than one frame + // is available (frame_cnt = -1 => not included in output) + frame_cnt = (frame->next == NULL) ? -1 : 0; + + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + // only print the header info for the first frame (should be + // the same for each frame in a sequence of a multi-telegram + // transfer. + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_header_json(&(frame_data.data_var.header))); + + // loop through all records in the current frame, using a global + // record count as record ID in the JSON output + for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); + } + + // free all records in the list + if (frame_data.data_var.record) + { + mbus_data_record_free(frame_data.data_var.record); + } + + frame_cnt++; + + for (iter = frame->next; iter; iter = iter->next, frame_cnt++) + { + if (mbus_frame_data_parse(iter, &frame_data) == -1) + { + mbus_error_str_set("M-bus variable data parse error."); + return NULL; + } + + // loop through all records in the current frame, using a global + // record count as record ID in the JSON output + for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); + } + + // free all records in the list + if (frame_data.data_var.record) + { + mbus_data_record_free(frame_data.data_var.record); + } + } + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; + } + } + + return NULL; +} + + //------------------------------------------------------------------------------ // // XML RELATED FUNCTIONS diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 60b7424b..3e7d14b8 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,6 +566,21 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); +// +// JSON generating functions +// +int mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len); +char *mbus_data_json(mbus_frame_data *data); +char *mbus_data_variable_json(mbus_data_variable *data); +char *mbus_data_fixed_json(mbus_data_fixed *data); +char *mbus_data_error_json(int error); +char *mbus_frame_data_json(mbus_frame_data *data); + +char *mbus_data_variable_header_json(mbus_data_variable_header *header); + +char *mbus_frame_json(mbus_frame *frame); + + // // XML generating functions // @@ -643,4 +658,3 @@ int mbus_is_secondary_address(const char * value); #endif #endif /* _MBUS_PROTOCOL_H_ */ - From 0cf4843882ff68b0f846087256ae4095886d60c0 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Fri, 23 Feb 2018 09:35:07 +0100 Subject: [PATCH 002/238] make sure mbus-protocol-aux.o --- mbus/Makefile.am | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mbus/Makefile.am b/mbus/Makefile.am index b0749871..261e0c00 100644 --- a/mbus/Makefile.am +++ b/mbus/Makefile.am @@ -2,7 +2,7 @@ # Copyright (C) 2010, Raditex AB # All rights reserved. # -# rSCADA +# rSCADA # http://www.rSCADA.se # info@rscada.se # @@ -10,11 +10,10 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -fPIC includedir = $(prefix)/include/mbus include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h lib_LTLIBRARIES = libmbus.la libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c - From 68dfbbaa4bac17924247b1caf6ba30f29a64586c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:33:10 +0100 Subject: [PATCH 003/238] output config.h --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39fe165c..9fa74e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ os: - linux - osx -script: +script: - ./build.sh + - cat config.h - cd test && make && ./generate-xml.sh test-frames From 588b57f9970d78c5d992a33eabf166ed77bcb6a3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:54:38 +0100 Subject: [PATCH 004/238] Revert "make sure mbus-protocol-aux.o" This reverts commit 0cf4843882ff68b0f846087256ae4095886d60c0. --- mbus/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mbus/Makefile.am b/mbus/Makefile.am index 261e0c00..b0749871 100644 --- a/mbus/Makefile.am +++ b/mbus/Makefile.am @@ -2,7 +2,7 @@ # Copyright (C) 2010, Raditex AB # All rights reserved. # -# rSCADA +# rSCADA # http://www.rSCADA.se # info@rscada.se # @@ -10,10 +10,11 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -fPIC +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) includedir = $(prefix)/include/mbus include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h lib_LTLIBRARIES = libmbus.la libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c + From 38e0a3414db84973816c6b5ea40505842d98263b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:54:43 +0100 Subject: [PATCH 005/238] Revert "output config.h" This reverts commit 68dfbbaa4bac17924247b1caf6ba30f29a64586c. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9fa74e04..39fe165c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ os: - linux - osx -script: +script: - ./build.sh - - cat config.h - cd test && make && ./generate-xml.sh test-frames From 2a69df0bd7918b76cdf6f43963d38353977e6ebc Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 12:56:04 +0100 Subject: [PATCH 006/238] try --- mbus/mbus-serial.c | 11 +++++++++-- mbus/mbus-tcp.c | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index ea4d977b..e8d5a4da 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -8,7 +8,16 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 +#include +#include +#include +#else #include +#include +#endif + + #include #include @@ -17,7 +26,6 @@ #include #include -#include #include #include @@ -374,4 +382,3 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame) return MBUS_RECV_RESULT_OK; } - diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 81043db5..84fdf0c8 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,7 +8,13 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 +#include +#include +#else #include +#endif + #include #include @@ -262,4 +268,3 @@ mbus_tcp_set_timeout_set(double seconds) return 0; } - From e24a9d034bf70325e9592caf6421f2426fc58f23 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 13:21:34 +0100 Subject: [PATCH 007/238] try --- mbus/mbus-protocol-aux.c | 112 ++++++++++++++++++++------------------- mbus/mbus-protocol.c | 5 ++ mbus/mbus-serial.c | 6 ++- mbus/mbus-serial.h | 7 ++- mbus/mbus-tcp.c | 5 ++ 5 files changed, 79 insertions(+), 56 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ed295624..14421427 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -11,6 +11,10 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#endif + #include "mbus-protocol-aux.h" #include "mbus-serial.h" #include "mbus-tcp.h" @@ -154,17 +158,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ - { 0x58, 1.0e-3, "°C", "Flow temperature" }, - { 0x59, 1.0e-2, "°C", "Flow temperature" }, - { 0x5A, 1.0e-1, "°C", "Flow temperature" }, - { 0x5B, 1.0e0, "°C", "Flow temperature" }, + /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ + { 0x58, 1.0e-3, "�C", "Flow temperature" }, + { 0x59, 1.0e-2, "�C", "Flow temperature" }, + { 0x5A, 1.0e-1, "�C", "Flow temperature" }, + { 0x5B, 1.0e0, "�C", "Flow temperature" }, - /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ - { 0x5C, 1.0e-3, "°C", "Return temperature" }, - { 0x5D, 1.0e-2, "°C", "Return temperature" }, - { 0x5E, 1.0e-1, "°C", "Return temperature" }, - { 0x5F, 1.0e0, "°C", "Return temperature" }, + /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ + { 0x5C, 1.0e-3, "�C", "Return temperature" }, + { 0x5D, 1.0e-2, "�C", "Return temperature" }, + { 0x5E, 1.0e-1, "�C", "Return temperature" }, + { 0x5F, 1.0e0, "�C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -172,11 +176,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature °C (0.001°C to 1°C) */ - { 0x64, 1.0e-3, "°C", "External temperature" }, - { 0x65, 1.0e-2, "°C", "External temperature" }, - { 0x66, 1.0e-1, "°C", "External temperature" }, - { 0x67, 1.0e0, "°C", "External temperature" }, + /* E110 01nn External Temperature �C (0.001�C to 1�C) */ + { 0x64, 1.0e-3, "�C", "External temperature" }, + { 0x65, 1.0e-2, "�C", "External temperature" }, + { 0x66, 1.0e-1, "�C", "External temperature" }, + { 0x67, 1.0e0, "�C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -608,29 +612,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x258, 1.0e-3, "°F", "Flow temperature" }, - { 0x259, 1.0e-2, "°F", "Flow temperature" }, - { 0x25A, 1.0e-1, "°F", "Flow temperature" }, - { 0x25B, 1.0e0, "°F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x25C, 1.0e-3, "°F", "Return temperature" }, - { 0x25D, 1.0e-2, "°F", "Return temperature" }, - { 0x25E, 1.0e-1, "°F", "Return temperature" }, - { 0x25F, 1.0e0, "°F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ - { 0x260, 1.0e-3, "°F", "Temperature difference" }, - { 0x261, 1.0e-2, "°F", "Temperature difference" }, - { 0x262, 1.0e-1, "°F", "Temperature difference" }, - { 0x263, 1.0e0, "°F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x264, 1.0e-3, "°F", "External temperature" }, - { 0x265, 1.0e-2, "°F", "External temperature" }, - { 0x266, 1.0e-1, "°F", "External temperature" }, - { 0x267, 1.0e0, "°F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x258, 1.0e-3, "�F", "Flow temperature" }, + { 0x259, 1.0e-2, "�F", "Flow temperature" }, + { 0x25A, 1.0e-1, "�F", "Flow temperature" }, + { 0x25B, 1.0e0, "�F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x25C, 1.0e-3, "�F", "Return temperature" }, + { 0x25D, 1.0e-2, "�F", "Return temperature" }, + { 0x25E, 1.0e-1, "�F", "Return temperature" }, + { 0x25F, 1.0e0, "�F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ + { 0x260, 1.0e-3, "�F", "Temperature difference" }, + { 0x261, 1.0e-2, "�F", "Temperature difference" }, + { 0x262, 1.0e-1, "�F", "Temperature difference" }, + { 0x263, 1.0e0, "�F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x264, 1.0e-3, "�F", "External temperature" }, + { 0x265, 1.0e-2, "�F", "External temperature" }, + { 0x266, 1.0e-1, "�F", "External temperature" }, + { 0x267, 1.0e0, "�F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -642,19 +646,19 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ - { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ + { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ - { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ + { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power § 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, @@ -730,7 +734,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "°C", "Temperature" }, + { 0x38, 1.0e-3, "�C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, @@ -886,7 +890,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 2, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -921,7 +925,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 4, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -1286,7 +1290,7 @@ mbus_parse_variable_record(mbus_data_record *data) MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__); return NULL; } - + record->storage_number = mbus_data_record_storage_number(data); record->tariff = mbus_data_record_tariff(data); record->device = mbus_data_record_device(data); @@ -2304,7 +2308,7 @@ mbus_probe_secondary_address(mbus_handle *handle, const char *mask, char *matchi if (addr == NULL) { // show error message, but procede with scan - MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", + MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", mbus_error_str()); return MBUS_PROBE_NOTHING; } diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 35789223..d9793347 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -8,6 +8,11 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#endif + + #include #include #include diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index e8d5a4da..6baf8b65 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -11,12 +11,16 @@ #ifdef _WIN32 #include #include -#include #else #include #include #endif +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#endif + + #include #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 76445779..8e7c42a4 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -18,7 +18,13 @@ #ifndef MBUS_SERIAL_H #define MBUS_SERIAL_H +#ifdef _WIN32 +#include +#include +#else #include +#endif + #include "mbus-protocol-aux.h" #include "mbus-protocol.h" @@ -45,4 +51,3 @@ void mbus_serial_data_free(mbus_handle *handle); #endif #endif /* MBUS_SERIAL_H */ - diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 84fdf0c8..1e3ba577 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,6 +8,11 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#endif + + #ifdef _WIN32 #include #include From ae95ecfb45f4069dd71340093543df222ff44037 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 13:28:33 +0100 Subject: [PATCH 008/238] # ------------------------ >8 ------------------------ # Do not touch the line above. # Everything below will be removed. # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch build-windows # Your branch is up-to-date with 'origin/build-windows'. # # Changes to be committed: # # modified: mbus/mbus-serial.c # modified: mbus/mbus-tcp.c --- mbus/mbus-serial.c | 4 +++- mbus/mbus-tcp.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 6baf8b65..003ae5a6 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -9,11 +9,14 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 +#include #include #include +#include #else #include #include +#include #endif #ifdef _WIN32 @@ -28,7 +31,6 @@ #include #include -#include #include #include diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 1e3ba577..221ab701 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -16,14 +16,15 @@ #ifdef _WIN32 #include #include +#include #else #include +#include #endif #include #include -#include #include #include From 895c4df2c27a7398a7c1074c82abc085d2e477f4 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 13:29:42 +0100 Subject: [PATCH 009/238] fix --- mbus/mbus-protocol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index d9793347..ea5dcbb8 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -9,7 +9,7 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif From 1847c31048b3fc4d47b7ce231e3db5779ab246d8 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 14:24:55 +0100 Subject: [PATCH 010/238] fix --- mbus/mbus-protocol-aux.c | 2 +- mbus/mbus-protocol-aux.h | 2 +- mbus/mbus-serial.c | 2 +- mbus/mbus-tcp.c | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 14421427..e7fe11cd 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -12,7 +12,7 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif #include "mbus-protocol-aux.h" diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 703bc23c..05d348b2 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 003ae5a6..3952f274 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -20,7 +20,7 @@ #endif #ifdef _WIN32 -#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 221ab701..80703aef 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -9,11 +9,12 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#define __PRETTY_FUNCTION__ = __FUNCSIG__ +#define __PRETTY_FUNCTION__ __FUNCSIG__ #endif #ifdef _WIN32 +#include #include #include #include From 66183d26062ed3ea0c492811e1ad0cbec1c9252e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 15:53:54 +0100 Subject: [PATCH 011/238] add termiWin --- mbus/mbus-serial.c | 1 + mbus/mbus-serial.h | 1 + win/termiWin.c | 536 +++++++++++++++++++++++++++++++++++++++++++++ win/termiWin.h | 183 ++++++++++++++++ 4 files changed, 721 insertions(+) create mode 100644 win/termiWin.c create mode 100644 win/termiWin.h diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 3952f274..52d979d0 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -13,6 +13,7 @@ #include #include #include +#include <../win/termiWin.h> #else #include #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 8e7c42a4..bd249a22 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -21,6 +21,7 @@ #ifdef _WIN32 #include #include +#include <../win/termiWin.h> #else #include #endif diff --git a/win/termiWin.c b/win/termiWin.c new file mode 100644 index 00000000..bf430fc0 --- /dev/null +++ b/win/termiWin.c @@ -0,0 +1,536 @@ +/* termiWin.c +* +* Copyright (C) 2017 Christian Visintin - christian.visintin1997@gmail.com +* +* This file is part of "termiWin: a termios porting for Windows" +* +* termiWin is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* termiWin is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with termiWin. If not, see . +* +*/ + +#include "termiWin.h" +#include +#include + +typedef struct COM +{ + HANDLE hComm; + int fd; //Actually it's completely useless + char* port; +} COM; + +DCB SerialParams = { 0 }; //Initializing DCB structure +struct COM com; +COMMTIMEOUTS timeouts = { 0 }; //Initializing COMMTIMEOUTS structure + +//LOCAL functions + +/*nbyte 0->7*/ +int getByte(tcflag_t flag,int nbyte, int nibble) { + + int byte; + if(nibble == 1) byte = (flag >> (8*(nbyte)) & 0x0f); + else byte = (flag >> (8*(nbyte)) & 0xf0); + return byte; + +} + +//INPUT FUNCTIONS + +int getIXOptions(tcflag_t flag) { + + #define i_IXOFF 0x01 + #define i_IXON 0x02 + #define i_IXOFF_IXON 0x03 + #define i_PARMRK 0x04 + #define i_PARMRK_IXOFF 0x05 + #define i_PARMRK_IXON 0x06 + #define i_PARMRK_IXON_IXOFF 0x07 + + int byte = getByte(flag,4,1); + + return byte; + +} + +//LOCALOPT FUNCTIONS + +int getEchoOptions(tcflag_t flag) { + + #define l_NOECHO 0x00 + #define l_ECHO 0x01 + #define l_ECHO_ECHOE 0x03 + #define l_ECHO_ECHOK 0x05 + #define l_ECHO_ECHONL 0x09 + #define l_ECHO_ECHOE_ECHOK 0x07 + #define l_ECHO_ECHOE_ECHONL 0x0b + #define l_ECHO_ECHOE_ECHOK_ECHONL 0x0f + #define l_ECHO_ECHOK_ECHONL 0x0d + #define l_ECHOE 0x02 + #define l_ECHOE_ECHOK 0x06 + #define l_ECHOE_ECHONL 0x0a + #define l_ECHOE_ECHOK_ECHONL 0x0e + #define l_ECHOK 0x04 + #define l_ECHOK_ECHONL 0x0c + #define l_ECHONL 0x08 + + int byte = getByte(flag,5,1); + return byte; + +} + +int getLocalOptions(tcflag_t flag) { + + #define l_ICANON 0x10 + #define l_ICANON_ISIG 0x50 + #define l_ICANON_IEXTEN 0x30 + #define l_ICANON_NOFLSH 0x90 + #define l_ICANON_ISIG_IEXTEN 0x70 + #define l_ICANON_ISIG_NOFLSH 0xd0 + #define l_ICANON_IEXTEN_NOFLSH 0xb0 + #define l_ICANON_ISIG_IEXTEN_NOFLSH 0xf0 + #define l_ISIG 0x40 + #define l_ISIG_IEXTEN 0x60 + #define l_ISIG_NOFLSH 0xc0 + #define l_ISIG_IEXTEN_NOFLSH 0xe0 + #define l_IEXTEN 0x20 + #define l_IEXTEN_NOFLSH 0xa0 + #define l_NOFLSH 0x80 + + int byte = getByte(flag,5,0); + return byte; + +} + +int getToStop(tcflag_t flag) { + + #define l_TOSTOP 0x01 + + int byte = getByte(flag,4,1); + return byte; + +} + +//CONTROLOPT FUNCTIONS + +int getCharSet(tcflag_t flag) { + + //FLAG IS MADE UP OF 8 BYTES, A FLAG IS MADE UP OF A NIBBLE -> 4 BITS, WE NEED TO EXTRACT THE SECOND NIBBLE (1st) FROM THE FIFTH BYTE (6th). + int byte = getByte(flag,5,1); + + switch(byte) { + + case 0X0: + return CS5; + break; + + case 0X4: + return CS6; + break; + + case 0X8: + return CS7; + break; + + case 0Xc: + return CS8; + break; + + default: + return CS8; + break; + + } + +} + +int getControlOptions(tcflag_t flag) { + + #define c_ALL_ENABLED 0xd0 + #define c_PAREVEN_CSTOPB 0x50 + #define c_PAREVEN_NOCSTOPB 0x40 + #define c_PARODD_NOCSTOPB 0xc0 + #define c_NOPARENB_CSTOPB 0x10 + #define c_ALL_DISABLED 0x00 + + int byte = getByte(flag,5,0); + return byte; + +} + +//LIBFUNCTIONS + +int tcgetattr(int fd, struct termios *termios_p) { + + if(fd != com.fd) return -1; + int ret=0; + + ret = GetCommState(com.hComm,&SerialParams); + + return 0; + +} + +int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { + + if(fd != com.fd) return -1; + int ret=0; + + //Store flags into local variables + tcflag_t iflag = termios_p->c_iflag; + tcflag_t lflag = termios_p->c_lflag; + tcflag_t cflag = termios_p->c_cflag; + tcflag_t oflag = termios_p->c_oflag; + + /***************************************** + iflag + *****************************************/ + + int IX = getIXOptions(iflag); + + if( (IX == i_IXOFF_IXON) || (IX == i_PARMRK_IXON_IXOFF) ) { + + SerialParams.fOutX = TRUE; + SerialParams.fInX = TRUE; + SerialParams.fTXContinueOnXoff = TRUE; + + } + + /***************************************** + lflag + *****************************************/ + + int EchoOpt = getEchoOptions(lflag); + int l_opt = getLocalOptions(lflag); + int tostop = getToStop(lflag); + + //Missing parameters... + + /***************************************** + cflag + *****************************************/ + + int CharSet = getCharSet(cflag); + int c_opt = getControlOptions(cflag); + + switch(CharSet) { + + case CS5: + SerialParams.ByteSize = 5; + break; + + case CS6: + SerialParams.ByteSize = 6; + break; + + case CS7: + SerialParams.ByteSize = 7; + break; + + case CS8: + SerialParams.ByteSize = 8; + break; + + } + + switch(c_opt) { + + case c_ALL_ENABLED: + SerialParams.Parity = ODDPARITY; + SerialParams.StopBits = TWOSTOPBITS; + break; + + case c_ALL_DISABLED: + SerialParams.Parity = NOPARITY; + SerialParams.StopBits = ONESTOPBIT; + break; + + case c_PAREVEN_CSTOPB: + SerialParams.Parity = EVENPARITY; + SerialParams.StopBits = TWOSTOPBITS; + break; + + case c_PAREVEN_NOCSTOPB: + SerialParams.Parity = EVENPARITY; + SerialParams.StopBits = ONESTOPBIT; + break; + + case c_PARODD_NOCSTOPB: + SerialParams.Parity = ODDPARITY; + SerialParams.StopBits = ONESTOPBIT; + break; + + case c_NOPARENB_CSTOPB: + SerialParams.Parity = NOPARITY; + SerialParams.StopBits = TWOSTOPBITS; + break; + + } + + /***************************************** + oflag + *****************************************/ + + /*int OP; + if(oflag == OPOST) + else ...*/ + //Missing parameters... + + /***************************************** + special characters + *****************************************/ + + if(termios_p->c_cc[VEOF] != 0) SerialParams.EofChar = (char) termios_p->c_cc[VEOF]; + if(termios_p->c_cc[VINTR] != 0) SerialParams.EvtChar = (char) termios_p->c_cc[VINTR]; + + if(termios_p->c_cc[VMIN] == 1) { //Blocking + + + timeouts.ReadIntervalTimeout = 0; // in milliseconds + timeouts.ReadTotalTimeoutConstant = 0; // in milliseconds + timeouts.ReadTotalTimeoutMultiplier = 0; // in milliseconds + timeouts.WriteTotalTimeoutConstant = 0; // in milliseconds + timeouts.WriteTotalTimeoutMultiplier = 0; // in milliseconds + + + } + + else { //Non blocking + + timeouts.ReadIntervalTimeout = termios_p->c_cc[VTIME]*100; // in milliseconds + timeouts.ReadTotalTimeoutConstant = termios_p->c_cc[VTIME]*100; // in milliseconds + timeouts.ReadTotalTimeoutMultiplier = termios_p->c_cc[VTIME]*100; // in milliseconds + timeouts.WriteTotalTimeoutConstant = termios_p->c_cc[VTIME]*100; // in milliseconds + timeouts.WriteTotalTimeoutMultiplier = termios_p->c_cc[VTIME]*100; // in milliseconds + + } + + + + SetCommTimeouts(com.hComm,&timeouts); + + /***************************************** + EOF + *****************************************/ + + ret = SetCommState(com.hComm,&SerialParams); + if (ret != 0) return 0; + else return -1; + +} + +int tcsendbreak(int fd, int duration) { + + if(fd != com.fd) return -1; + + int ret = 0; + ret = TransmitCommChar(com.hComm,'\x00'); + if(ret != 0) return 0; + else return -1; + +} + +int tcdrain(int fd) { + + if(fd != com.fd) return -1; + SetCommMask(com.hComm, EV_TXEMPTY); + DWORD dwEventMask; + WaitCommEvent(com.hComm, &dwEventMask, NULL); + + return 0; + +} + +int tcflush(int fd, int queue_selector) { + + if(fd != com.fd) return -1; + int rc=0; + + switch (queue_selector) { + + case TCIFLUSH: + rc = PurgeComm(com.hComm, PURGE_RXCLEAR); + break; + + case TCOFLUSH: + rc = PurgeComm(com.hComm, PURGE_TXCLEAR); + break; + + case TCIOFLUSH: + rc = PurgeComm(com.hComm, PURGE_RXCLEAR); + rc *= PurgeComm(com.hComm, PURGE_TXCLEAR); + break; + + default: + rc = 0; + break; + + } + + if(rc != 0) return 0; + else return -1; + +} + +int tcflow(int fd, int action) { + + if(fd != com.fd) return -1; + int rc = 0; + + switch (action) { + + case TCOOFF: + rc = PurgeComm(com.hComm, PURGE_TXABORT); + break; + + case TCOON: + rc = ClearCommBreak(com.hComm); + break; + + case TCIOFF: + rc = PurgeComm(com.hComm, PURGE_RXABORT); + break; + + case TCION: + rc = ClearCommBreak(com.hComm); + break; + + default: + rc = 0; + break; + + } + + if(rc != 0) return 0; + else return -1; + +} + +void cfmakeraw(struct termios *termios_p) { + + SerialParams.ByteSize = 8; + SerialParams.StopBits = ONESTOPBIT; + SerialParams.Parity = NOPARITY; + +} + +speed_t cfgetispeed(const struct termios *termios_p) { + + return SerialParams.BaudRate; + +} + +speed_t cfgetospeed(const struct termios *termios_p) { + + return SerialParams.BaudRate; + +} + +int cfsetispeed(struct termios *termios_p, speed_t speed) { + + SerialParams.BaudRate = speed; + return 0; + +} + +int cfsetospeed(struct termios *termios_p, speed_t speed) { + + SerialParams.BaudRate = speed; + return 0; + +} + +int cfsetspeed(struct termios *termios_p, speed_t speed) { + + SerialParams.BaudRate = speed; + return 0; + +} + +int selectSerial(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { + + SetCommMask(com.hComm, EV_RXCHAR); + DWORD dwEventMask; + WaitCommEvent(com.hComm, &dwEventMask, NULL); + + if(dwEventMask == EV_RXCHAR) return com.fd; + else return -1; + +} + +int readFromSerial(int fd, char* buffer, int count) { + + if(fd != com.fd) return -1; + int rc = 0; + int ret; + + ret = ReadFile(com.hComm, buffer, count, &rc, NULL); + + if (ret == 0) return -1; + else return rc; + +} + +int writeToSerial(int fd, char* buffer, int count) { + + if(fd != com.fd) return -1; + int rc = 0; + int ret; + + ret = WriteFile(com.hComm, buffer, count, &rc, NULL); + + if (ret == 0) return -1; + else return rc; + +} + +int openSerial(char* portname, int opt) { + + + if (strlen(portname) < 4) return -1; + + com.port = calloc(1,sizeof(char)*(strlen("\\\\.\\")+4)); + strncat(com.port, portname, 4); + + switch (opt) { + + case O_RDWR: + com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + break; + + case O_RDONLY: + com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); + break; + + case O_WRONLY: + com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + break; + + } + + if (com.hComm == INVALID_HANDLE_VALUE) return -1; + strncpy(portname, portname + 3, 1); + com.fd = atoi(portname); //COMx + SerialParams.DCBlength = sizeof(SerialParams); + return com.fd; + +} + +int closeSerial(int fd) { + + int ret = CloseHandle(com.hComm); + if(ret != 0) return 0; + else return -1; + +} diff --git a/win/termiWin.h b/win/termiWin.h new file mode 100644 index 00000000..9f1e404c --- /dev/null +++ b/win/termiWin.h @@ -0,0 +1,183 @@ +/* termiWin.h +* +* Copyright (C) 2017 Christian Visintin - christian.visintin1997@gmail.com +* +* This file is part of "termiWin: a termios porting for Windows" +* +* termiWin is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* termiWin is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with termiWin. If not, see . +* +*/ + +#ifndef TERMIWIN_H_ +#define TERMIWIN_H_ +#endif + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#include +#include +#pragma comment(lib, "Ws2_32.lib") + +/*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ + +#define read readFromSerial +#define write writeToSerial +#define select selectSerial +#define open openSerial +#define close closeSerial + +//Serial options - Linux -> Windows + +/*setAttr flags - ~ in front of flags -> deny them*/ + +//iFlag + +#define INPCK 0x00004000 /*If this bit is set, input parity checking is enabled. If it is not set, no checking at all is done for parity errors on input; the characters are simply passed through to the application.*/ +#define IGNPAR 0x00001000 /*If this bit is set, any byte with a framing or parity error is ignored. This is only useful if INPCK is also set.*/ +#define PARMRK 0x00040000 /*If this bit is set, input bytes with parity or framing errors are marked when passed to the program. This bit is meaningful only when INPCK is set and IGNPAR is not set.*/ +#define ISTRIP 0x00008000 /*If this bit is set, valid input bytes are stripped to seven bits; otherwise, all eight bits are available for programs to read. */ +#define IGNBRK 0x00000400 /*If this bit is set, break conditions are ignored. */ +#define BRKINT 0x00000100 /*If this bit is set and IGNBRK is not set, a break condition clears the terminal input and output queues and raises a SIGINT signal for the foreground process group associated with the terminal. */ +#define IGNCR 0x00000800 /*If this bit is set, carriage return characters ('\r') are discarded on input. Discarding carriage return may be useful on terminals that send both carriage return and linefeed when you type the RET key. */ +#define ICRNL 0x00000200 /*If this bit is set and IGNCR is not set, carriage return characters ('\r') received as input are passed to the application as newline characters ('\n').*/ +#define INLCR 0x00002000 /*If this bit is set, newline characters ('\n') received as input are passed to the application as carriage return characters ('\r').*/ +#define IXOFF 0x00010000 /*If this bit is set, start/stop control on input is enabled. In other words, the computer sends STOP and START characters as necessary to prevent input from coming in faster than programs are reading it. The idea is that the actual terminal hardware that is generating the input data responds to a STOP character by suspending transmission, and to a START character by resuming transmission.*/ +#define IXON 0x00020000 /*If this bit is set, start/stop control on output is enabled. In other words, if the computer receives a STOP character, it suspends output until a START character is received. In this case, the STOP and START characters are never passed to the application program. If this bit is not set, then START and STOP can be read as ordinary characters.*/ + +//lFlag + +#define ICANON 0x00001000 /*This bit, if set, enables canonical input processing mode. Otherwise, input is processed in noncanonical mode. */ +#define ECHO 0x00000100 /*If this bit is set, echoing of input characters back to the terminal is enabled.*/ +#define ECHOE 0x00000200 /*If this bit is set, echoing indicates erasure of input with the ERASE character by erasing the last character in the current line from the screen. Otherwise, the character erased is re-echoed to show what has happened (suitable for a printing terminal). */ +#define ECHOK 0x00000400 /*This bit enables special display of the KILL character by moving to a new line after echoing the KILL character normally. The behavior of ECHOKE (below) is nicer to look at.*/ +#define ECHONL 0x00000800 /*If this bit is set and the ICANON bit is also set, then the newline ('\n') character is echoed even if the ECHO bit is not set. */ +#define ISIG 0x00004000 /*This bit controls whether the INTR, QUIT, and SUSP characters are recognized. The functions associated with these characters are performed if and only if this bit is set. Being in canonical or noncanonical input mode has no effect on the interpretation of these characters. */ +#define IEXTEN 0x00002000 /*On BSD systems and GNU/Linux and GNU/Hurd systems, it enables the LNEXT and DISCARD characters.*/ +#define NOFLSH 0x00008000 /*Normally, the INTR, QUIT, and SUSP characters cause input and output queues for the terminal to be cleared. If this bit is set, the queues are not cleared. */ +#define TOSTOP 0x00010000 /*If this bit is set and the system supports job control, then SIGTTOU signals are generated by background processes that attempt to write to the terminal.*/ + +//cFlag + +#define CSTOPB 0x00001000 /*If this bit is set, two stop bits are used. Otherwise, only one stop bit is used. */ +#define PARENB 0x00004000 /*If this bit is set, generation and detection of a parity bit are enabled*/ +#define PARODD 0x00008000 /*This bit is only useful if PARENB is set. If PARODD is set, odd parity is used, otherwise even parity is used. */ +#define CSIZE 0x00000c00 /*This is a mask for the number of bits per character. */ +#define CS5 0x00000000 /*This specifies five bits per byte. */ +#define CS6 0x00000400 /*This specifies six bits per byte. */ +#define CS7 0x00000800 /*This specifies seven bits per byte. */ +#define CS8 0x00000c00 /*This specifies eight bits per byte. */ + +//oFlag + +#define OPOST 0x00000100 /*If this bit is set, output data is processed in some unspecified way so that it is displayed appropriately on the terminal device. This typically includes mapping newline characters ('\n') onto carriage return and linefeed pairs. */ + +//cc + +#define VEOF 0 +#define VEOL 1 +#define VERASE 2 +#define VINTR 3 +#define VKILL 4 +#define VMIN 5 /*If set to 0, serial communication is NOT-BLOCKING, otherwise is BLOCKING*/ +#define VQUIT 6 +#define VSTART 7 +#define VSTOP 8 +#define VSUSP 9 +#define VTIME 10 + +//END OF setAttr flags + +/*Controls*/ +#define TIOMBIC DTR_CONTROL_DISABLE +#define TIOMBIS DTR_CONTROL_ENABLE +#define CRTSCTS RTS_CONTROL_ENABLE + +/*Others*/ +#define NCCS 11 + +//Baud speed +#define B300 CBR_300 +#define B1200 CBR_2400 +#define B2400 CBR_2400 +#define B4800 CBR_4800 +#define B9600 CBR_9600 +#define B19200 CBR_19200 +#define B38400 CBR_38400 +#define B57600 CBR_57600 +#define B115200 CBR_115200 + +/*Attributes optional_actions*/ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/*TCFLUSH options*/ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/*TCFLOW optons*/ + +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +//typdef +typedef unsigned tcflag_t; /*This is an unsigned integer type used to represent the various bit masks for terminal flags.*/ +typedef unsigned cc_t; /*This is an unsigned integer type used to represent characters associated with various terminal control functions.*/ +typedef unsigned speed_t; /*used for terminal baud rates*/ + +typedef struct termios +{ + + tcflag_t c_iflag; /*input modes*/ + tcflag_t c_oflag; /*output modes*/ + tcflag_t c_cflag; /*control modes*/ + tcflag_t c_lflag; /*local modes*/ + cc_t c_cc[NCCS]; /*special character*/ + +} termios; + +//Serial configuration functions + +int tcgetattr(int fd, struct termios *termios_p); +int tcsetattr(int fd, int optional_actions, const struct termios *termios_p); +int tcsendbreak(int fd, int duration); +int tcdrain(int fd); +int tcflush(int fd, int queue_selector); +int tcflow(int fd, int action); +void cfmakeraw(struct termios *termios_p); +speed_t cfgetispeed(const struct termios *termios_p); +speed_t cfgetospeed(const struct termios *termios_p); +int cfsetispeed(struct termios *termios_p, speed_t speed); +int cfsetospeed(struct termios *termios_p, speed_t speed); +int cfsetspeed(struct termios * termios_p, speed_t speed); + +//Write/Read/Open/Close/Select Functions + +int selectSerial(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +int readFromSerial(int fd, char* buffer, int count); +int writeToSerial(int fd, char* buffer, int count); +int openSerial(char* portname, int opt); +int closeSerial(int fd); + + + +#endif + +#ifndef _WIN32 +#pragma message("-Warning: termiWin requires a Windows system!") +#endif From 0c6c7fba4d7cd94aff40f0a8d9c214b839ff3202 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 16:42:08 +0100 Subject: [PATCH 012/238] try --- win/termiWin.c | 6 ++++++ win/termiWin.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/win/termiWin.c b/win/termiWin.c index bf430fc0..a4301929 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -23,6 +23,12 @@ #include #include +#define read readFromSerial +#define write writeToSerial +#define select selectSerial +#define open openSerial +#define close closeSerial + typedef struct COM { HANDLE hComm; diff --git a/win/termiWin.h b/win/termiWin.h index 9f1e404c..17750132 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -32,12 +32,13 @@ /*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ +/* #define read readFromSerial #define write writeToSerial #define select selectSerial #define open openSerial #define close closeSerial - +*/ //Serial options - Linux -> Windows /*setAttr flags - ~ in front of flags -> deny them*/ From 3d096ec4636cd711f3ca2900afdb160aed8a1c0f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 16:50:20 +0100 Subject: [PATCH 013/238] try --- mbus/mbus-tcp.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 80703aef..74a6956b 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -17,7 +17,6 @@ #include #include #include -#include #else #include #include From 4ad00578f7ad865e6f0e86cac24de467f8eea170 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 16:54:15 +0100 Subject: [PATCH 014/238] fix --- mbus/mbus-serial.c | 1 - mbus/mbus-tcp.c | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 52d979d0..3952f274 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -13,7 +13,6 @@ #include #include #include -#include <../win/termiWin.h> #else #include #include diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 74a6956b..80703aef 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -17,6 +17,7 @@ #include #include #include +#include #else #include #include From d9cf47724b44973e9d394c09d9e609b18deba6a0 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:02:48 +0100 Subject: [PATCH 015/238] try --- mbus/mbus-serial.c | 2 +- mbus/mbus-tcp.c | 2 +- win/termiWin.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 3952f274..b5719a4d 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -15,7 +15,7 @@ #include #else #include -#include +//#include #include #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 80703aef..4fa473ba 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -14,10 +14,10 @@ #ifdef _WIN32 +#include #include #include #include -#include #else #include #include diff --git a/win/termiWin.h b/win/termiWin.h index 17750132..bc74ef7e 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -26,9 +26,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN -#include #include #pragma comment(lib, "Ws2_32.lib") +#include /*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ From 6f550f8524cd4ef2ab005c6ed0f06afbb0572457 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:07:15 +0100 Subject: [PATCH 016/238] try --- mbus/mbus-serial.c | 1 + mbus/mbus-serial.h | 3 ++- mbus/mbus-tcp.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index b5719a4d..273f0db3 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -9,6 +9,7 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include #include #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index bd249a22..079f5281 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -19,9 +19,10 @@ #define MBUS_SERIAL_H #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <../win/termiWin.h> #include #include -#include <../win/termiWin.h> #else #include #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 4fa473ba..8fcc067c 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -14,6 +14,7 @@ #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include #include #include @@ -21,6 +22,7 @@ #else #include #include +#include #endif #include @@ -28,7 +30,6 @@ #include -#include #include #include From e385d78f9a43069b844767421852838f51db5263 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:12:03 +0100 Subject: [PATCH 017/238] fis --- mbus/mbus-serial.c | 12 +++++------- mbus/mbus-serial.h | 1 - 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 273f0db3..1f8b78a7 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -9,7 +9,11 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + + +#ifdef _WIN32 #include #include #include @@ -20,12 +24,6 @@ #include #endif -#ifdef _WIN32 -#define __PRETTY_FUNCTION__ __FUNCSIG__ -#endif - - - #include #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 079f5281..22a462e7 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -19,7 +19,6 @@ #define MBUS_SERIAL_H #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN #include <../win/termiWin.h> #include #include From 90f8e149ff4c3505e0872b03d5206f8e813613b6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:16:04 +0100 Subject: [PATCH 018/238] fix --- mbus/mbus-tcp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 8fcc067c..bfa26d64 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #endif #include @@ -30,9 +32,6 @@ #include -#include -#include - #include #include #include From e767e89114536f836aa0326c061b4ea66ef1185f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:25:53 +0100 Subject: [PATCH 019/238] try --- mbus/mbus-serial.c | 2 +- mbus/mbus-tcp.c | 4 ++-- mbus/mbus-tcp.h | 3 --- win/termiWin.h | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 1f8b78a7..bb77a989 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -22,6 +22,7 @@ #include //#include #include +#include #endif #include @@ -32,7 +33,6 @@ #include #include -#include #include "mbus-serial.h" #include "mbus-protocol-aux.h" diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bfa26d64..4ffb64bd 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -15,8 +15,8 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN -#include #include +#include #include #include #else @@ -25,6 +25,7 @@ #include #include #include +#include #endif #include @@ -34,7 +35,6 @@ #include #include -#include #include #include "mbus-tcp.h" diff --git a/mbus/mbus-tcp.h b/mbus/mbus-tcp.h index 0d4e6b73..3916aa55 100755 --- a/mbus/mbus-tcp.h +++ b/mbus/mbus-tcp.h @@ -44,6 +44,3 @@ int mbus_tcp_set_timeout_set(double seconds); #endif #endif /* MBUS_TCP_H */ - - - diff --git a/win/termiWin.h b/win/termiWin.h index bc74ef7e..17750132 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -26,9 +26,9 @@ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN +#include #include #pragma comment(lib, "Ws2_32.lib") -#include /*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ From acfa9045560f49afa1323f6fd625d5c46282151e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 17:29:50 +0100 Subject: [PATCH 020/238] fix --- mbus/mbus-tcp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 4ffb64bd..5e82bc90 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -14,9 +14,8 @@ #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include #include +#include #include #include #else From 83eded9f57ee5a5d601059d0060648dec5969aa6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 20:06:30 +0100 Subject: [PATCH 021/238] try --- mbus/mbus-tcp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 5e82bc90..30fb6bb0 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -18,6 +18,22 @@ #include #include #include + +/* +#ifndef _SSIZE_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 ssize_t; +#else +typedef _W64 unsigned int ssize_t; +#endif +#define _SSIZE_T_DEFINED +#endif +*/ +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + #else #include #include From e0b4dbb9e111583cb3cdbdfcb250d97d5b20ba05 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 20:09:48 +0100 Subject: [PATCH 022/238] fix --- mbus/mbus-serial.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index bb77a989..422ffd7c 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -18,6 +18,13 @@ #include #include #include + +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#endif + + #else #include //#include From 910a0872db5ef504dffa7bd456b5b0d9b7d1f6af Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 20:21:02 +0100 Subject: [PATCH 023/238] fix --- mbus/mbus-tcp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 30fb6bb0..da3b8c8d 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -29,9 +29,15 @@ typedef _W64 unsigned int ssize_t; #define _SSIZE_T_DEFINED #endif */ -#if defined(_MSC_VER) #include typedef SSIZE_T ssize_t; + +#ifndef SSIZE_MAX +#ifdef _WIN64 +#define SSIZE_MAX _I64_MAX +#else +#define SSIZE_MAX INT_MAX +#endif #endif #else From e4d0f7ca55b1b7db602c78c5212c65fffa7ac71c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 20:23:36 +0100 Subject: [PATCH 024/238] fix --- mbus/mbus-serial.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 422ffd7c..7fc9de72 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -19,11 +19,16 @@ #include #include -#if defined(_MSC_VER) #include typedef SSIZE_T ssize_t; -#endif +#ifndef SSIZE_MAX +#ifdef _WIN64 +#define SSIZE_MAX _I64_MAX +#else +#define SSIZE_MAX INT_MAX +#endif +#endif #else #include From 8e770c4d5a43dff1984528a1ce589539de7d128f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 21:01:11 +0100 Subject: [PATCH 025/238] try --- mbus/mbus-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 7fc9de72..24aaceda 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -14,7 +14,7 @@ #ifdef _WIN32 -#include +//#include #include #include #include From 6277835fe50a19ca9d2a59c477866886b094e91c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 21:08:45 +0100 Subject: [PATCH 026/238] current --- mbus/mbus-serial.c | 2 -- mbus/mbus-tcp.c | 10 ---------- 2 files changed, 12 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 24aaceda..0e89b02b 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -14,7 +14,6 @@ #ifdef _WIN32 -//#include #include #include #include @@ -32,7 +31,6 @@ typedef SSIZE_T ssize_t; #else #include -//#include #include #include #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index da3b8c8d..bb6a29be 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -19,16 +19,6 @@ #include #include -/* -#ifndef _SSIZE_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 ssize_t; -#else -typedef _W64 unsigned int ssize_t; -#endif -#define _SSIZE_T_DEFINED -#endif -*/ #include typedef SSIZE_T ssize_t; From 9b75c6e1661b42e2f79d69545300beb50ed030ae Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 21:18:49 +0100 Subject: [PATCH 027/238] add b600 --- win/termiWin.h | 1 + 1 file changed, 1 insertion(+) diff --git a/win/termiWin.h b/win/termiWin.h index 17750132..d6c501d6 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -110,6 +110,7 @@ //Baud speed #define B300 CBR_300 +#define B600 CBR_600 #define B1200 CBR_2400 #define B2400 CBR_2400 #define B4800 CBR_4800 From e7bb3d65aa225ffb4a3ae2b3c7b27fc3e446b12a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 21:39:12 +0100 Subject: [PATCH 028/238] fixes --- mbus/mbus-serial.c | 2 ++ win/termiWin.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 0e89b02b..faabb111 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -29,6 +29,8 @@ typedef SSIZE_T ssize_t; #endif #endif +#define O_NOCTTY 0x0000 // No idea if this makes sense + #else #include #include diff --git a/win/termiWin.h b/win/termiWin.h index d6c501d6..f29fb4a9 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -80,6 +80,8 @@ #define CS7 0x00000800 /*This specifies seven bits per byte. */ #define CS8 0x00000c00 /*This specifies eight bits per byte. */ +#define CLOCAL 0x00000000 // No idea if this makes sense +#define CREAD 0x00000000 // No idea if this makes sense //oFlag #define OPOST 0x00000100 /*If this bit is set, output data is processed in some unspecified way so that it is displayed appropriately on the terminal device. This typically includes mapping newline characters ('\n') onto carriage return and linefeed pairs. */ From 90fba8b6f8b62b51bb9ecf7624e9ea04891c8864 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 21:59:24 +0100 Subject: [PATCH 029/238] try --- mbus/mbus-serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index faabb111..b6b6e57c 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -14,6 +14,7 @@ #ifdef _WIN32 +#include <../win/termiWin.h> #include #include #include From e2eaca54fa65f3c963cde6dc610c8529fc5579eb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:03:24 +0100 Subject: [PATCH 030/238] try --- win/termiWin.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/win/termiWin.h b/win/termiWin.h index f29fb4a9..5c96e763 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -144,6 +144,8 @@ typedef unsigned tcflag_t; /*This is an unsigned integer type used to represent typedef unsigned cc_t; /*This is an unsigned integer type used to represent characters associated with various terminal control functions.*/ typedef unsigned speed_t; /*used for terminal baud rates*/ +#ifndef TERMIOS_DEFINED +#define TERMIOS_DEFINED typedef struct termios { @@ -154,6 +156,7 @@ typedef struct termios cc_t c_cc[NCCS]; /*special character*/ } termios; +#endif //Serial configuration functions From 720d3dc4841ba3e57e043029dcd5d48e7cbef485 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:22:03 +0100 Subject: [PATCH 031/238] try --- mbus/mbus-serial.c | 1 - mbus/mbus-tcp.c | 7 +++++++ win/termiWin.h | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index b6b6e57c..faabb111 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -14,7 +14,6 @@ #ifdef _WIN32 -#include <../win/termiWin.h> #include #include #include diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bb6a29be..62397660 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -111,8 +111,15 @@ mbus_tcp_connect(mbus_handle *handle) // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds time_out.tv_usec = tcp_timeout_usec; // microseconds + + #ifdef _WIN32 + uint64_t millis = (time_out.tv_sec * (uint64_t)1000) + (time_out.tv_usec / 1000); + setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &millis, sizeof(millis)); + setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &millis, sizeof(millis)); + #else setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &time_out, sizeof(time_out)); setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &time_out, sizeof(time_out)); + #endif return 0; } diff --git a/win/termiWin.h b/win/termiWin.h index 5c96e763..f29fb4a9 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -144,8 +144,6 @@ typedef unsigned tcflag_t; /*This is an unsigned integer type used to represent typedef unsigned cc_t; /*This is an unsigned integer type used to represent characters associated with various terminal control functions.*/ typedef unsigned speed_t; /*used for terminal baud rates*/ -#ifndef TERMIOS_DEFINED -#define TERMIOS_DEFINED typedef struct termios { @@ -156,7 +154,6 @@ typedef struct termios cc_t c_cc[NCCS]; /*special character*/ } termios; -#endif //Serial configuration functions From ade7320d58bf9c72e0e9a33623f2ba632bd6b793 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:32:11 +0100 Subject: [PATCH 032/238] fix --- mbus/mbus-tcp.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 62397660..dd9a7871 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -111,15 +111,8 @@ mbus_tcp_connect(mbus_handle *handle) // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds time_out.tv_usec = tcp_timeout_usec; // microseconds - - #ifdef _WIN32 - uint64_t millis = (time_out.tv_sec * (uint64_t)1000) + (time_out.tv_usec / 1000); - setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &millis, sizeof(millis)); - setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &millis, sizeof(millis)); - #else - setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &time_out, sizeof(time_out)); - setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &time_out, sizeof(time_out)); - #endif + setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &time_out, sizeof(struct timeval)); + setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &time_out, sizeof(struct timeval)); return 0; } From 8985f5dbce08a96a43f2e2529f8670d8c2404203 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:36:25 +0100 Subject: [PATCH 033/238] try --- mbus/mbus-tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index dd9a7871..2eefa54c 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -111,8 +111,8 @@ mbus_tcp_connect(mbus_handle *handle) // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds time_out.tv_usec = tcp_timeout_usec; // microseconds - setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &time_out, sizeof(struct timeval)); - setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &time_out, sizeof(struct timeval)); + setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, (struct timeval *)&time_out, sizeof(time_out)); + setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&time_out, sizeof(time_out)); return 0; } From 2fff07de6a371f7676598e4af134685c2d63ac2c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:40:51 +0100 Subject: [PATCH 034/238] try --- mbus/mbus-tcp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 2eefa54c..8ff8400a 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -111,9 +111,15 @@ mbus_tcp_connect(mbus_handle *handle) // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds time_out.tv_usec = tcp_timeout_usec; // microseconds - setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, (struct timeval *)&time_out, sizeof(time_out)); - setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&time_out, sizeof(time_out)); + #ifdef _WIN32 + uint64_t millis = (time->tv_sec * (uint64_t)1000) + (time->tv_usec / 1000); + setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&millis, sizeof(time_out)); + setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&millis, sizeof(time_out)); + #else + setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, &time_out, sizeof(time_out)); + setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, &time_out, sizeof(time_out)); + #endif return 0; } From 472848466a98ff3821b884fcbc962b2f36dd5e91 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 22:42:20 +0100 Subject: [PATCH 035/238] fix --- mbus/mbus-tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 8ff8400a..8c946559 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -113,7 +113,7 @@ mbus_tcp_connect(mbus_handle *handle) time_out.tv_usec = tcp_timeout_usec; // microseconds #ifdef _WIN32 - uint64_t millis = (time->tv_sec * (uint64_t)1000) + (time->tv_usec / 1000); + uint64_t millis = (time_out.tv_sec * (uint64_t)1000) + (time_out.tv_usec / 1000); setsockopt(handle->fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&millis, sizeof(time_out)); setsockopt(handle->fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&millis, sizeof(time_out)); #else From fd5a7ad38eea0fe22dd184503ea716ea5daa4f90 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:02:52 +0100 Subject: [PATCH 036/238] fix --- mbus/mbus-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index faabb111..137c8d9c 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -25,7 +25,7 @@ typedef SSIZE_T ssize_t; #ifdef _WIN64 #define SSIZE_MAX _I64_MAX #else -#define SSIZE_MAX INT_MAX +#define SSIZE_MAX LONG_MAX #endif #endif From e04685701d5e84caae90b646f999ad9ca861882f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:08:42 +0100 Subject: [PATCH 037/238] fix --- mbus/mbus-tcp.c | 2 +- win/termiWin.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 8c946559..cb4c4ca5 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -26,7 +26,7 @@ typedef SSIZE_T ssize_t; #ifdef _WIN64 #define SSIZE_MAX _I64_MAX #else -#define SSIZE_MAX INT_MAX +#define SSIZE_MAX LONG_MAX #endif #endif diff --git a/win/termiWin.c b/win/termiWin.c index a4301929..9235ef28 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -23,11 +23,13 @@ #include #include +/* #define read readFromSerial #define write writeToSerial #define select selectSerial #define open openSerial #define close closeSerial +*/ typedef struct COM { From f335971895f5a781f75ea16fd0da3429f1067712 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:28:44 +0100 Subject: [PATCH 038/238] logging --- mbus/mbus-tcp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index cb4c4ca5..3a568bd9 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -174,18 +174,22 @@ mbus_tcp_send_frame(mbus_handle *handle, mbus_frame *frame) if (handle == NULL || frame == NULL) { + fprintf(stderr, "%s: handle NULL.\n", __PRETTY_FUNCTION__); return -1; } if ((len = mbus_frame_pack(frame, buff, sizeof(buff))) == -1) { + fprintf(stderr, "%s: mbus_frame_pack failed\n", __PRETTY_FUNCTION__); snprintf(error_str, sizeof(error_str), "%s: mbus_frame_pack failed\n", __PRETTY_FUNCTION__); mbus_error_str_set(error_str); return -1; } + fprintf(stderr, "%s: before write\n", __PRETTY_FUNCTION__); if ((ret = write(handle->fd, buff, len)) == len) { + fprintf(stderr, "%s: write failed\n", __PRETTY_FUNCTION__); // // call the send event function, if the callback function is registered // From 1832ef51dc5d87553de6d5dfb793a1ac90f73abb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:32:10 +0100 Subject: [PATCH 039/238] log --- mbus/mbus-tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 3a568bd9..3445138a 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -107,6 +107,7 @@ mbus_tcp_connect(mbus_handle *handle) mbus_error_str_set(error_str); return -1; } + fprintf(stderr, "%s: HUHU\n", __PRETTY_FUNCTION__); // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds From 950a02f56d9ebf73dc524601801b38425a25555e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:34:10 +0100 Subject: [PATCH 040/238] try again logs --- mbus/mbus-tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 3445138a..bbba5d3d 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -107,7 +107,7 @@ mbus_tcp_connect(mbus_handle *handle) mbus_error_str_set(error_str); return -1; } - fprintf(stderr, "%s: HUHU\n", __PRETTY_FUNCTION__); + fprintf(stdout, "%s: HUHU\n", __PRETTY_FUNCTION__); // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds From 4c61a9779bd82f837446e636b9a559738a451aa3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Feb 2018 23:40:49 +0100 Subject: [PATCH 041/238] log --- mbus/mbus-protocol-aux.c | 1 + mbus/mbus-tcp.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index e7fe11cd..3bf645a1 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -27,6 +27,7 @@ /*@ignore@*/ #define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) +#define _DEBUG_ #ifdef _DEBUG_ #define MBUS_DEBUG(...) fprintf (stderr, __VA_ARGS__) #else diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bbba5d3d..4b469665 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -107,7 +107,7 @@ mbus_tcp_connect(mbus_handle *handle) mbus_error_str_set(error_str); return -1; } - fprintf(stdout, "%s: HUHU\n", __PRETTY_FUNCTION__); + fprintf(stderr, "%s: write failed\n", __PRETTY_FUNCTION__); // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds From 7e4f31e2758ee210aabe1442c075f63411440975 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 00:26:00 +0100 Subject: [PATCH 042/238] revert --- mbus/mbus-protocol-aux.c | 1 - mbus/mbus-tcp.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 3bf645a1..e7fe11cd 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -27,7 +27,6 @@ /*@ignore@*/ #define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) -#define _DEBUG_ #ifdef _DEBUG_ #define MBUS_DEBUG(...) fprintf (stderr, __VA_ARGS__) #else diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 4b469665..cb4c4ca5 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -107,7 +107,6 @@ mbus_tcp_connect(mbus_handle *handle) mbus_error_str_set(error_str); return -1; } - fprintf(stderr, "%s: write failed\n", __PRETTY_FUNCTION__); // Set a timeout time_out.tv_sec = tcp_timeout_sec; // seconds @@ -175,22 +174,18 @@ mbus_tcp_send_frame(mbus_handle *handle, mbus_frame *frame) if (handle == NULL || frame == NULL) { - fprintf(stderr, "%s: handle NULL.\n", __PRETTY_FUNCTION__); return -1; } if ((len = mbus_frame_pack(frame, buff, sizeof(buff))) == -1) { - fprintf(stderr, "%s: mbus_frame_pack failed\n", __PRETTY_FUNCTION__); snprintf(error_str, sizeof(error_str), "%s: mbus_frame_pack failed\n", __PRETTY_FUNCTION__); mbus_error_str_set(error_str); return -1; } - fprintf(stderr, "%s: before write\n", __PRETTY_FUNCTION__); if ((ret = write(handle->fd, buff, len)) == len) { - fprintf(stderr, "%s: write failed\n", __PRETTY_FUNCTION__); // // call the send event function, if the callback function is registered // From 2aa27ce1c64842beb9ee82864d1b1234c26c979b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 09:38:05 +0100 Subject: [PATCH 043/238] try --- mbus/mbus-serial.c | 7 +++++++ mbus/mbus-tcp.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 137c8d9c..136f3ca4 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -31,6 +31,13 @@ typedef SSIZE_T ssize_t; #define O_NOCTTY 0x0000 // No idea if this makes sense +#define read readFromSerial +#define write writeToSerial +#define select selectSerial +#define open openSerial +#define close closeSerial + + #else #include #include diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index cb4c4ca5..3fbcdb97 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -30,6 +30,10 @@ typedef SSIZE_T ssize_t; #endif #endif +#define write send // On Win the method is "send" +#define read recv // On Win the method is "recv" +#define close closesocket // On Win the method is "closesocket" + #else #include #include From 7f3ca550e7f0c4b27f84ddf51e848fb9985d7476 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 09:52:19 +0100 Subject: [PATCH 044/238] revert partly --- mbus/mbus-serial.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 136f3ca4..137c8d9c 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -31,13 +31,6 @@ typedef SSIZE_T ssize_t; #define O_NOCTTY 0x0000 // No idea if this makes sense -#define read readFromSerial -#define write writeToSerial -#define select selectSerial -#define open openSerial -#define close closeSerial - - #else #include #include From d474c820e51881fdf0f839fcffb63ce35a4636b6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 09:59:45 +0100 Subject: [PATCH 045/238] fix win32 tcp --- mbus/mbus-tcp.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 3fbcdb97..1c772a9e 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -30,10 +30,6 @@ typedef SSIZE_T ssize_t; #endif #endif -#define write send // On Win the method is "send" -#define read recv // On Win the method is "recv" -#define close closesocket // On Win the method is "closesocket" - #else #include #include @@ -161,7 +157,11 @@ mbus_tcp_disconnect(mbus_handle *handle) return -1; } + #ifdef _WIN32 + closesocket(handle->fd); + #else close(handle->fd); + #endif return 0; } @@ -188,7 +188,11 @@ mbus_tcp_send_frame(mbus_handle *handle, mbus_frame *frame) return -1; } + #ifdef _WIN32 + if ((ret = send(handle->fd, buff, len, 0)) == len) + #else if ((ret = write(handle->fd, buff, len)) == len) + #endif { // // call the send event function, if the callback function is registered @@ -236,7 +240,11 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) return MBUS_RECV_RESULT_ERROR; } + #ifdef _WIN32 + nread = recv(handle->fd, &buff[len], remaining, 0); + #else nread = read(handle->fd, &buff[len], remaining); + #endif switch (nread) { case -1: if (errno == EINTR) From ebb80415a9ce3523c1cdaa2f7d72434518fff380 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 10:19:20 +0100 Subject: [PATCH 046/238] try --- mbus/mbus-tcp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 1c772a9e..15127e94 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -30,6 +30,8 @@ typedef SSIZE_T ssize_t; #endif #endif +#define errno WSAGetLastError() + #else #include #include @@ -244,7 +246,6 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) nread = recv(handle->fd, &buff[len], remaining, 0); #else nread = read(handle->fd, &buff[len], remaining); - #endif switch (nread) { case -1: if (errno == EINTR) @@ -269,6 +270,7 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) len += nread; } + #endif } while ((remaining = mbus_parse(frame, buff, len)) > 0); // From 8ced25b8c4ac725021c3171dc14ec1a2eaa6dbff Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:05:32 +0100 Subject: [PATCH 047/238] fix --- mbus/mbus-tcp.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 15127e94..d2c899b1 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -80,6 +80,23 @@ mbus_tcp_connect(mbus_handle *handle) host = tcp_data->host; port = tcp_data->port; + #ifdef _WIN32 + WORD wVersionRequested; + WSADATA wsaData; + int err; + + /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + snprintf(error_str, sizeof(error_str), "%s: WSAStartup failed with error: %d", __PRETTY_FUNCTION__, err)); + mbus_error_str_set(error_str); + return -1; + } + #endif // // create the TCP connection // @@ -161,6 +178,7 @@ mbus_tcp_disconnect(mbus_handle *handle) #ifdef _WIN32 closesocket(handle->fd); + WSACleanup(); #else close(handle->fd); #endif From 458a83007be1227dc21891ae0fd5268ec328abf0 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:20:16 +0100 Subject: [PATCH 048/238] fix --- mbus/mbus-tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index d2c899b1..deb1a514 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -92,7 +92,7 @@ mbus_tcp_connect(mbus_handle *handle) if (err != 0) { /* Tell the user that we could not find a usable */ /* Winsock DLL. */ - snprintf(error_str, sizeof(error_str), "%s: WSAStartup failed with error: %d", __PRETTY_FUNCTION__, err)); + snprintf(error_str, sizeof(error_str), "%s: WSAStartup failed with error: %d", __PRETTY_FUNCTION__, err); mbus_error_str_set(error_str); return -1; } From a19aa1a84e1f1c8f31da6b5b07861bfb28dc16f8 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:34:00 +0100 Subject: [PATCH 049/238] change --- mbus/mbus-tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index deb1a514..f7a376d3 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -14,6 +14,8 @@ #ifdef _WIN32 +#define errno WSAGetLastError() + #include #include #include @@ -30,8 +32,6 @@ typedef SSIZE_T ssize_t; #endif #endif -#define errno WSAGetLastError() - #else #include #include From febc14e9b5bfa244d1b7f383df52422f79ae30d6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:37:42 +0100 Subject: [PATCH 050/238] fix --- mbus/mbus-tcp.c | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index f7a376d3..081f3124 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -14,8 +14,6 @@ #ifdef _WIN32 -#define errno WSAGetLastError() - #include #include #include @@ -81,21 +79,21 @@ mbus_tcp_connect(mbus_handle *handle) port = tcp_data->port; #ifdef _WIN32 - WORD wVersionRequested; - WSADATA wsaData; - int err; - - /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ - wVersionRequested = MAKEWORD(2, 2); - - err = WSAStartup(wVersionRequested, &wsaData); - if (err != 0) { - /* Tell the user that we could not find a usable */ - /* Winsock DLL. */ - snprintf(error_str, sizeof(error_str), "%s: WSAStartup failed with error: %d", __PRETTY_FUNCTION__, err); - mbus_error_str_set(error_str); - return -1; - } + WORD wVersionRequested; + WSADATA wsaData; + int err; + + /* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */ + wVersionRequested = MAKEWORD(2, 2); + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + /* Tell the user that we could not find a usable */ + /* Winsock DLL. */ + snprintf(error_str, sizeof(error_str), "%s: WSAStartup failed with error: %d", __PRETTY_FUNCTION__, err); + mbus_error_str_set(error_str); + return -1; + } #endif // // create the TCP connection @@ -261,9 +259,11 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) } #ifdef _WIN32 - nread = recv(handle->fd, &buff[len], remaining, 0); + nread = recv(handle->fd, &buff[len], remaining, 0); + errno = WSAGetLastError(); #else - nread = read(handle->fd, &buff[len], remaining); + nread = read(handle->fd, &buff[len], remaining); + #endif switch (nread) { case -1: if (errno == EINTR) @@ -288,7 +288,6 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) len += nread; } - #endif } while ((remaining = mbus_parse(frame, buff, len)) > 0); // From fba7a9976507dcf084199b4454a9126bc0b2e0df Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:46:09 +0100 Subject: [PATCH 051/238] enhance logging --- mbus/mbus-protocol-aux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index e7fe11cd..69338e38 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -2199,7 +2199,7 @@ mbus_send_ping_frame(mbus_handle *handle, int address, char purge_response) int mbus_select_secondary_address(mbus_handle * handle, const char *mask) { - int ret; + int ret, frameType; mbus_frame reply; if (mask == NULL || strlen(mask) != 16) @@ -2232,7 +2232,7 @@ mbus_select_secondary_address(mbus_handle * handle, const char *mask) return MBUS_PROBE_COLLISION; } - if (mbus_frame_type(&reply) == MBUS_FRAME_TYPE_ACK) + if (frameType = mbus_frame_type(&reply) == MBUS_FRAME_TYPE_ACK) { /* check for more data (collision) */ if (mbus_purge_frames(handle)) @@ -2243,7 +2243,7 @@ mbus_select_secondary_address(mbus_handle * handle, const char *mask) return MBUS_PROBE_SINGLE; } - MBUS_ERROR("%s: Unexpected reply for address [%s].\n", __PRETTY_FUNCTION__, mask); + MBUS_ERROR("%s: Unexpected reply for address [%s]. ret=%d, frameType=%d\n", __PRETTY_FUNCTION__, mask, ret, frameType); return MBUS_PROBE_NOTHING; } From eb6aa7854f1434f6b5cb4fa0dddab685a98db99f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 11:54:24 +0100 Subject: [PATCH 052/238] fix --- mbus/mbus-tcp.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 081f3124..cd249086 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -12,6 +12,8 @@ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) + #ifdef _WIN32 #include @@ -271,13 +273,16 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) if (errno == EAGAIN || errno == EWOULDBLOCK) { mbus_error_str_set("M-Bus tcp transport layer response timeout has been reached."); + MBUS_ERROR("%s: M-Bus tcp transport layer response timeout has been reached. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_TIMEOUT; } mbus_error_str_set("M-Bus tcp transport layer failed to read data."); + MBUS_ERROR("%s: M-Bus tcp transport layer failed to read data. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_ERROR; case 0: mbus_error_str_set("M-Bus tcp transport layer connection closed by remote host."); + MBUS_ERROR("%s: M-Bus tcp transport layer connection closed by remote host. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_RESET; default: if (len > (SSIZE_MAX-nread)) From 12de0eb92715aebae28a57504420022ecd4c87dd Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 12:01:26 +0100 Subject: [PATCH 053/238] try --- mbus/mbus-tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index cd249086..46219dfa 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -271,7 +271,7 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) if (errno == EINTR) goto retry; - if (errno == EAGAIN || errno == EWOULDBLOCK) { + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEOUT) { mbus_error_str_set("M-Bus tcp transport layer response timeout has been reached."); MBUS_ERROR("%s: M-Bus tcp transport layer response timeout has been reached. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_TIMEOUT; From c36e34c5881230d056b5b9d563438bc37333d678 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 12:36:53 +0100 Subject: [PATCH 054/238] fix --- mbus/mbus-tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 46219dfa..bb20a2ad 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -271,7 +271,7 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) if (errno == EINTR) goto retry; - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEOUT) { + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEDOUT) { mbus_error_str_set("M-Bus tcp transport layer response timeout has been reached."); MBUS_ERROR("%s: M-Bus tcp transport layer response timeout has been reached. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_TIMEOUT; From f14885a3d0c1a2f389b065e2cc613c1a63a36a26 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 12:44:24 +0100 Subject: [PATCH 055/238] fix --- mbus/mbus-tcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bb20a2ad..d1160aec 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -271,7 +271,11 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) if (errno == EINTR) goto retry; - if (errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEDOUT) { + if (errno == EAGAIN || errno == EWOULDBLOCK + #ifdef _WIN32 + || errno == WSAETIMEDOUT + #endif + ) { mbus_error_str_set("M-Bus tcp transport layer response timeout has been reached."); MBUS_ERROR("%s: M-Bus tcp transport layer response timeout has been reached. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_TIMEOUT; From 0cfbaefd2fd81d900cb26e01ccc969d49b86005a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 27 Feb 2018 12:51:42 +0100 Subject: [PATCH 056/238] finalize TCP --- mbus/mbus-tcp.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index d1160aec..bb05f801 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -12,9 +12,6 @@ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif -#define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) - - #ifdef _WIN32 #include #include @@ -277,16 +274,13 @@ int mbus_tcp_recv_frame(mbus_handle *handle, mbus_frame *frame) #endif ) { mbus_error_str_set("M-Bus tcp transport layer response timeout has been reached."); - MBUS_ERROR("%s: M-Bus tcp transport layer response timeout has been reached. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_TIMEOUT; } mbus_error_str_set("M-Bus tcp transport layer failed to read data."); - MBUS_ERROR("%s: M-Bus tcp transport layer failed to read data. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_ERROR; case 0: mbus_error_str_set("M-Bus tcp transport layer connection closed by remote host."); - MBUS_ERROR("%s: M-Bus tcp transport layer connection closed by remote host. (%d)\n", __PRETTY_FUNCTION__, errno); return MBUS_RECV_RESULT_RESET; default: if (len > (SSIZE_MAX-nread)) From f5da9c82aad286f0456ada4ee888927afb017edb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 12:24:40 +0100 Subject: [PATCH 057/238] try --- mbus/mbus-serial.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 137c8d9c..5c561070 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -12,7 +12,6 @@ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif - #ifdef _WIN32 #include #include @@ -27,6 +26,13 @@ typedef SSIZE_T ssize_t; #else #define SSIZE_MAX LONG_MAX #endif + +#define read readFromSerial +#define write writeToSerial +#define select selectSerial +#define open openSerial +#define close closeSerial + #endif #define O_NOCTTY 0x0000 // No idea if this makes sense From 670f6fddcc9b9709221a5b84ad86c16ceeaf6bef Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 12:32:27 +0100 Subject: [PATCH 058/238] try --- mbus/mbus-serial.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 5c561070..8de668db 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -27,12 +27,6 @@ typedef SSIZE_T ssize_t; #define SSIZE_MAX LONG_MAX #endif -#define read readFromSerial -#define write writeToSerial -#define select selectSerial -#define open openSerial -#define close closeSerial - #endif #define O_NOCTTY 0x0000 // No idea if this makes sense @@ -82,7 +76,11 @@ mbus_serial_connect(mbus_handle *handle) // // Use blocking read and handle it by serial port VMIN/VTIME setting + #ifdef _WIN32 + if ((handle->fd = openSerial(device, O_RDWR | O_NOCTTY)) < 0) + #else if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) + #endif { fprintf(stderr, "%s: failed to open tty.", __PRETTY_FUNCTION__); return -1; @@ -222,7 +220,11 @@ mbus_serial_disconnect(mbus_handle *handle) return -1; } + #ifdef _WIN32 + closeSerial(handle->fd); + #else close(handle->fd); + #endif return 0; } @@ -284,7 +286,11 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) printf("\n"); #endif + #ifdef _WIN32 + if ((ret = writeToSerial(handle->fd, buff, len)) == len) + #else if ((ret = write(handle->fd, buff, len)) == len) + #endif { // // call the send event function, if the callback function is registered @@ -347,7 +353,11 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame) //printf("%s: Attempt to read %d bytes [len = %d]\n", __PRETTY_FUNCTION__, remaining, len); + #ifdef _WIN32 + if ((nread = readFromSerial(handle->fd, &buff[len], remaining)) == -1) + #else if ((nread = read(handle->fd, &buff[len], remaining)) == -1) + #endif { // fprintf(stderr, "%s: aborting recv frame (remaining = %d, len = %d, nread = %d)\n", // __PRETTY_FUNCTION__, remaining, len, nread); From 175ee275597098bce86360a56d8fd6518cb513f6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 13:24:41 +0100 Subject: [PATCH 059/238] try --- mbus/mbus-serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 8de668db..3656b7ba 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -77,12 +77,12 @@ mbus_serial_connect(mbus_handle *handle) // Use blocking read and handle it by serial port VMIN/VTIME setting #ifdef _WIN32 - if ((handle->fd = openSerial(device, O_RDWR | O_NOCTTY)) < 0) + if ((handle->fd = openSerial(device, O_RDWR)) < 0) #else if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) #endif { - fprintf(stderr, "%s: failed to open tty.", __PRETTY_FUNCTION__); + fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__); return -1; } From 48a128dec3092f82289b1f48427e2f0cb7e2329d Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 13:41:05 +0100 Subject: [PATCH 060/238] ebug --- mbus/mbus-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 3656b7ba..c7217a3a 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -82,7 +82,7 @@ mbus_serial_connect(mbus_handle *handle) if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) #endif { - fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__); + fprintf(stderr, "%s: failed to open tty. %d\n", __PRETTY_FUNCTION__, GetLastError()); return -1; } From ca204130e5382d3c2c44145a8a0a1ffcfc138f47 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 23:03:03 +0100 Subject: [PATCH 061/238] fix --- mbus/mbus-serial.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index c7217a3a..7f4ce91b 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -82,7 +82,11 @@ mbus_serial_connect(mbus_handle *handle) if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) #endif { + #ifdef _WIN32 fprintf(stderr, "%s: failed to open tty. %d\n", __PRETTY_FUNCTION__, GetLastError()); + #else + fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__); + #endif return -1; } From 2576cc9368d82d4092ee82e942f3032103163728 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 23:08:47 +0100 Subject: [PATCH 062/238] fix --- mbus/mbus-serial.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 7f4ce91b..4953c8f4 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -85,7 +85,8 @@ mbus_serial_connect(mbus_handle *handle) #ifdef _WIN32 fprintf(stderr, "%s: failed to open tty. %d\n", __PRETTY_FUNCTION__, GetLastError()); #else - fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__); + fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__ + ); #endif return -1; } From 8d4651445a4204e1f3d26ef6470485a900a29a9e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 23:27:41 +0100 Subject: [PATCH 063/238] add very first win compile try --- libmbus.vcxproj | 145 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 libmbus.vcxproj diff --git a/libmbus.vcxproj b/libmbus.vcxproj new file mode 100644 index 00000000..5e821d2d --- /dev/null +++ b/libmbus.vcxproj @@ -0,0 +1,145 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {B03220E0-285E-8766-5959-75355F21213E} + Win32Proj + libmbus + true + x64 + + + + StaticLibrary + + + v140 + + + + + + + + + + $(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\ + $(Configuration)\obj\$(ProjectName)\ + false + true + $(SolutionDir)$(Configuration)\ + $(ProjectName) + $(OutDir)\$(ProjectName)$(TargetExt) + + + + .\mbus;%(AdditionalIncludeDirectories) + EnableFastChecks + true + false + ProgramDatabase + 4267;4351;4355;4800;4251;%(DisableSpecificWarnings) + false + false + false + Disabled + NotUsing + USING_UV_SHARED=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;DEBUG;_DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + true + true + false + Level3 + + + $(OutDir)$(ProjectName)$(TargetExt) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib + /ignore:4199 %(AdditionalOptions) + true + true + %(DelayLoadDLLs) + true + true + true + true + true + MachineX86 + + + .\mbus;%(AdditionalIncludeDirectories) + USING_UV_SHARED=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + .\mbus;%(AdditionalIncludeDirectories) + /MP %(AdditionalOptions) + true + false + ProgramDatabase + 4267;4351;4355;4800;4251;%(DisableSpecificWarnings) + false + Speed + true + AnySuitable + true + true + Full + NotUsing + USING_UV_SHARED=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) + MultiThreaded + false + true + true + false + Level3 + true + + + /LTCG %(AdditionalOptions) + $(OutDir)$(ProjectName)$(TargetExt) + + + kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib + /ignore:4199 %(AdditionalOptions) + true + true + %(DelayLoadDLLs) + true + true + true + UseLinkTimeCodeGeneration + true + true + true + true + MachineX86 + + + .\mbus;%(AdditionalIncludeDirectories) + USING_UV_SHARED=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + + + + + + + + + + From 41a42e374d96652c0dcaba0b1281863214179fdb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Feb 2018 23:38:24 +0100 Subject: [PATCH 064/238] try --- libmbus.vcxproj | 5 +++++ mbus/mbus.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libmbus.vcxproj b/libmbus.vcxproj index 5e821d2d..5b67a89b 100644 --- a/libmbus.vcxproj +++ b/libmbus.vcxproj @@ -10,6 +10,11 @@ Win32 + + Release + Debug + Release + {B03220E0-285E-8766-5959-75355F21213E} Win32Proj diff --git a/mbus/mbus.c b/mbus/mbus.c index 0ff0f8ef..df584e92 100644 --- a/mbus/mbus.c +++ b/mbus/mbus.c @@ -9,8 +9,12 @@ //------------------------------------------------------------------------------ #include "mbus-protocol.h" -#include "../config.h" +#ifdef _WIN32 +#define VERSION "0.9.0" +#else +#include "../config.h" +#endif // // // From c459e5535279829019435a2581ee92aa43325448 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 01:21:58 +0100 Subject: [PATCH 065/238] update for win after several tests --- CMakeLists.txt | 18 ++++++++++++++ appveyor.yml | 7 ++++++ build.bat | 5 ++++ mbus/mbus-serial.c | 61 +++++++++++++++++++++++++++------------------- win/termiWin.c | 21 ++++++++-------- win/termiWin.h | 3 ++- 6 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 appveyor.yml create mode 100644 build.bat diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..bbe91d59 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 2.8) +project(libmbus) + +include_directories(./) + +add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) + +add_executable(mbus-serial-request-data mbus-serial-request-data.c) +target_link_libraries(mbus-serial-request-data mbus) + +add_executable(mbus-serial-scan-secondary mbus-serial-scan-secondary.c) +target_link_libraries(mbus-serial-scan-secondary mbus) + +add_executable(mbus-serial-scan mbus-serial-scan.c) +target_link_libraries(mbus-serial-scan mbus) + +add_executable(mbus-serial-select-secondary mbus-serial-select-secondary.c) +target_link_libraries(mbus-serial-select-secondary mbus) diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..1cd9732c --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,7 @@ +version: 'test-{build}' +platform: + - x86 + - x64 +clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' +test_script: + - echo %cd% diff --git a/build.bat b/build.bat new file mode 100644 index 00000000..f57d78ba --- /dev/null +++ b/build.bat @@ -0,0 +1,5 @@ +mkdir build +cd build +cmake .. -G "MinGW Makefiles" +mingw32-make +cd .. diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 4953c8f4..67100845 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -12,6 +12,9 @@ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) +#define MBUS_SERIAL_DEBUG + #ifdef _WIN32 #include #include @@ -31,6 +34,12 @@ typedef SSIZE_T ssize_t; #define O_NOCTTY 0x0000 // No idea if this makes sense +#define read(...) readFromSerial(__VA_ARGS__) +#define write(...) writeToSerial(__VA_ARGS__) +#define select(...) selectSerial(__VA_ARGS__) +#define open(...) openSerial(__VA_ARGS__) +#define close(...) closeSerial(__VA_ARGS__) + #else #include #include @@ -52,6 +61,7 @@ typedef SSIZE_T ssize_t; #define PACKET_BUFF_SIZE 2048 + //------------------------------------------------------------------------------ /// Set up a serial connection handle. //------------------------------------------------------------------------------ @@ -76,18 +86,10 @@ mbus_serial_connect(mbus_handle *handle) // // Use blocking read and handle it by serial port VMIN/VTIME setting - #ifdef _WIN32 - if ((handle->fd = openSerial(device, O_RDWR)) < 0) - #else if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) - #endif { - #ifdef _WIN32 - fprintf(stderr, "%s: failed to open tty. %d\n", __PRETTY_FUNCTION__, GetLastError()); - #else fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__ ); - #endif return -1; } @@ -112,7 +114,7 @@ mbus_serial_connect(mbus_handle *handle) // For 2400Bd this means (330 + 11) / 2400 + 0.15 = 292 ms (added 11 bit periods to receive first byte). // I.e. timeout of 0.3s seems appropriate for 2400Bd. - term->c_cc[VTIME] = (cc_t) 3; // Timeout in 1/10 sec + term->c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec cfsetispeed(term, B2400); cfsetospeed(term, B2400); @@ -165,7 +167,7 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) case 2400: speed = B2400; - serial_data->t.c_cc[VTIME] = (cc_t) 3; // Timeout in 1/10 sec + serial_data->t.c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec break; case 4800: @@ -225,11 +227,7 @@ mbus_serial_disconnect(mbus_handle *handle) return -1; } - #ifdef _WIN32 - closeSerial(handle->fd); - #else close(handle->fd); - #endif return 0; } @@ -269,8 +267,13 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) } // Make sure serial connection is open + #ifdef _WIN32 + if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) + #else if (isatty(handle->fd) == 0) + #endif { + MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); return -1; } @@ -291,11 +294,7 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) printf("\n"); #endif - #ifdef _WIN32 - if ((ret = writeToSerial(handle->fd, buff, len)) == len) - #else if ((ret = write(handle->fd, buff, len)) == len) - #endif { // // call the send event function, if the callback function is registered @@ -312,7 +311,9 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) // // wait until complete frame has been transmitted // + #ifndef _WIN32 tcdrain(handle->fd); + #endif return 0; } @@ -323,7 +324,7 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) int mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame) { - char buff[PACKET_BUFF_SIZE]; + unsigned char buff[PACKET_BUFF_SIZE]; int remaining, timeouts; ssize_t len, nread; @@ -334,7 +335,11 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame) } // Make sure serial connection is open + #ifdef _WIN32 + if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) + #else if (isatty(handle->fd) == 0) + #endif { fprintf(stderr, "%s: Serial connection is not available.\n", __PRETTY_FUNCTION__); return MBUS_RECV_RESULT_ERROR; @@ -356,20 +361,26 @@ mbus_serial_recv_frame(mbus_handle *handle, mbus_frame *frame) return MBUS_RECV_RESULT_ERROR; } - //printf("%s: Attempt to read %d bytes [len = %d]\n", __PRETTY_FUNCTION__, remaining, len); + #ifdef MBUS_SERIAL_DEBUG + printf("%s: Attempt to read %d bytes [len = %d]\n", __PRETTY_FUNCTION__, remaining, len); + #endif - #ifdef _WIN32 - if ((nread = readFromSerial(handle->fd, &buff[len], remaining)) == -1) - #else if ((nread = read(handle->fd, &buff[len], remaining)) == -1) - #endif { // fprintf(stderr, "%s: aborting recv frame (remaining = %d, len = %d, nread = %d)\n", // __PRETTY_FUNCTION__, remaining, len, nread); return MBUS_RECV_RESULT_ERROR; } -// printf("%s: Got %d byte [remaining %d, len %d]\n", __PRETTY_FUNCTION__, nread, remaining, len); + #ifdef MBUS_SERIAL_DEBUG + printf("%s: Got %d byte [remaining %d, len %d]\n", __PRETTY_FUNCTION__, nread, remaining, len); + int i; + for (i = len; i < len+nread; i++) + { + printf("%.2X ", buff[i]); + } + printf("\n"); + #endif if (nread == 0) { diff --git a/win/termiWin.c b/win/termiWin.c index 9235ef28..692eaadf 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -23,13 +23,6 @@ #include #include -/* -#define read readFromSerial -#define write writeToSerial -#define select selectSerial -#define open openSerial -#define close closeSerial -*/ typedef struct COM { @@ -135,7 +128,7 @@ int getToStop(tcflag_t flag) { int getCharSet(tcflag_t flag) { //FLAG IS MADE UP OF 8 BYTES, A FLAG IS MADE UP OF A NIBBLE -> 4 BITS, WE NEED TO EXTRACT THE SECOND NIBBLE (1st) FROM THE FIFTH BYTE (6th). - int byte = getByte(flag,5,1); + int byte = getByte(flag,1,1); switch(byte) { @@ -172,7 +165,7 @@ int getControlOptions(tcflag_t flag) { #define c_NOPARENB_CSTOPB 0x10 #define c_ALL_DISABLED 0x00 - int byte = getByte(flag,5,0); + int byte = getByte(flag,1,0); return byte; } @@ -429,7 +422,7 @@ void cfmakeraw(struct termios *termios_p) { SerialParams.ByteSize = 8; SerialParams.StopBits = ONESTOPBIT; - SerialParams.Parity = NOPARITY; + SerialParams.Parity = EVENPARITY; } @@ -531,6 +524,9 @@ int openSerial(char* portname, int opt) { strncpy(portname, portname + 3, 1); com.fd = atoi(portname); //COMx SerialParams.DCBlength = sizeof(SerialParams); + + if (!GetCommState(com.hComm, &SerialParams)) + return -1; return com.fd; } @@ -542,3 +538,8 @@ int closeSerial(int fd) { else return -1; } + +//Returns hComm from the COM structure +HANDLE getHandle() { + return com.hComm; +} diff --git a/win/termiWin.h b/win/termiWin.h index f29fb4a9..f09aee2a 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -178,7 +178,8 @@ int writeToSerial(int fd, char* buffer, int count); int openSerial(char* portname, int opt); int closeSerial(int fd); - +//get Handle out of the COM structure +HANDLE getHandle(); #endif From cf7c248ed54c9e847c7c87239ad43979489e5dd5 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:00:16 +0100 Subject: [PATCH 066/238] fix? --- mbus/mbus-serial.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 67100845..13e09412 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -34,12 +34,6 @@ typedef SSIZE_T ssize_t; #define O_NOCTTY 0x0000 // No idea if this makes sense -#define read(...) readFromSerial(__VA_ARGS__) -#define write(...) writeToSerial(__VA_ARGS__) -#define select(...) selectSerial(__VA_ARGS__) -#define open(...) openSerial(__VA_ARGS__) -#define close(...) closeSerial(__VA_ARGS__) - #else #include #include @@ -61,6 +55,13 @@ typedef SSIZE_T ssize_t; #define PACKET_BUFF_SIZE 2048 +#ifdef _WIN32 +#define read(...) readFromSerial(__VA_ARGS__) +#define write(...) writeToSerial(__VA_ARGS__) +#define select(...) selectSerial(__VA_ARGS__) +#define open(...) openSerial(__VA_ARGS__) +#define close(...) closeSerial(__VA_ARGS__) +#endif //------------------------------------------------------------------------------ /// Set up a serial connection handle. From cc27d2f44a196e97211bb9eef391c650bfa5c6ce Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:10:11 +0100 Subject: [PATCH 067/238] add both builds --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 1cd9732c..a5b2b0d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,6 +2,9 @@ version: 'test-{build}' platform: - x86 - x64 +configuration: + - Debug + - Release clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' test_script: - echo %cd% From 72e7a962bfbed1d2a14d22544e58afcb86f57af6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:14:12 +0100 Subject: [PATCH 068/238] try add x64 --- libmbus.vcxproj | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libmbus.vcxproj b/libmbus.vcxproj index 5b67a89b..7c0f5e7c 100644 --- a/libmbus.vcxproj +++ b/libmbus.vcxproj @@ -1,14 +1,22 @@ - - Debug - Win32 - - - Release - Win32 - + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + Release From 2706ebcf82393762e7ff47131ae2f9b586c18eeb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:25:10 +0100 Subject: [PATCH 069/238] try add 64 bit build --- mbus/mbus-protocol-aux.c | 3 +++ mbus/mbus-protocol.c | 4 ++++ mbus/mbus-serial.c | 4 ++++ mbus/mbus-tcp.c | 4 ++++ mbus/mbus.c | 4 ++++ win/termiWin.h | 10 +++++++++- 6 files changed, 28 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 69338e38..49522b1f 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -10,6 +10,9 @@ // Large parts of this file was contributed by Tomas Menzl. // //------------------------------------------------------------------------------ +#ifdef _WIN64 +#define _WIN32 +#endif #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index ea5dcbb8..449bffc7 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -8,6 +8,10 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN64 +#define _WIN32 +#endif + #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 13e09412..7473575d 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -8,6 +8,10 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN64 +#define _WIN32 +#endif + #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bb05f801..2b70281e 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,6 +8,10 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN64 +#define _WIN32 +#endif + #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus.c b/mbus/mbus.c index df584e92..bf04519b 100644 --- a/mbus/mbus.c +++ b/mbus/mbus.c @@ -10,6 +10,10 @@ #include "mbus-protocol.h" +#ifdef _WIN64 +#define _WIN32 +#endif + #ifdef _WIN32 #define VERSION "0.9.0" #else diff --git a/win/termiWin.h b/win/termiWin.h index f09aee2a..0d4461b5 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -23,13 +23,21 @@ #define TERMIWIN_H_ #endif +#ifdef _WIN64 +#define _WIN32 +#define WIN32_LEAN_AND_MEAN +#endif + #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #include +#ifdef _WIN64 +#pragma comment(lib, "Ws2_64.lib") +#else #pragma comment(lib, "Ws2_32.lib") - +#endif /*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ /* From d05ce7cbddfa336f6f2adf8dd376072b5ab8d19c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:31:35 +0100 Subject: [PATCH 070/238] try --- CMakeLists.txt | 6 ++++++ build.bat => cmake_build.bat | 0 mbus/mbus-serial.h | 2 +- win/termiWin.h | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) rename build.bat => cmake_build.bat (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe91d59..b3fa8956 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,3 +16,9 @@ target_link_libraries(mbus-serial-scan mbus) add_executable(mbus-serial-select-secondary mbus-serial-select-secondary.c) target_link_libraries(mbus-serial-select-secondary mbus) + +add_executable(mbus_parse mbus_parse.c) +target_link_libraries(mbus_parse.c mbus) + +add_executable(mbus_parse_hex mbus_parse_hex.c) +target_link_libraries(mbus_parse_hex.c mbus) diff --git a/build.bat b/cmake_build.bat similarity index 100% rename from build.bat rename to cmake_build.bat diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 22a462e7..29e47b2c 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -19,7 +19,7 @@ #define MBUS_SERIAL_H #ifdef _WIN32 -#include <../win/termiWin.h> +#include "../win/termiWin.h>" #include #include #else diff --git a/win/termiWin.h b/win/termiWin.h index 0d4461b5..e6f26eae 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -25,7 +25,7 @@ #ifdef _WIN64 #define _WIN32 -#define WIN32_LEAN_AND_MEAN +#define WIN64_LEAN_AND_MEAN #endif #ifdef _WIN32 From 72776da36657be732ea9af787407d682297b8379 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:33:36 +0100 Subject: [PATCH 071/238] fix --- mbus/mbus-protocol-aux.c | 4 ---- mbus/mbus-protocol.c | 4 ---- mbus/mbus-serial.c | 4 ---- mbus/mbus-serial.h | 2 +- mbus/mbus-tcp.c | 4 ---- mbus/mbus.c | 4 ---- win/termiWin.h | 1 - 7 files changed, 1 insertion(+), 22 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 49522b1f..ccfaeb16 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -10,10 +10,6 @@ // Large parts of this file was contributed by Tomas Menzl. // //------------------------------------------------------------------------------ -#ifdef _WIN64 -#define _WIN32 -#endif - #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 449bffc7..ea5dcbb8 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -8,10 +8,6 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN64 -#define _WIN32 -#endif - #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 7473575d..13e09412 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -8,10 +8,6 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN64 -#define _WIN32 -#endif - #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 29e47b2c..b0c2691b 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -19,7 +19,7 @@ #define MBUS_SERIAL_H #ifdef _WIN32 -#include "../win/termiWin.h>" +#include "../win/termiWin.h" #include #include #else diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 2b70281e..bb05f801 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,10 +8,6 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN64 -#define _WIN32 -#endif - #ifdef _WIN32 #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus.c b/mbus/mbus.c index bf04519b..df584e92 100644 --- a/mbus/mbus.c +++ b/mbus/mbus.c @@ -10,10 +10,6 @@ #include "mbus-protocol.h" -#ifdef _WIN64 -#define _WIN32 -#endif - #ifdef _WIN32 #define VERSION "0.9.0" #else diff --git a/win/termiWin.h b/win/termiWin.h index e6f26eae..7f9de3e6 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -24,7 +24,6 @@ #endif #ifdef _WIN64 -#define _WIN32 #define WIN64_LEAN_AND_MEAN #endif From f0c7ac20f8799107d40663937f2dbb2777f114c5 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:41:00 +0100 Subject: [PATCH 072/238] try --- libmbus.vcxproj | 98 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 95 insertions(+), 3 deletions(-) diff --git a/libmbus.vcxproj b/libmbus.vcxproj index 7c0f5e7c..094e9c1c 100644 --- a/libmbus.vcxproj +++ b/libmbus.vcxproj @@ -21,7 +21,6 @@ Release Debug - Release {B03220E0-285E-8766-5959-75355F21213E} @@ -49,6 +48,8 @@ $(Configuration)\obj\$(ProjectName)\ false true + false + true $(SolutionDir)$(Configuration)\ $(ProjectName) $(OutDir)\$(ProjectName)$(TargetExt) @@ -77,7 +78,7 @@ $(OutDir)$(ProjectName)$(TargetExt) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib + /ignore:4199 %(AdditionalOptions) true true @@ -124,7 +125,7 @@ $(OutDir)$(ProjectName)$(TargetExt) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;DelayImp.lib + /ignore:4199 %(AdditionalOptions) true true @@ -144,6 +145,97 @@ USING_UV_SHARED=1;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + .\mbus;%(AdditionalIncludeDirectories) + EnableFastChecks + true + false + ProgramDatabase + 4267;4351;4355;4800;4251;%(DisableSpecificWarnings) + false + false + false + Disabled + NotUsing + USING_UV_SHARED=1;WIN64;WIN32;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;DEBUG;_DEBUG;%(PreprocessorDefinitions) + MultiThreadedDebug + true + true + false + Level3 + + + $(OutDir)$(ProjectName)$(TargetExt) + + + + /ignore:4199 %(AdditionalOptions) + true + true + %(DelayLoadDLLs) + true + true + true + true + true + MachineX86 + + + .\mbus;%(AdditionalIncludeDirectories) + USING_UV_SHARED=1;WIN32;WIN64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;DEBUG;_DEBUG;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + + + + .\mbus;%(AdditionalIncludeDirectories) + /MP %(AdditionalOptions) + true + false + ProgramDatabase + 4267;4351;4355;4800;4251;%(DisableSpecificWarnings) + false + Speed + true + AnySuitable + true + true + Full + NotUsing + USING_UV_SHARED=1;WIN32;WIN64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions) + MultiThreaded + false + true + true + false + Level3 + true + + + /LTCG %(AdditionalOptions) + $(OutDir)$(ProjectName)$(TargetExt) + + + + /ignore:4199 %(AdditionalOptions) + true + true + %(DelayLoadDLLs) + true + true + true + UseLinkTimeCodeGeneration + true + true + true + true + MachineX86 + + + .\mbus;%(AdditionalIncludeDirectories) + USING_UV_SHARED=1;WIN32;WIN64;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions);%(PreprocessorDefinitions) + + From e9acb61a179a29644890d33a1b1d6c4a70150efa Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:43:48 +0100 Subject: [PATCH 073/238] try adding tests --- Makefile-static | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile-static b/Makefile-static index 93da7516..40308ad3 100644 --- a/Makefile-static +++ b/Makefile-static @@ -18,7 +18,7 @@ clean: rm -rf *.o *core core $(LIB) test: - (cd test && make) + (cd test && make && ./generate_xml.sh test-frames) install: all cp $(LIB) /usr/local/freescada/lib From 52847fbf55cb07693021d7862c9e4b618e0d6d4a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:45:26 +0100 Subject: [PATCH 074/238] fix --- libmbus.vcxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmbus.vcxproj b/libmbus.vcxproj index 094e9c1c..8b489f02 100644 --- a/libmbus.vcxproj +++ b/libmbus.vcxproj @@ -48,7 +48,7 @@ $(Configuration)\obj\$(ProjectName)\ false true - false + false true $(SolutionDir)$(Configuration)\ $(ProjectName) From d9b358cdd9c043b2165d2ef18f7d5ed2a3357f86 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 11:56:39 +0100 Subject: [PATCH 075/238] try cmake build --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index a5b2b0d4..1d30dc0c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,8 @@ platform: configuration: - Debug - Release +install: + - cmake_build.bat clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' test_script: - echo %cd% From e41b18759b7a388c472c60718db9b3fa8ed91302 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 4 Mar 2018 12:12:00 +0100 Subject: [PATCH 076/238] only serial log when debug build --- mbus/mbus-serial.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 13e09412..a747eaff 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -13,7 +13,9 @@ #endif #define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) +#ifdef DEBUG #define MBUS_SERIAL_DEBUG +#endif #ifdef _WIN32 #include From f6ba013d814cde2c10de1c180eb757f7c601161a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 00:04:08 +0100 Subject: [PATCH 077/238] ry appbveyort cmake build --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 1d30dc0c..90422b7f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,8 @@ configuration: - Debug - Release install: + - set PATH=%PATH:C:\Program Files (x86)\Git\bin;=% + - set PATH=C:\MinGW\bin;%PATH% - cmake_build.bat clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' test_script: From 05641b51549a73fd6b6bbd8f71a484976c879889 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 00:10:49 +0100 Subject: [PATCH 078/238] another try --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 90422b7f..4d1ca52f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,8 +6,8 @@ configuration: - Debug - Release install: - - set PATH=%PATH:C:\Program Files (x86)\Git\bin;=% - set PATH=C:\MinGW\bin;%PATH% + - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% - cmake_build.bat clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' test_script: From cedb07899d90f12668101120885db7c2dbe92823 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 10:35:34 +0100 Subject: [PATCH 079/238] fix cmake config --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b3fa8956..a596be70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ add_executable(mbus-serial-select-secondary mbus-serial-select-secondary.c) target_link_libraries(mbus-serial-select-secondary mbus) add_executable(mbus_parse mbus_parse.c) -target_link_libraries(mbus_parse.c mbus) +target_link_libraries(mbus_parse mbus) add_executable(mbus_parse_hex mbus_parse_hex.c) -target_link_libraries(mbus_parse_hex.c mbus) +target_link_libraries(mbus_parse_hex mbus) From 49684c3fb4d9797be158be68d8ebaa1874a114d6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 12:27:17 +0100 Subject: [PATCH 080/238] try fix cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a596be70..d778164a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -include_directories(./) +include_directories(../) add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) From 110afec8ca2706dfde3f417b2683abfb179ae99a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 12:53:03 +0100 Subject: [PATCH 081/238] try fix cmake and correct pathss --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d778164a..cff3cd61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -include_directories(../) +include_directories(../mbus ../test ../win) add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) From bf7ca0536eb43a1cd19f48e16bb71bfd62293318 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 12:56:49 +0100 Subject: [PATCH 082/238] again try cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cff3cd61..d6f26c32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -include_directories(../mbus ../test ../win) +include_directories(../mbus ../test ../win ./mbus ./test ./win) add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) From 78172f528d1da8a0c21955b4039604ea811e1b1a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 15:25:53 +0100 Subject: [PATCH 083/238] try cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6f26c32..42248e8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -include_directories(../mbus ../test ../win ./mbus ./test ./win) +include_directories(../mbus/ ../test/ ../win/ ./mbus/ ./test/ ./win/) add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) From 15cc951c24206d7086084c296d889eca49fac5ee Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 16:03:13 +0100 Subject: [PATCH 084/238] try cmake --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42248e8d..63b354fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,24 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -include_directories(../mbus/ ../test/ ../win/ ./mbus/ ./test/ ./win/) +include_directories(../mbus/ ../test/ ../win/) -add_library(mbus SHARED mbus.c mbus-protocol.c mbus-protocol-aux.c mbus-serial.c mbus-tcp.c termiWin.c) +add_library(mbus SHARED ../mbus/mbus.c ../mbus/mbus-protocol.c ../mbus/mbus-protocol-aux.c ../mbus/mbus-serial.c ../mbus/mbus-tcp.c ../win/termiWin.c) -add_executable(mbus-serial-request-data mbus-serial-request-data.c) +add_executable(mbus-serial-request-data ../bin/mbus-serial-request-data.c) target_link_libraries(mbus-serial-request-data mbus) -add_executable(mbus-serial-scan-secondary mbus-serial-scan-secondary.c) +add_executable(mbus-serial-scan-secondary ../bin/mbus-serial-scan-secondary.c) target_link_libraries(mbus-serial-scan-secondary mbus) -add_executable(mbus-serial-scan mbus-serial-scan.c) +add_executable(mbus-serial-scan ../bin/mbus-serial-scan.c) target_link_libraries(mbus-serial-scan mbus) -add_executable(mbus-serial-select-secondary mbus-serial-select-secondary.c) +add_executable(mbus-serial-select-secondary ../bin/mbus-serial-select-secondary.c) target_link_libraries(mbus-serial-select-secondary mbus) -add_executable(mbus_parse mbus_parse.c) +add_executable(mbus_parse ../test/mbus_parse.c) target_link_libraries(mbus_parse mbus) -add_executable(mbus_parse_hex mbus_parse_hex.c) +add_executable(mbus_parse_hex ../test/mbus_parse_hex.c) target_link_libraries(mbus_parse_hex mbus) From 55bd7c2f0cc68c1c8772018ce0899752097c9b16 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 16:43:04 +0100 Subject: [PATCH 085/238] add WIN32 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63b354fc..571f7f7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) +add_definitions(-DWIN32) + include_directories(../mbus/ ../test/ ../win/) add_library(mbus SHARED ../mbus/mbus.c ../mbus/mbus-protocol.c ../mbus/mbus-protocol-aux.c ../mbus/mbus-serial.c ../mbus/mbus-tcp.c ../win/termiWin.c) From dd3bfa13b8b59f7ee1f651aeaa1270fcd71fe1ac Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 16:46:44 +0100 Subject: [PATCH 086/238] change --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 571f7f7a..b2175e69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -add_definitions(-DWIN32) +add_definitions(-DWIN32) include_directories(../mbus/ ../test/ ../win/) From 66007fd2a2d415a97e3f70a5bc0df1c4015e0cf4 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 17:02:03 +0100 Subject: [PATCH 087/238] change --- mbus/mbus-protocol-aux.c | 2 +- mbus/mbus-protocol.c | 2 +- mbus/mbus-serial.c | 2 +- mbus/mbus-tcp.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ccfaeb16..fefaa254 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -10,7 +10,7 @@ // Large parts of this file was contributed by Tomas Menzl. // //------------------------------------------------------------------------------ -#ifdef _WIN32 +#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index ea5dcbb8..8079a2e3 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN32 +#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index a747eaff..ae5c5ff3 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN32 +#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bb05f801..0bffcaeb 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -#ifdef _WIN32 +#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif From 31f5948be5763b3c27258f8665b93bfdfe4e8a58 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 17:11:45 +0100 Subject: [PATCH 088/238] fix --- CMakeLists.txt | 2 +- mbus/mbus-protocol-aux.c | 2 ++ mbus/mbus-protocol.c | 2 ++ mbus/mbus-serial.c | 2 ++ mbus/mbus-tcp.c | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2175e69..ea99b608 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -add_definitions(-DWIN32) +add_definitions(-DWIN32 -D_WIN32) include_directories(../mbus/ ../test/ ../win/) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index fefaa254..abff2aaf 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -10,9 +10,11 @@ // Large parts of this file was contributed by Tomas Menzl. // //------------------------------------------------------------------------------ +#ifdef _WIN32 #ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#endif #include "mbus-protocol-aux.h" #include "mbus-serial.h" diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 8079a2e3..5e36fe36 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -8,9 +8,11 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 #ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#endif #include diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index ae5c5ff3..56e2ce13 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -8,9 +8,11 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 #ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#endif #define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) #ifdef DEBUG diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 0bffcaeb..17dbe12d 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -8,9 +8,11 @@ // //------------------------------------------------------------------------------ +#ifdef _WIN32 #ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif +#endif #ifdef _WIN32 #include From f82c72d738b1e8c76ebf1d44dfd1f1aa051e9ddb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 17:15:40 +0100 Subject: [PATCH 089/238] trx --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea99b608..2d66ec41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -add_definitions(-DWIN32 -D_WIN32) +add_definitions(-DWIN32 -D_WIN32 -d__FUNCSIG__=not-available) include_directories(../mbus/ ../test/ ../win/) From 526d06c6216827718310ef602656ee7117ebd66b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 17:50:46 +0100 Subject: [PATCH 090/238] fix --- win/termiWin.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/win/termiWin.h b/win/termiWin.h index 7f9de3e6..bf074ff8 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -32,11 +32,8 @@ #define WIN32_LEAN_AND_MEAN #include #include -#ifdef _WIN64 -#pragma comment(lib, "Ws2_64.lib") -#else #pragma comment(lib, "Ws2_32.lib") -#endif + /*Redefining functions from winsock to termiWin. This is very important since winsock2 defines functions such as close as closesocket we have to redefine it*/ /* From 68144ee37a63c2a48d9b9abab0d8349042959c16 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 17:53:25 +0100 Subject: [PATCH 091/238] fix cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d66ec41..53866943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(libmbus) -add_definitions(-DWIN32 -D_WIN32 -d__FUNCSIG__=not-available) +add_definitions(-DWIN32 -D_WIN32 -D__FUNCSIG__="not-available") include_directories(../mbus/ ../test/ ../win/) From 8b28488738bba470ad4426d47e5b317d3a12e59f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 18:23:14 +0100 Subject: [PATCH 092/238] finalize --- CMakeLists.txt | 26 -------------------------- cmake_build.bat | 5 ----- mbus/mbus-protocol-aux.c | 2 -- mbus/mbus-protocol.c | 2 -- mbus/mbus-serial.c | 2 -- mbus/mbus-tcp.c | 2 -- win/termiWin.h | 1 - 7 files changed, 40 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 cmake_build.bat diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 53866943..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(libmbus) - -add_definitions(-DWIN32 -D_WIN32 -D__FUNCSIG__="not-available") - -include_directories(../mbus/ ../test/ ../win/) - -add_library(mbus SHARED ../mbus/mbus.c ../mbus/mbus-protocol.c ../mbus/mbus-protocol-aux.c ../mbus/mbus-serial.c ../mbus/mbus-tcp.c ../win/termiWin.c) - -add_executable(mbus-serial-request-data ../bin/mbus-serial-request-data.c) -target_link_libraries(mbus-serial-request-data mbus) - -add_executable(mbus-serial-scan-secondary ../bin/mbus-serial-scan-secondary.c) -target_link_libraries(mbus-serial-scan-secondary mbus) - -add_executable(mbus-serial-scan ../bin/mbus-serial-scan.c) -target_link_libraries(mbus-serial-scan mbus) - -add_executable(mbus-serial-select-secondary ../bin/mbus-serial-select-secondary.c) -target_link_libraries(mbus-serial-select-secondary mbus) - -add_executable(mbus_parse ../test/mbus_parse.c) -target_link_libraries(mbus_parse mbus) - -add_executable(mbus_parse_hex ../test/mbus_parse_hex.c) -target_link_libraries(mbus_parse_hex mbus) diff --git a/cmake_build.bat b/cmake_build.bat deleted file mode 100644 index f57d78ba..00000000 --- a/cmake_build.bat +++ /dev/null @@ -1,5 +0,0 @@ -mkdir build -cd build -cmake .. -G "MinGW Makefiles" -mingw32-make -cd .. diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index abff2aaf..ccfaeb16 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -11,10 +11,8 @@ // //------------------------------------------------------------------------------ #ifdef _WIN32 -#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif -#endif #include "mbus-protocol-aux.h" #include "mbus-serial.h" diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 5e36fe36..ea5dcbb8 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -9,10 +9,8 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif -#endif #include diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 56e2ce13..a747eaff 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -9,10 +9,8 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif -#endif #define MBUS_ERROR(...) fprintf (stderr, __VA_ARGS__) #ifdef DEBUG diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 17dbe12d..bb05f801 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -9,10 +9,8 @@ //------------------------------------------------------------------------------ #ifdef _WIN32 -#ifndef __PRETTY_FUNCTION__ #define __PRETTY_FUNCTION__ __FUNCSIG__ #endif -#endif #ifdef _WIN32 #include diff --git a/win/termiWin.h b/win/termiWin.h index bf074ff8..d27eb4e7 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -28,7 +28,6 @@ #endif #ifdef _WIN32 - #define WIN32_LEAN_AND_MEAN #include #include From eee82a4a9e98f78936bc4ae78e9ef4666b77f50c Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 18:23:45 +0100 Subject: [PATCH 093/238] finalize --- appveyor.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 4d1ca52f..a5b2b0d4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,10 +5,6 @@ platform: configuration: - Debug - Release -install: - - set PATH=C:\MinGW\bin;%PATH% - - set PATH=%PATH:C:\Program Files\Git\usr\bin;=% - - cmake_build.bat clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' test_script: - echo %cd% From ce6b9851a62e5f96ecfddee2eb228957d4d0466b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 22:20:24 +0100 Subject: [PATCH 094/238] add windows status --- WINDOWS_TOTO.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 WINDOWS_TOTO.md diff --git a/WINDOWS_TOTO.md b/WINDOWS_TOTO.md new file mode 100644 index 00000000..004a5eec --- /dev/null +++ b/WINDOWS_TOTO.md @@ -0,0 +1,9 @@ +# Status Windows Build + +## What's working +* Build mbus library including tcp and serial support on Windows using Visual Studio in 32bit and 64bit + +## Todo +* add correct build configuration (complete vcxproj file?) +* check all binaries for needed changes for windows Build +* implement test shellscript as bat file for Windows From 1eb631644e97bfb5a8658c1378501ece8158c557 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 22:21:30 +0100 Subject: [PATCH 095/238] fix --- WINDOWS_TOTO.md => WINDOWS_TODO.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename WINDOWS_TOTO.md => WINDOWS_TODO.md (100%) diff --git a/WINDOWS_TOTO.md b/WINDOWS_TODO.md similarity index 100% rename from WINDOWS_TOTO.md rename to WINDOWS_TODO.md From ed3dada467463d7939627bb9de4f7ec3c4510ba6 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 23:34:30 +0100 Subject: [PATCH 096/238] fixes --- mbus/mbus-protocol-aux.c | 100 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ccfaeb16..88e50476 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -157,17 +157,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ - { 0x58, 1.0e-3, "�C", "Flow temperature" }, - { 0x59, 1.0e-2, "�C", "Flow temperature" }, - { 0x5A, 1.0e-1, "�C", "Flow temperature" }, - { 0x5B, 1.0e0, "�C", "Flow temperature" }, - - /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ - { 0x5C, 1.0e-3, "�C", "Return temperature" }, - { 0x5D, 1.0e-2, "�C", "Return temperature" }, - { 0x5E, 1.0e-1, "�C", "Return temperature" }, - { 0x5F, 1.0e0, "�C", "Return temperature" }, + /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ + { 0x58, 1.0e-3, "°C", "Flow temperature" }, + { 0x59, 1.0e-2, "°C", "Flow temperature" }, + { 0x5A, 1.0e-1, "°C", "Flow temperature" }, + { 0x5B, 1.0e0, "°C", "Flow temperature" }, + + /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ + { 0x5C, 1.0e-3, "°C", "Return temperature" }, + { 0x5D, 1.0e-2, "°C", "Return temperature" }, + { 0x5E, 1.0e-1, "°C", "Return temperature" }, + { 0x5F, 1.0e0, "°C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -175,11 +175,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature �C (0.001�C to 1�C) */ - { 0x64, 1.0e-3, "�C", "External temperature" }, - { 0x65, 1.0e-2, "�C", "External temperature" }, - { 0x66, 1.0e-1, "�C", "External temperature" }, - { 0x67, 1.0e0, "�C", "External temperature" }, + /* E110 01nn External Temperature °C (0.001°C to 1°C) */ + { 0x64, 1.0e-3, "°C", "External temperature" }, + { 0x65, 1.0e-2, "°C", "External temperature" }, + { 0x66, 1.0e-1, "°C", "External temperature" }, + { 0x67, 1.0e0, "°C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -611,29 +611,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x258, 1.0e-3, "�F", "Flow temperature" }, - { 0x259, 1.0e-2, "�F", "Flow temperature" }, - { 0x25A, 1.0e-1, "�F", "Flow temperature" }, - { 0x25B, 1.0e0, "�F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x25C, 1.0e-3, "�F", "Return temperature" }, - { 0x25D, 1.0e-2, "�F", "Return temperature" }, - { 0x25E, 1.0e-1, "�F", "Return temperature" }, - { 0x25F, 1.0e0, "�F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ - { 0x260, 1.0e-3, "�F", "Temperature difference" }, - { 0x261, 1.0e-2, "�F", "Temperature difference" }, - { 0x262, 1.0e-1, "�F", "Temperature difference" }, - { 0x263, 1.0e0, "�F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x264, 1.0e-3, "�F", "External temperature" }, - { 0x265, 1.0e-2, "�F", "External temperature" }, - { 0x266, 1.0e-1, "�F", "External temperature" }, - { 0x267, 1.0e0, "�F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x258, 1.0e-3, "°F", "Flow temperature" }, + { 0x259, 1.0e-2, "°F", "Flow temperature" }, + { 0x25A, 1.0e-1, "°F", "Flow temperature" }, + { 0x25B, 1.0e0, "°F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x25C, 1.0e-3, "°F", "Return temperature" }, + { 0x25D, 1.0e-2, "°F", "Return temperature" }, + { 0x25E, 1.0e-1, "°F", "Return temperature" }, + { 0x25F, 1.0e0, "°F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ + { 0x260, 1.0e-3, "°F", "Temperature difference" }, + { 0x261, 1.0e-2, "°F", "Temperature difference" }, + { 0x262, 1.0e-1, "°F", "Temperature difference" }, + { 0x263, 1.0e0, "°F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x264, 1.0e-3, "°F", "External temperature" }, + { 0x265, 1.0e-2, "°F", "External temperature" }, + { 0x266, 1.0e-1, "°F", "External temperature" }, + { 0x267, 1.0e0, "°F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -645,17 +645,17 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ - { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ + { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ - { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ + { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, @@ -733,7 +733,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "�C", "Temperature" }, + { 0x38, 1.0e-3, "°C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, From 71adabe65a4b6d658ab3c6b101f0a6f672fb87d8 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 5 Mar 2018 23:35:47 +0100 Subject: [PATCH 097/238] fix --- mbus/mbus-serial.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index a747eaff..578e8db3 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -91,8 +91,7 @@ mbus_serial_connect(mbus_handle *handle) // Use blocking read and handle it by serial port VMIN/VTIME setting if ((handle->fd = open(device, O_RDWR | O_NOCTTY)) < 0) { - fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__ - ); + fprintf(stderr, "%s: failed to open tty.\n", __PRETTY_FUNCTION__); return -1; } From 06cdd2788ee9f09e0416021f72869cb291703823 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 6 Mar 2018 11:34:29 +0100 Subject: [PATCH 098/238] adopt serial timeouts to @devicehubnet values from field tests --- mbus/mbus-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 578e8db3..319de116 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -179,7 +179,7 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) case 9600: speed = B9600; - serial_data->t.c_cc[VTIME] = (cc_t) 2; // Timeout in 1/10 sec + serial_data->t.c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec break; case 19200: From 21d5c81ab2925cc65b76864131f4a37373f3db44 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Fri, 9 Mar 2018 13:43:49 +0100 Subject: [PATCH 099/238] try overlapping --- win/termiWin.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/win/termiWin.c b/win/termiWin.c index 692eaadf..edfde31a 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -507,17 +507,16 @@ int openSerial(char* portname, int opt) { switch (opt) { case O_RDWR: - com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); break; case O_RDONLY: - com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); + com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); break; case O_WRONLY: - com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); break; - } if (com.hComm == INVALID_HANDLE_VALUE) return -1; From d03fd7512f3fcbe94a77ef1fb794b04986d89683 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Fri, 9 Mar 2018 13:46:45 +0100 Subject: [PATCH 100/238] try --- win/termiWin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/win/termiWin.c b/win/termiWin.c index edfde31a..7da4ba87 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -507,15 +507,15 @@ int openSerial(char* portname, int opt) { switch (opt) { case O_RDWR: - com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); + com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); break; case O_RDONLY: - com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); + com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); break; case O_WRONLY: - com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, FILE_FLAG_OVERLAPPED); + com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); break; } From 958273240cd1bb565336cbff2c49c188d44cfcbb Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:13:25 +0100 Subject: [PATCH 101/238] try changes to avoid _WIN32 --- mbus/mbus-serial.c | 2 -- win/termiWin.c | 14 +++++++++----- win/termiWin.h | 2 ++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 319de116..c08aac21 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -313,9 +313,7 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) // // wait until complete frame has been transmitted // - #ifndef _WIN32 tcdrain(handle->fd); - #endif return 0; } diff --git a/win/termiWin.c b/win/termiWin.c index 7da4ba87..342ce679 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -345,11 +345,7 @@ int tcsendbreak(int fd, int duration) { int tcdrain(int fd) { if(fd != com.fd) return -1; - SetCommMask(com.hComm, EV_TXEMPTY); - DWORD dwEventMask; - WaitCommEvent(com.hComm, &dwEventMask, NULL); - - return 0; + return FlushFileBuffers(com.hComm); } @@ -542,3 +538,11 @@ int closeSerial(int fd) { HANDLE getHandle() { return com.hComm; } + +int isatty(int fd) { + + if(fd != com.fd) return -1; + if (GetFileType(com.hComm) != FILE_TYPE_CHAR ) return 0; + else return -1; + +} diff --git a/win/termiWin.h b/win/termiWin.h index d27eb4e7..ba93478d 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -184,6 +184,8 @@ int closeSerial(int fd); //get Handle out of the COM structure HANDLE getHandle(); +int isatty(int fd); + #endif #ifndef _WIN32 From 08a913dbd459e5eaf9ba325ab039f3c2d601dea9 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:14:45 +0100 Subject: [PATCH 102/238] se isatty --- mbus/mbus-serial.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index c08aac21..296def13 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -269,11 +269,7 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) } // Make sure serial connection is open - #ifdef _WIN32 - if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) - #else if (isatty(handle->fd) == 0) - #endif { MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); return -1; From 7996ad72430036ffbd4bef34732187d45f8b0307 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:32:29 +0100 Subject: [PATCH 103/238] try --- mbus/mbus-serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 296def13..b8bdbe98 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -18,8 +18,8 @@ #endif #ifdef _WIN32 -#include -#include +//#include +//#include #include #include From 9b10f42815fc98a3a81dd3257770ae2bbd8c2ff3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:42:00 +0100 Subject: [PATCH 104/238] try --- mbus/mbus-serial.c | 2 ++ mbus/mbus-serial.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index b8bdbe98..6f4c64a1 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -47,7 +47,9 @@ typedef SSIZE_T ssize_t; #include +#ifndef _WIN32 #include +#endif #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index b0c2691b..634f5c02 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,8 +20,8 @@ #ifdef _WIN32 #include "../win/termiWin.h" -#include -#include +//#include +//#include #else #include #endif From 4c6b789726a2b32473d678e0d88bab0a02069217 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:44:56 +0100 Subject: [PATCH 105/238] try --- mbus/mbus-serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 634f5c02..de1879da 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,7 +20,7 @@ #ifdef _WIN32 #include "../win/termiWin.h" -//#include +#include //#include #else #include From 99d246b4b261c280ed76e65792a8a862629bcb5a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:46:14 +0100 Subject: [PATCH 106/238] try --- mbus/mbus-serial.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index de1879da..01127b6d 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,8 +20,8 @@ #ifdef _WIN32 #include "../win/termiWin.h" -#include -//#include +//#include +#include #else #include #endif From 1899f0951eefcc8f12c40f5b3915e24d5486d8bf Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:47:43 +0100 Subject: [PATCH 107/238] try --- mbus/mbus-serial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 01127b6d..b0c2691b 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,7 +20,7 @@ #ifdef _WIN32 #include "../win/termiWin.h" -//#include +#include #include #else #include From 7936f8600b02bec1fa59ab11e4f20de8cabfbb3f Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 22:51:23 +0100 Subject: [PATCH 108/238] try --- mbus/mbus-serial.c | 2 -- mbus/mbus-serial.h | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 6f4c64a1..b8bdbe98 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -47,9 +47,7 @@ typedef SSIZE_T ssize_t; #include -#ifndef _WIN32 #include -#endif #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index b0c2691b..634f5c02 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,8 +20,8 @@ #ifdef _WIN32 #include "../win/termiWin.h" -#include -#include +//#include +//#include #else #include #endif From 5d76c2fb5ebdd83ef8f10eedc5f9fb198be19ee2 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 23:01:41 +0100 Subject: [PATCH 109/238] finalize --- mbus/mbus-serial.c | 2 -- mbus/mbus-serial.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index b8bdbe98..06ab2d29 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -18,8 +18,6 @@ #endif #ifdef _WIN32 -//#include -//#include #include #include diff --git a/mbus/mbus-serial.h b/mbus/mbus-serial.h index 634f5c02..774dd62b 100755 --- a/mbus/mbus-serial.h +++ b/mbus/mbus-serial.h @@ -20,8 +20,6 @@ #ifdef _WIN32 #include "../win/termiWin.h" -//#include -//#include #else #include #endif From 0c79250a607e89cf193a68077783eb61c92656b4 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 10 Mar 2018 23:02:32 +0100 Subject: [PATCH 110/238] sync --- win/termiWin.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/win/termiWin.c b/win/termiWin.c index 342ce679..2c2604c1 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -59,7 +59,7 @@ int getIXOptions(tcflag_t flag) { #define i_PARMRK_IXON 0x06 #define i_PARMRK_IXON_IXOFF 0x07 - int byte = getByte(flag,4,1); + int byte = getByte(flag,1,1); return byte; @@ -86,7 +86,7 @@ int getEchoOptions(tcflag_t flag) { #define l_ECHOK_ECHONL 0x0c #define l_ECHONL 0x08 - int byte = getByte(flag,5,1); + int byte = getByte(flag,1,1); return byte; } @@ -109,7 +109,7 @@ int getLocalOptions(tcflag_t flag) { #define l_IEXTEN_NOFLSH 0xa0 #define l_NOFLSH 0x80 - int byte = getByte(flag,5,0); + int byte = getByte(flag,1,0); return byte; } @@ -118,7 +118,7 @@ int getToStop(tcflag_t flag) { #define l_TOSTOP 0x01 - int byte = getByte(flag,4,1); + int byte = getByte(flag,1,1); return byte; } From 29a9e5ac613da61e34e7ade0076b08b9e00329d2 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 11 Mar 2018 21:25:14 +0100 Subject: [PATCH 111/238] make timestamps all ISO conform by adding "Z" at the end --- mbus/mbus-protocol.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 35789223..a3ce536e 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3739,7 +3739,7 @@ mbus_hex_dump(const char *label, const char *buff, size_t len) { time_t rawtime; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; size_t i; if (label == NULL || buff == NULL) @@ -3748,7 +3748,7 @@ mbus_hex_dump(const char *label, const char *buff, size_t len) time ( &rawtime ); timeinfo = gmtime ( &rawtime ); - strftime(timestamp,20,"%Y-%m-%d %H:%M:%S",timeinfo); + strftime(timestamp,21,"%Y-%m-%d %H:%M:%SZ",timeinfo); fprintf(stderr, "[%s] %s (%03zu):", timestamp, label, len); for (i = 0; i < len; i++) @@ -3880,7 +3880,7 @@ mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int fra char str_encoded[768]; size_t len = 0; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; long tariff; if (record) @@ -3936,7 +3936,7 @@ mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int fra if (record->timestamp > 0) { timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,20,"%Y-%m-%dT%H:%M:%SZ",timeinfo); + strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" len += snprintf(&buff[len], sizeof(buff) - len, "\"Timestamp\":\"%s\"", timestamp); @@ -4399,7 +4399,7 @@ mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int fram char str_encoded[768]; size_t len = 0; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; long tariff; if (record) @@ -4455,7 +4455,7 @@ mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int fram if (record->timestamp > 0) { timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,20,"%Y-%m-%dT%H:%M:%S",timeinfo); + strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); len += snprintf(&buff[len], sizeof(buff) - len, " %s\n", timestamp); } From 75bc499f33a002d87c3b1845f24c8c3528051677 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:26:03 +0100 Subject: [PATCH 112/238] remove json functions again --- configure.ac | 4 +- mbus/mbus-protocol.c | 512 ------------------------------------------- mbus/mbus-protocol.h | 14 -- 3 files changed, 2 insertions(+), 528 deletions(-) diff --git a/configure.ac b/configure.ac index 37968448..edd30c2d 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ dnl ---------------------------------------------------------------------------- LT_CONFIG_LTDL_DIR([libltdl]) -AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) @@ -18,7 +18,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AM_PROG_LIBTOOL -LDFLAGS="$LDFLAGS -version-info 0:9:0" +LDFLAGS="$LDFLAGS -version-info 0:8:0" dnl ---------------------- dnl diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index a3ce536e..94773cd8 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3767,518 +3767,6 @@ mbus_data_error_print(int error) return -1; } -//------------------------------------------------------------------------------ -// -// JSON RELATED FUNCTIONS -// -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// -/// Encode string to JSON -/// -//------------------------------------------------------------------------------ -int -mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len) -{ - size_t i, len; - - i = 0; - len = 0; - - if (dst == NULL) - { - return -1; - } - - if (src == NULL) - { - dst[len] = '\0'; - return -2; - } - - while((len+6) < max_len) - { - if (src[i] == '\0') - { - break; - } - - if (iscntrl(src[i])) - { - // convert all control chars into spaces - dst[len++] = ' '; - } - else - { - switch (src[i]) - { - case '"': - len += snprintf(&dst[len], max_len - len, "\\\""); - break; - default: - dst[len++] = src[i]; - break; - } - } - - i++; - } - - dst[len] = '\0'; - return 0; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for the variable-length data header -//------------------------------------------------------------------------------ -char * -mbus_data_variable_header_json(mbus_data_variable_header *header) -{ - static char buff[8192]; - char str_encoded[768]; - size_t len = 0; - int val; - - if (header) - { - len += snprintf(&buff[len], sizeof(buff) - len, "\"SlaveInformation\":{"); - - val = (int)mbus_data_bcd_decode(header->id_bcd, 4); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"Id\":%d,", val); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Manufacturer\":\"%s\",", - mbus_decode_manufacturer(header->manufacturer[0], header->manufacturer[1])); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Version\":%d,", header->version); - - mbus_str_json_encode(str_encoded, mbus_data_product_name(header), sizeof(str_encoded)); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"ProductName\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_variable_medium_lookup(header->medium), sizeof(str_encoded)); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"Medium\":\"%s\",", str_encoded); - len += snprintf(&buff[len], sizeof(buff) - len, "\"AccessNumber\":%d,", header->access_no); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Status\":\"%.2X\",", header->status); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Signature\":\"%.2X%.2X\"", header->signature[1], header->signature[0]); - - len += snprintf(&buff[len], sizeof(buff) - len, "}"); - - return buff; - } - - return ""; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for a single variable-length data record -//------------------------------------------------------------------------------ -char * -mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int frame_cnt, mbus_data_variable_header *header) -{ - static char buff[8192]; - char str_encoded[768]; - size_t len = 0; - struct tm * timeinfo; - char timestamp[22]; - long tariff; - - if (record) - { - if (frame_cnt >= 0) - { - len += snprintf(&buff[len], sizeof(buff) - len, - "{\"id\":%d,\"frame\":%d,", - record_cnt, frame_cnt); - } - else - { - len += snprintf(&buff[len], sizeof(buff) - len, - "{\"id\":%d,", record_cnt); - } - - if (record->drh.dib.dif == MBUS_DIB_DIF_MANUFACTURER_SPECIFIC) // MBUS_DIB_DIF_VENDOR_SPECIFIC - { - len += snprintf(&buff[len], sizeof(buff) - len, - " \"Function\":\"Manufacturer specific\","); - } - else if (record->drh.dib.dif == MBUS_DIB_DIF_MORE_RECORDS_FOLLOW) - { - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Function\"\"More records follow\","); - } - else - { - mbus_str_json_encode(str_encoded, mbus_data_record_function(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Function\":\"%s\",", str_encoded); - - len += snprintf(&buff[len], sizeof(buff) - len, - "\"StorageNumber\":%ld,", - mbus_data_record_storage_number(record)); - - if ((tariff = mbus_data_record_tariff(record)) >= 0) - { - len += snprintf(&buff[len], sizeof(buff) - len, "\"Tariff\":%ld,", - tariff); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Device\":%d,", - mbus_data_record_device(record)); - } - - mbus_str_json_encode(str_encoded, mbus_data_record_unit(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Unit\":\"%s\",", str_encoded); - } - - mbus_str_json_encode(str_encoded, mbus_data_record_value(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Value\":\"%s\",", str_encoded); - - if (record->timestamp > 0) - { - timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); - // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Timestamp\":\"%s\"", timestamp); - } - - len += snprintf(&buff[len], sizeof(buff) - len, "},"); - - return buff; - } - - return ""; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for variable-length data -//------------------------------------------------------------------------------ -char * -mbus_data_variable_json(mbus_data_variable *data) -{ - mbus_data_record *record; - char *buff = NULL, *new_buff; - size_t len = 0, buff_size = 8192; - int i; - - if (data) - { - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "%s,", - mbus_data_variable_header_json(&(data->header))); - - len += snprintf(&buff[len], buff_size - len, "%s","\"DataRecords\":["); - - for (record = data->record, i = 0; record; record = record->next, i++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, i, -1, &(data->header))); - } - len += snprintf(&buff[len-1], buff_size - len + 1, "]}}"); - - return buff; - } - - return NULL; -} - -//------------------------------------------------------------------------------ -/// Generate JSON representation of fixed-length frame. -//------------------------------------------------------------------------------ -char * -mbus_data_fixed_json(mbus_data_fixed *data) -{ - char *buff = NULL; - char str_encoded[256]; - size_t len = 0, buff_size = 8192; - int val; - - if (data) - { - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); - len += snprintf(&buff[len], buff_size - len, "\"Id\":%d,", (int)mbus_data_bcd_decode(data->id_bcd, 4)); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_medium(data), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Medium\":\"%s\",", str_encoded); - - len += snprintf(&buff[len], buff_size - len, "\"AccessNumber\":%d,", data->tx_cnt); - len += snprintf(&buff[len], buff_size - len, "\"Status\":\"%.2X\"", data->status); - len += snprintf(&buff[len], buff_size - len, "},"); - - len += snprintf(&buff[len], buff_size - len, "\"DataRecord\":[{"); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt1_type), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); - if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) - { - val = mbus_data_bcd_decode(data->cnt1_val, 4); - } - else - { - mbus_data_int_decode(data->cnt1_val, 4, &val); - } - len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); - - len += snprintf(&buff[len], buff_size - len, "},{"); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt2_type), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); - if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) - { - val = mbus_data_bcd_decode(data->cnt2_val, 4); - } - else - { - mbus_data_int_decode(data->cnt2_val, 4, &val); - } - len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); - - len += snprintf(&buff[len], buff_size - len, "}]"); - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; - } - - return NULL; -} - -//------------------------------------------------------------------------------ -/// Generate JSON representation of a general application error. -//------------------------------------------------------------------------------ -char * -mbus_data_error_json(int error) -{ - char *buff = NULL; - char str_encoded[256]; - size_t len = 0, buff_size = 8192; - - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); - - mbus_str_json_encode(str_encoded, mbus_data_error_lookup(error), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Error\"\"%s\"", str_encoded); - - len += snprintf(&buff[len], buff_size - len, "}"); - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; -} - -//------------------------------------------------------------------------------ -/// Return a string containing an JSON representation of the M-BUS frame data. -//------------------------------------------------------------------------------ -char * -mbus_frame_data_json(mbus_frame_data *data) -{ - if (data) - { - if (data->type == MBUS_DATA_TYPE_ERROR) - { - return mbus_data_error_json(data->error); - } - - if (data->type == MBUS_DATA_TYPE_FIXED) - { - return mbus_data_fixed_json(&(data->data_fix)); - } - - if (data->type == MBUS_DATA_TYPE_VARIABLE) - { - return mbus_data_variable_json(&(data->data_var)); - } - } - - return NULL; -} - - -//------------------------------------------------------------------------------ -/// Return an JSON representation of the M-BUS frame. -//------------------------------------------------------------------------------ -char * -mbus_frame_json(mbus_frame *frame) -{ - mbus_frame_data frame_data; - mbus_frame *iter; - - mbus_data_record *record; - char *buff = NULL, *new_buff; - - size_t len = 0, buff_size = 8192; - int record_cnt = 0, frame_cnt; - - if (frame) - { - memset((void *)&frame_data, 0, sizeof(mbus_frame_data)); - - if (mbus_frame_data_parse(frame, &frame_data) == -1) - { - mbus_error_str_set("M-bus data parse error."); - return NULL; - } - - if (frame_data.type == MBUS_DATA_TYPE_ERROR) - { - // - // generate JSON for error - // - return mbus_data_error_json(frame_data.error); - } - - if (frame_data.type == MBUS_DATA_TYPE_FIXED) - { - // - // generate JSON for fixed data - // - return mbus_data_fixed_json(&(frame_data.data_fix)); - } - - if (frame_data.type == MBUS_DATA_TYPE_VARIABLE) - { - // - // generate JSON for a sequence of variable data frames - // - - buff = (char*) malloc(buff_size); - - if (buff == NULL) - { - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - // include frame counter in JSON output if more than one frame - // is available (frame_cnt = -1 => not included in output) - frame_cnt = (frame->next == NULL) ? -1 : 0; - - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - // only print the header info for the first frame (should be - // the same for each frame in a sequence of a multi-telegram - // transfer. - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_header_json(&(frame_data.data_var.header))); - - // loop through all records in the current frame, using a global - // record count as record ID in the JSON output - for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); - } - - // free all records in the list - if (frame_data.data_var.record) - { - mbus_data_record_free(frame_data.data_var.record); - } - - frame_cnt++; - - for (iter = frame->next; iter; iter = iter->next, frame_cnt++) - { - if (mbus_frame_data_parse(iter, &frame_data) == -1) - { - mbus_error_str_set("M-bus variable data parse error."); - return NULL; - } - - // loop through all records in the current frame, using a global - // record count as record ID in the JSON output - for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); - } - - // free all records in the list - if (frame_data.data_var.record) - { - mbus_data_record_free(frame_data.data_var.record); - } - } - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; - } - } - - return NULL; -} - //------------------------------------------------------------------------------ // diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 3e7d14b8..5ee9dd5e 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,20 +566,6 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); -// -// JSON generating functions -// -int mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len); -char *mbus_data_json(mbus_frame_data *data); -char *mbus_data_variable_json(mbus_data_variable *data); -char *mbus_data_fixed_json(mbus_data_fixed *data); -char *mbus_data_error_json(int error); -char *mbus_frame_data_json(mbus_frame_data *data); - -char *mbus_data_variable_header_json(mbus_data_variable_header *header); - -char *mbus_frame_json(mbus_frame *frame); - // // XML generating functions From 55a5357d93b7befa2ee04873c2245cb66b9177b3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:33:36 +0100 Subject: [PATCH 113/238] also add iso compatible timestamps into protoco-aux --- mbus/mbus-protocol-aux.c | 118 +++++++++++++++++++-------------------- mbus/mbus-protocol-aux.h | 2 +- mbus/mbus-protocol.h | 1 - 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ed295624..67e520a5 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -154,17 +154,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ - { 0x58, 1.0e-3, "°C", "Flow temperature" }, - { 0x59, 1.0e-2, "°C", "Flow temperature" }, - { 0x5A, 1.0e-1, "°C", "Flow temperature" }, - { 0x5B, 1.0e0, "°C", "Flow temperature" }, - - /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ - { 0x5C, 1.0e-3, "°C", "Return temperature" }, - { 0x5D, 1.0e-2, "°C", "Return temperature" }, - { 0x5E, 1.0e-1, "°C", "Return temperature" }, - { 0x5F, 1.0e0, "°C", "Return temperature" }, + /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ + { 0x58, 1.0e-3, "�C", "Flow temperature" }, + { 0x59, 1.0e-2, "�C", "Flow temperature" }, + { 0x5A, 1.0e-1, "�C", "Flow temperature" }, + { 0x5B, 1.0e0, "�C", "Flow temperature" }, + + /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ + { 0x5C, 1.0e-3, "�C", "Return temperature" }, + { 0x5D, 1.0e-2, "�C", "Return temperature" }, + { 0x5E, 1.0e-1, "�C", "Return temperature" }, + { 0x5F, 1.0e0, "�C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -172,11 +172,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature °C (0.001°C to 1°C) */ - { 0x64, 1.0e-3, "°C", "External temperature" }, - { 0x65, 1.0e-2, "°C", "External temperature" }, - { 0x66, 1.0e-1, "°C", "External temperature" }, - { 0x67, 1.0e0, "°C", "External temperature" }, + /* E110 01nn External Temperature �C (0.001�C to 1�C) */ + { 0x64, 1.0e-3, "�C", "External temperature" }, + { 0x65, 1.0e-2, "�C", "External temperature" }, + { 0x66, 1.0e-1, "�C", "External temperature" }, + { 0x67, 1.0e0, "�C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -608,29 +608,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x258, 1.0e-3, "°F", "Flow temperature" }, - { 0x259, 1.0e-2, "°F", "Flow temperature" }, - { 0x25A, 1.0e-1, "°F", "Flow temperature" }, - { 0x25B, 1.0e0, "°F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x25C, 1.0e-3, "°F", "Return temperature" }, - { 0x25D, 1.0e-2, "°F", "Return temperature" }, - { 0x25E, 1.0e-1, "°F", "Return temperature" }, - { 0x25F, 1.0e0, "°F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ - { 0x260, 1.0e-3, "°F", "Temperature difference" }, - { 0x261, 1.0e-2, "°F", "Temperature difference" }, - { 0x262, 1.0e-1, "°F", "Temperature difference" }, - { 0x263, 1.0e0, "°F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x264, 1.0e-3, "°F", "External temperature" }, - { 0x265, 1.0e-2, "°F", "External temperature" }, - { 0x266, 1.0e-1, "°F", "External temperature" }, - { 0x267, 1.0e0, "°F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x258, 1.0e-3, "�F", "Flow temperature" }, + { 0x259, 1.0e-2, "�F", "Flow temperature" }, + { 0x25A, 1.0e-1, "�F", "Flow temperature" }, + { 0x25B, 1.0e0, "�F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x25C, 1.0e-3, "�F", "Return temperature" }, + { 0x25D, 1.0e-2, "�F", "Return temperature" }, + { 0x25E, 1.0e-1, "�F", "Return temperature" }, + { 0x25F, 1.0e0, "�F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ + { 0x260, 1.0e-3, "�F", "Temperature difference" }, + { 0x261, 1.0e-2, "�F", "Temperature difference" }, + { 0x262, 1.0e-1, "�F", "Temperature difference" }, + { 0x263, 1.0e0, "�F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x264, 1.0e-3, "�F", "External temperature" }, + { 0x265, 1.0e-2, "�F", "External temperature" }, + { 0x266, 1.0e-1, "�F", "External temperature" }, + { 0x267, 1.0e0, "�F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -642,19 +642,19 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ - { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ + { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ - { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ + { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power § 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, @@ -730,7 +730,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "°C", "Temperature" }, + { 0x38, 1.0e-3, "�C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, @@ -886,7 +886,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 2, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -904,12 +904,12 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, ((record->drh.vib.vif == 0xFD) && (vife == 0x70))) { mbus_data_tm_decode(&time, record->data, 4); - if ((*value_out_str = (char*) malloc(20)) == NULL) + if ((*value_out_str = (char*) malloc(21)) == NULL) { MBUS_ERROR("Unable to allocate memory"); return -1; } - *value_out_str_size = snprintf(*value_out_str, 20, "%04d-%02d-%02dT%02d:%02d:%02d", + *value_out_str_size = snprintf(*value_out_str, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ", (time.tm_year + 1900), (time.tm_mon + 1), time.tm_mday, @@ -921,7 +921,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 4, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -939,12 +939,12 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, ((record->drh.vib.vif == 0xFD) && (vife == 0x70))) { mbus_data_tm_decode(&time, record->data, 6); - if ((*value_out_str = (char*) malloc(20)) == NULL) + if ((*value_out_str = (char*) malloc(21)) == NULL) { MBUS_ERROR("Unable to allocate memory"); return -1; } - *value_out_str_size = snprintf(*value_out_str, 20, "%04d-%02d-%02dT%02d:%02d:%02d", + *value_out_str_size = snprintf(*value_out_str, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ", (time.tm_year + 1900), (time.tm_mon + 1), time.tm_mday, @@ -1286,7 +1286,7 @@ mbus_parse_variable_record(mbus_data_record *data) MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__); return NULL; } - + record->storage_number = mbus_data_record_storage_number(data); record->tariff = mbus_data_record_tariff(data); record->device = mbus_data_record_device(data); @@ -2304,7 +2304,7 @@ mbus_probe_secondary_address(mbus_handle *handle, const char *mask, char *matchi if (addr == NULL) { // show error message, but procede with scan - MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", + MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", mbus_error_str()); return MBUS_PROBE_NOTHING; } diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 703bc23c..05d348b2 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 5ee9dd5e..85b8c11b 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,7 +566,6 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); - // // XML generating functions // From c014db38cd3e1815b6bcc72133fd0b25f2e19aaf Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:52:28 +0100 Subject: [PATCH 114/238] fix encoding --- mbus/mbus-protocol-aux.c | 102 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 67e520a5..2cd520ab 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -154,17 +154,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ - { 0x58, 1.0e-3, "�C", "Flow temperature" }, - { 0x59, 1.0e-2, "�C", "Flow temperature" }, - { 0x5A, 1.0e-1, "�C", "Flow temperature" }, - { 0x5B, 1.0e0, "�C", "Flow temperature" }, - - /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ - { 0x5C, 1.0e-3, "�C", "Return temperature" }, - { 0x5D, 1.0e-2, "�C", "Return temperature" }, - { 0x5E, 1.0e-1, "�C", "Return temperature" }, - { 0x5F, 1.0e0, "�C", "Return temperature" }, + /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ + { 0x58, 1.0e-3, "°C", "Flow temperature" }, + { 0x59, 1.0e-2, "°C", "Flow temperature" }, + { 0x5A, 1.0e-1, "°C", "Flow temperature" }, + { 0x5B, 1.0e0, "°C", "Flow temperature" }, + + /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ + { 0x5C, 1.0e-3, "°C", "Return temperature" }, + { 0x5D, 1.0e-2, "°C", "Return temperature" }, + { 0x5E, 1.0e-1, "°C", "Return temperature" }, + { 0x5F, 1.0e0, "°C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -172,11 +172,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature �C (0.001�C to 1�C) */ - { 0x64, 1.0e-3, "�C", "External temperature" }, - { 0x65, 1.0e-2, "�C", "External temperature" }, - { 0x66, 1.0e-1, "�C", "External temperature" }, - { 0x67, 1.0e0, "�C", "External temperature" }, + /* E110 01nn External Temperature °C (0.001°C to 1°C) */ + { 0x64, 1.0e-3, "°C", "External temperature" }, + { 0x65, 1.0e-2, "°C", "External temperature" }, + { 0x66, 1.0e-1, "°C", "External temperature" }, + { 0x67, 1.0e0, "°C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -608,29 +608,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x258, 1.0e-3, "�F", "Flow temperature" }, - { 0x259, 1.0e-2, "�F", "Flow temperature" }, - { 0x25A, 1.0e-1, "�F", "Flow temperature" }, - { 0x25B, 1.0e0, "�F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x25C, 1.0e-3, "�F", "Return temperature" }, - { 0x25D, 1.0e-2, "�F", "Return temperature" }, - { 0x25E, 1.0e-1, "�F", "Return temperature" }, - { 0x25F, 1.0e0, "�F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ - { 0x260, 1.0e-3, "�F", "Temperature difference" }, - { 0x261, 1.0e-2, "�F", "Temperature difference" }, - { 0x262, 1.0e-1, "�F", "Temperature difference" }, - { 0x263, 1.0e0, "�F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x264, 1.0e-3, "�F", "External temperature" }, - { 0x265, 1.0e-2, "�F", "External temperature" }, - { 0x266, 1.0e-1, "�F", "External temperature" }, - { 0x267, 1.0e0, "�F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x258, 1.0e-3, "°F", "Flow temperature" }, + { 0x259, 1.0e-2, "°F", "Flow temperature" }, + { 0x25A, 1.0e-1, "°F", "Flow temperature" }, + { 0x25B, 1.0e0, "°F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x25C, 1.0e-3, "°F", "Return temperature" }, + { 0x25D, 1.0e-2, "°F", "Return temperature" }, + { 0x25E, 1.0e-1, "°F", "Return temperature" }, + { 0x25F, 1.0e0, "°F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ + { 0x260, 1.0e-3, "°F", "Temperature difference" }, + { 0x261, 1.0e-2, "°F", "Temperature difference" }, + { 0x262, 1.0e-1, "°F", "Temperature difference" }, + { 0x263, 1.0e0, "°F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x264, 1.0e-3, "°F", "External temperature" }, + { 0x265, 1.0e-2, "°F", "External temperature" }, + { 0x266, 1.0e-1, "°F", "External temperature" }, + { 0x267, 1.0e0, "°F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -642,19 +642,19 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ - { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ + { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ - { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ + { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power ° 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, @@ -730,7 +730,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "�C", "Temperature" }, + { 0x38, 1.0e-3, "°C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, From 248fc2822ce6b813aab0164f7efcdbb6acd75e78 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:54:30 +0100 Subject: [PATCH 115/238] fix encoding --- mbus/mbus-protocol-aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 2cd520ab..1ebe2807 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -654,7 +654,7 @@ mbus_variable_vif vif_table[] = { { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power ° 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power § 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, From c134735a21a3a78f7af36b06061a06e04710f358 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 08:33:03 +0100 Subject: [PATCH 116/238] revert build/configure to main repo --- build.sh | 3 +-- configure.ac | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 40874a5c..34c2799b 100755 --- a/build.sh +++ b/build.sh @@ -15,8 +15,7 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure \ - && autoreconf + && ./configure fi make diff --git a/configure.ac b/configure.ac index edd30c2d..a2efd560 100644 --- a/configure.ac +++ b/configure.ac @@ -14,9 +14,9 @@ AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/l AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AM_PROG_LIBTOOL # fix for automake 1.11 & 1.12 m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -AM_PROG_LIBTOOL LDFLAGS="$LDFLAGS -version-info 0:8:0" From 34b5da7160a84cbc78cf2596a66412419051359d Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 08:43:16 +0100 Subject: [PATCH 117/238] retry macbuild --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 34c2799b..40874a5c 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,8 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure + && ./configure \ + && autoreconf fi make From 2e72238b16d3cabc49012c88970d13956961a88e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 16:27:38 +0100 Subject: [PATCH 118/238] fix windows --- win/termiWin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/win/termiWin.c b/win/termiWin.c index 2c2604c1..2d046803 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -503,15 +503,15 @@ int openSerial(char* portname, int opt) { switch (opt) { case O_RDWR: - com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + com.hComm = CreateFile(com.port, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); break; case O_RDONLY: - com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + com.hComm = CreateFile(com.port, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); break; case O_WRONLY: - com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + com.hComm = CreateFile(com.port, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); break; } From 5efd4716e97347ba293e52f4e6dfb4ce0ee68125 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 22:47:11 +0100 Subject: [PATCH 119/238] try fix windows com name handling --- win/termiWin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/termiWin.c b/win/termiWin.c index 2d046803..3db3367d 100644 --- a/win/termiWin.c +++ b/win/termiWin.c @@ -497,8 +497,8 @@ int openSerial(char* portname, int opt) { if (strlen(portname) < 4) return -1; - com.port = calloc(1,sizeof(char)*(strlen("\\\\.\\")+4)); - strncat(com.port, portname, 4); + com.port = calloc(1,sizeof(char)*(strlen(portname)+1)); + strncat(com.port, portname, strlen(portname)); switch (opt) { From e6a4fbb2cd9289a9f0b5680a65ac74e83045ea2d Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 25 Mar 2018 18:24:14 +0200 Subject: [PATCH 120/238] reset serial timeouts to defaults --- mbus/mbus-serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 06ab2d29..d8fb35a8 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -114,7 +114,7 @@ mbus_serial_connect(mbus_handle *handle) // For 2400Bd this means (330 + 11) / 2400 + 0.15 = 292 ms (added 11 bit periods to receive first byte). // I.e. timeout of 0.3s seems appropriate for 2400Bd. - term->c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec + term->c_cc[VTIME] = (cc_t) 3; // Timeout in 1/10 sec cfsetispeed(term, B2400); cfsetospeed(term, B2400); @@ -167,7 +167,7 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) case 2400: speed = B2400; - serial_data->t.c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec + serial_data->t.c_cc[VTIME] = (cc_t) 3; // Timeout in 1/10 sec break; case 4800: @@ -177,7 +177,7 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) case 9600: speed = B9600; - serial_data->t.c_cc[VTIME] = (cc_t) 30; // Timeout in 1/10 sec + serial_data->t.c_cc[VTIME] = (cc_t) 2; // Timeout in 1/10 sec break; case 19200: From 6fd08cec4e4d5d324ee1bbd350b37419168d7c08 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 25 Mar 2018 19:49:51 +0200 Subject: [PATCH 121/238] just to make sure check because of a reported segfault ... but could not be normally ... --- mbus/mbus-serial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index d8fb35a8..b0eead8c 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -246,7 +246,10 @@ mbus_serial_data_free(mbus_handle *handle) return; } - free(serial_data->device); + if (serial_data->device == NULL) + { + free(serial_data->device); + } free(serial_data); handle->auxdata = NULL; } From eaf08fe36115cf077678eeb0bb010c98f3948a30 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 25 Mar 2018 22:48:30 +0200 Subject: [PATCH 122/238] fix --- mbus/mbus-serial.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index b0eead8c..09801e26 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -246,7 +246,7 @@ mbus_serial_data_free(mbus_handle *handle) return; } - if (serial_data->device == NULL) + if (serial_data->device != NULL) { free(serial_data->device); } From 01ecb0a16bb5ce5c877a88868581267de925632b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Thu, 22 Feb 2018 10:19:16 +0100 Subject: [PATCH 123/238] replay all changees (JSon functions and 0.9.0) from samkrew/libmbus to current libmbus --- build.sh | 3 +- configure.ac | 14 +- mbus/mbus-protocol.c | 513 +++++++++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol.h | 16 +- 4 files changed, 537 insertions(+), 9 deletions(-) diff --git a/build.sh b/build.sh index 34c2799b..40874a5c 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,8 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure + && ./configure \ + && autoreconf fi make diff --git a/configure.ac b/configure.ac index fd8497cc..37968448 100644 --- a/configure.ac +++ b/configure.ac @@ -2,26 +2,26 @@ dnl ---------------------------------------------------------------------------- dnl Copyright (C) 2010, Raditex AB dnl All rights reserved. dnl -dnl rSCADA +dnl rSCADA dnl http://www.rSCADA.se dnl info@rscada.se -dnl +dnl dnl ---------------------------------------------------------------------------- LT_CONFIG_LTDL_DIR([libltdl]) -AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) -AM_PROG_LIBTOOL # fix for automake 1.11 & 1.12 -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) +AM_PROG_LIBTOOL -LDFLAGS="$LDFLAGS -version-info 0:8:0" +LDFLAGS="$LDFLAGS -version-info 0:9:0" dnl ---------------------- -dnl +dnl AC_PROG_CC AC_CONFIG_HEADERS([config.h]) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 03bd5d2b..35789223 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3767,6 +3767,519 @@ mbus_data_error_print(int error) return -1; } +//------------------------------------------------------------------------------ +// +// JSON RELATED FUNCTIONS +// +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// +/// Encode string to JSON +/// +//------------------------------------------------------------------------------ +int +mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len) +{ + size_t i, len; + + i = 0; + len = 0; + + if (dst == NULL) + { + return -1; + } + + if (src == NULL) + { + dst[len] = '\0'; + return -2; + } + + while((len+6) < max_len) + { + if (src[i] == '\0') + { + break; + } + + if (iscntrl(src[i])) + { + // convert all control chars into spaces + dst[len++] = ' '; + } + else + { + switch (src[i]) + { + case '"': + len += snprintf(&dst[len], max_len - len, "\\\""); + break; + default: + dst[len++] = src[i]; + break; + } + } + + i++; + } + + dst[len] = '\0'; + return 0; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for the variable-length data header +//------------------------------------------------------------------------------ +char * +mbus_data_variable_header_json(mbus_data_variable_header *header) +{ + static char buff[8192]; + char str_encoded[768]; + size_t len = 0; + int val; + + if (header) + { + len += snprintf(&buff[len], sizeof(buff) - len, "\"SlaveInformation\":{"); + + val = (int)mbus_data_bcd_decode(header->id_bcd, 4); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"Id\":%d,", val); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Manufacturer\":\"%s\",", + mbus_decode_manufacturer(header->manufacturer[0], header->manufacturer[1])); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Version\":%d,", header->version); + + mbus_str_json_encode(str_encoded, mbus_data_product_name(header), sizeof(str_encoded)); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"ProductName\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_variable_medium_lookup(header->medium), sizeof(str_encoded)); + + len += snprintf(&buff[len], sizeof(buff) - len, "\"Medium\":\"%s\",", str_encoded); + len += snprintf(&buff[len], sizeof(buff) - len, "\"AccessNumber\":%d,", header->access_no); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Status\":\"%.2X\",", header->status); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Signature\":\"%.2X%.2X\"", header->signature[1], header->signature[0]); + + len += snprintf(&buff[len], sizeof(buff) - len, "}"); + + return buff; + } + + return ""; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for a single variable-length data record +//------------------------------------------------------------------------------ +char * +mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int frame_cnt, mbus_data_variable_header *header) +{ + static char buff[8192]; + char str_encoded[768]; + size_t len = 0; + struct tm * timeinfo; + char timestamp[21]; + long tariff; + + if (record) + { + if (frame_cnt >= 0) + { + len += snprintf(&buff[len], sizeof(buff) - len, + "{\"id\":%d,\"frame\":%d,", + record_cnt, frame_cnt); + } + else + { + len += snprintf(&buff[len], sizeof(buff) - len, + "{\"id\":%d,", record_cnt); + } + + if (record->drh.dib.dif == MBUS_DIB_DIF_MANUFACTURER_SPECIFIC) // MBUS_DIB_DIF_VENDOR_SPECIFIC + { + len += snprintf(&buff[len], sizeof(buff) - len, + " \"Function\":\"Manufacturer specific\","); + } + else if (record->drh.dib.dif == MBUS_DIB_DIF_MORE_RECORDS_FOLLOW) + { + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Function\"\"More records follow\","); + } + else + { + mbus_str_json_encode(str_encoded, mbus_data_record_function(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Function\":\"%s\",", str_encoded); + + len += snprintf(&buff[len], sizeof(buff) - len, + "\"StorageNumber\":%ld,", + mbus_data_record_storage_number(record)); + + if ((tariff = mbus_data_record_tariff(record)) >= 0) + { + len += snprintf(&buff[len], sizeof(buff) - len, "\"Tariff\":%ld,", + tariff); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Device\":%d,", + mbus_data_record_device(record)); + } + + mbus_str_json_encode(str_encoded, mbus_data_record_unit(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Unit\":\"%s\",", str_encoded); + } + + mbus_str_json_encode(str_encoded, mbus_data_record_value(record), sizeof(str_encoded)); + len += snprintf(&buff[len], sizeof(buff) - len, "\"Value\":\"%s\",", str_encoded); + + if (record->timestamp > 0) + { + timeinfo = gmtime (&(record->timestamp)); + strftime(timestamp,20,"%Y-%m-%dT%H:%M:%SZ",timeinfo); + // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" + len += snprintf(&buff[len], sizeof(buff) - len, + "\"Timestamp\":\"%s\"", timestamp); + } + + len += snprintf(&buff[len], sizeof(buff) - len, "},"); + + return buff; + } + + return ""; +} + +//------------------------------------------------------------------------------ +/// Generate JSON for variable-length data +//------------------------------------------------------------------------------ +char * +mbus_data_variable_json(mbus_data_variable *data) +{ + mbus_data_record *record; + char *buff = NULL, *new_buff; + size_t len = 0, buff_size = 8192; + int i; + + if (data) + { + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "%s,", + mbus_data_variable_header_json(&(data->header))); + + len += snprintf(&buff[len], buff_size - len, "%s","\"DataRecords\":["); + + for (record = data->record, i = 0; record; record = record->next, i++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, i, -1, &(data->header))); + } + len += snprintf(&buff[len-1], buff_size - len + 1, "]}}"); + + return buff; + } + + return NULL; +} + +//------------------------------------------------------------------------------ +/// Generate JSON representation of fixed-length frame. +//------------------------------------------------------------------------------ +char * +mbus_data_fixed_json(mbus_data_fixed *data) +{ + char *buff = NULL; + char str_encoded[256]; + size_t len = 0, buff_size = 8192; + int val; + + if (data) + { + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); + len += snprintf(&buff[len], buff_size - len, "\"Id\":%d,", (int)mbus_data_bcd_decode(data->id_bcd, 4)); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_medium(data), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Medium\":\"%s\",", str_encoded); + + len += snprintf(&buff[len], buff_size - len, "\"AccessNumber\":%d,", data->tx_cnt); + len += snprintf(&buff[len], buff_size - len, "\"Status\":\"%.2X\"", data->status); + len += snprintf(&buff[len], buff_size - len, "},"); + + len += snprintf(&buff[len], buff_size - len, "\"DataRecord\":[{"); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt1_type), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); + if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) + { + val = mbus_data_bcd_decode(data->cnt1_val, 4); + } + else + { + mbus_data_int_decode(data->cnt1_val, 4, &val); + } + len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); + + len += snprintf(&buff[len], buff_size - len, "},{"); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); + + mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt2_type), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); + if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) + { + val = mbus_data_bcd_decode(data->cnt2_val, 4); + } + else + { + mbus_data_int_decode(data->cnt2_val, 4, &val); + } + len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); + + len += snprintf(&buff[len], buff_size - len, "}]"); + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; + } + + return NULL; +} + +//------------------------------------------------------------------------------ +/// Generate JSON representation of a general application error. +//------------------------------------------------------------------------------ +char * +mbus_data_error_json(int error) +{ + char *buff = NULL; + char str_encoded[256]; + size_t len = 0, buff_size = 8192; + + buff = (char*) malloc(buff_size); + + if (buff == NULL) + return NULL; + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); + + mbus_str_json_encode(str_encoded, mbus_data_error_lookup(error), sizeof(str_encoded)); + len += snprintf(&buff[len], buff_size - len, "\"Error\"\"%s\"", str_encoded); + + len += snprintf(&buff[len], buff_size - len, "}"); + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; +} + +//------------------------------------------------------------------------------ +/// Return a string containing an JSON representation of the M-BUS frame data. +//------------------------------------------------------------------------------ +char * +mbus_frame_data_json(mbus_frame_data *data) +{ + if (data) + { + if (data->type == MBUS_DATA_TYPE_ERROR) + { + return mbus_data_error_json(data->error); + } + + if (data->type == MBUS_DATA_TYPE_FIXED) + { + return mbus_data_fixed_json(&(data->data_fix)); + } + + if (data->type == MBUS_DATA_TYPE_VARIABLE) + { + return mbus_data_variable_json(&(data->data_var)); + } + } + + return NULL; +} + + +//------------------------------------------------------------------------------ +/// Return an JSON representation of the M-BUS frame. +//------------------------------------------------------------------------------ +char * +mbus_frame_json(mbus_frame *frame) +{ + mbus_frame_data frame_data; + mbus_frame *iter; + + mbus_data_record *record; + char *buff = NULL, *new_buff; + + size_t len = 0, buff_size = 8192; + int record_cnt = 0, frame_cnt; + + if (frame) + { + memset((void *)&frame_data, 0, sizeof(mbus_frame_data)); + + if (mbus_frame_data_parse(frame, &frame_data) == -1) + { + mbus_error_str_set("M-bus data parse error."); + return NULL; + } + + if (frame_data.type == MBUS_DATA_TYPE_ERROR) + { + // + // generate JSON for error + // + return mbus_data_error_json(frame_data.error); + } + + if (frame_data.type == MBUS_DATA_TYPE_FIXED) + { + // + // generate JSON for fixed data + // + return mbus_data_fixed_json(&(frame_data.data_fix)); + } + + if (frame_data.type == MBUS_DATA_TYPE_VARIABLE) + { + // + // generate JSON for a sequence of variable data frames + // + + buff = (char*) malloc(buff_size); + + if (buff == NULL) + { + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + // include frame counter in JSON output if more than one frame + // is available (frame_cnt = -1 => not included in output) + frame_cnt = (frame->next == NULL) ? -1 : 0; + + + len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); + + // only print the header info for the first frame (should be + // the same for each frame in a sequence of a multi-telegram + // transfer. + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_header_json(&(frame_data.data_var.header))); + + // loop through all records in the current frame, using a global + // record count as record ID in the JSON output + for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); + } + + // free all records in the list + if (frame_data.data_var.record) + { + mbus_data_record_free(frame_data.data_var.record); + } + + frame_cnt++; + + for (iter = frame->next; iter; iter = iter->next, frame_cnt++) + { + if (mbus_frame_data_parse(iter, &frame_data) == -1) + { + mbus_error_str_set("M-bus variable data parse error."); + return NULL; + } + + // loop through all records in the current frame, using a global + // record count as record ID in the JSON output + for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) + { + if ((buff_size - len) < 1024) + { + buff_size *= 2; + new_buff = (char*) realloc(buff,buff_size); + + if (new_buff == NULL) + { + free(buff); + mbus_data_record_free(frame_data.data_var.record); + return NULL; + } + + buff = new_buff; + } + + len += snprintf(&buff[len], buff_size - len, "%s", + mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); + } + + // free all records in the list + if (frame_data.data_var.record) + { + mbus_data_record_free(frame_data.data_var.record); + } + } + + len += snprintf(&buff[len], buff_size - len, "}}"); + + return buff; + } + } + + return NULL; +} + + //------------------------------------------------------------------------------ // // XML RELATED FUNCTIONS diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 60b7424b..3e7d14b8 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,6 +566,21 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); +// +// JSON generating functions +// +int mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len); +char *mbus_data_json(mbus_frame_data *data); +char *mbus_data_variable_json(mbus_data_variable *data); +char *mbus_data_fixed_json(mbus_data_fixed *data); +char *mbus_data_error_json(int error); +char *mbus_frame_data_json(mbus_frame_data *data); + +char *mbus_data_variable_header_json(mbus_data_variable_header *header); + +char *mbus_frame_json(mbus_frame *frame); + + // // XML generating functions // @@ -643,4 +658,3 @@ int mbus_is_secondary_address(const char * value); #endif #endif /* _MBUS_PROTOCOL_H_ */ - From ff53c9e154c7748c46b24d2c27698f19900ee062 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Fri, 23 Feb 2018 09:35:07 +0100 Subject: [PATCH 124/238] make sure mbus-protocol-aux.o --- mbus/Makefile.am | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mbus/Makefile.am b/mbus/Makefile.am index b0749871..261e0c00 100644 --- a/mbus/Makefile.am +++ b/mbus/Makefile.am @@ -2,7 +2,7 @@ # Copyright (C) 2010, Raditex AB # All rights reserved. # -# rSCADA +# rSCADA # http://www.rSCADA.se # info@rscada.se # @@ -10,11 +10,10 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -fPIC includedir = $(prefix)/include/mbus include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h lib_LTLIBRARIES = libmbus.la libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c - From 2974d47536a735c31f970a4ea81deedaa1c26dc3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:33:10 +0100 Subject: [PATCH 125/238] output config.h --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39fe165c..9fa74e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ os: - linux - osx -script: +script: - ./build.sh + - cat config.h - cd test && make && ./generate-xml.sh test-frames From 715a1f8ec1dddd86f883fcb04ce4e769003175de Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:54:38 +0100 Subject: [PATCH 126/238] Revert "make sure mbus-protocol-aux.o" This reverts commit 0cf4843882ff68b0f846087256ae4095886d60c0. --- mbus/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mbus/Makefile.am b/mbus/Makefile.am index 261e0c00..b0749871 100644 --- a/mbus/Makefile.am +++ b/mbus/Makefile.am @@ -2,7 +2,7 @@ # Copyright (C) 2010, Raditex AB # All rights reserved. # -# rSCADA +# rSCADA # http://www.rSCADA.se # info@rscada.se # @@ -10,10 +10,11 @@ PACKAGE = @PACKAGE@ VERSION = @VERSION@ -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -fPIC +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) includedir = $(prefix)/include/mbus include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h lib_LTLIBRARIES = libmbus.la libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c + From e1a9257ed7318214dd9648849137ef1b2e2d9973 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sat, 24 Feb 2018 17:54:43 +0100 Subject: [PATCH 127/238] Revert "output config.h" This reverts commit 68dfbbaa4bac17924247b1caf6ba30f29a64586c. --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9fa74e04..39fe165c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ os: - linux - osx -script: +script: - ./build.sh - - cat config.h - cd test && make && ./generate-xml.sh test-frames From f8ca7ed77c0834f87304ab381ebe91fd1c40aa52 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 11 Mar 2018 21:25:14 +0100 Subject: [PATCH 128/238] make timestamps all ISO conform by adding "Z" at the end --- mbus/mbus-protocol.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 35789223..a3ce536e 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3739,7 +3739,7 @@ mbus_hex_dump(const char *label, const char *buff, size_t len) { time_t rawtime; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; size_t i; if (label == NULL || buff == NULL) @@ -3748,7 +3748,7 @@ mbus_hex_dump(const char *label, const char *buff, size_t len) time ( &rawtime ); timeinfo = gmtime ( &rawtime ); - strftime(timestamp,20,"%Y-%m-%d %H:%M:%S",timeinfo); + strftime(timestamp,21,"%Y-%m-%d %H:%M:%SZ",timeinfo); fprintf(stderr, "[%s] %s (%03zu):", timestamp, label, len); for (i = 0; i < len; i++) @@ -3880,7 +3880,7 @@ mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int fra char str_encoded[768]; size_t len = 0; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; long tariff; if (record) @@ -3936,7 +3936,7 @@ mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int fra if (record->timestamp > 0) { timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,20,"%Y-%m-%dT%H:%M:%SZ",timeinfo); + strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" len += snprintf(&buff[len], sizeof(buff) - len, "\"Timestamp\":\"%s\"", timestamp); @@ -4399,7 +4399,7 @@ mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int fram char str_encoded[768]; size_t len = 0; struct tm * timeinfo; - char timestamp[21]; + char timestamp[22]; long tariff; if (record) @@ -4455,7 +4455,7 @@ mbus_data_variable_record_xml(mbus_data_record *record, int record_cnt, int fram if (record->timestamp > 0) { timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,20,"%Y-%m-%dT%H:%M:%S",timeinfo); + strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); len += snprintf(&buff[len], sizeof(buff) - len, " %s\n", timestamp); } From 139de3c87fc9bad95e22ae289dbdeb0a24a51366 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:26:03 +0100 Subject: [PATCH 129/238] remove json functions again --- configure.ac | 4 +- mbus/mbus-protocol.c | 512 ------------------------------------------- mbus/mbus-protocol.h | 14 -- 3 files changed, 2 insertions(+), 528 deletions(-) diff --git a/configure.ac b/configure.ac index 37968448..edd30c2d 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ dnl ---------------------------------------------------------------------------- LT_CONFIG_LTDL_DIR([libltdl]) -AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) @@ -18,7 +18,7 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign]) m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AM_PROG_LIBTOOL -LDFLAGS="$LDFLAGS -version-info 0:9:0" +LDFLAGS="$LDFLAGS -version-info 0:8:0" dnl ---------------------- dnl diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index a3ce536e..94773cd8 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3767,518 +3767,6 @@ mbus_data_error_print(int error) return -1; } -//------------------------------------------------------------------------------ -// -// JSON RELATED FUNCTIONS -// -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -/// -/// Encode string to JSON -/// -//------------------------------------------------------------------------------ -int -mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len) -{ - size_t i, len; - - i = 0; - len = 0; - - if (dst == NULL) - { - return -1; - } - - if (src == NULL) - { - dst[len] = '\0'; - return -2; - } - - while((len+6) < max_len) - { - if (src[i] == '\0') - { - break; - } - - if (iscntrl(src[i])) - { - // convert all control chars into spaces - dst[len++] = ' '; - } - else - { - switch (src[i]) - { - case '"': - len += snprintf(&dst[len], max_len - len, "\\\""); - break; - default: - dst[len++] = src[i]; - break; - } - } - - i++; - } - - dst[len] = '\0'; - return 0; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for the variable-length data header -//------------------------------------------------------------------------------ -char * -mbus_data_variable_header_json(mbus_data_variable_header *header) -{ - static char buff[8192]; - char str_encoded[768]; - size_t len = 0; - int val; - - if (header) - { - len += snprintf(&buff[len], sizeof(buff) - len, "\"SlaveInformation\":{"); - - val = (int)mbus_data_bcd_decode(header->id_bcd, 4); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"Id\":%d,", val); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Manufacturer\":\"%s\",", - mbus_decode_manufacturer(header->manufacturer[0], header->manufacturer[1])); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Version\":%d,", header->version); - - mbus_str_json_encode(str_encoded, mbus_data_product_name(header), sizeof(str_encoded)); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"ProductName\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_variable_medium_lookup(header->medium), sizeof(str_encoded)); - - len += snprintf(&buff[len], sizeof(buff) - len, "\"Medium\":\"%s\",", str_encoded); - len += snprintf(&buff[len], sizeof(buff) - len, "\"AccessNumber\":%d,", header->access_no); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Status\":\"%.2X\",", header->status); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Signature\":\"%.2X%.2X\"", header->signature[1], header->signature[0]); - - len += snprintf(&buff[len], sizeof(buff) - len, "}"); - - return buff; - } - - return ""; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for a single variable-length data record -//------------------------------------------------------------------------------ -char * -mbus_data_variable_record_json(mbus_data_record *record, int record_cnt, int frame_cnt, mbus_data_variable_header *header) -{ - static char buff[8192]; - char str_encoded[768]; - size_t len = 0; - struct tm * timeinfo; - char timestamp[22]; - long tariff; - - if (record) - { - if (frame_cnt >= 0) - { - len += snprintf(&buff[len], sizeof(buff) - len, - "{\"id\":%d,\"frame\":%d,", - record_cnt, frame_cnt); - } - else - { - len += snprintf(&buff[len], sizeof(buff) - len, - "{\"id\":%d,", record_cnt); - } - - if (record->drh.dib.dif == MBUS_DIB_DIF_MANUFACTURER_SPECIFIC) // MBUS_DIB_DIF_VENDOR_SPECIFIC - { - len += snprintf(&buff[len], sizeof(buff) - len, - " \"Function\":\"Manufacturer specific\","); - } - else if (record->drh.dib.dif == MBUS_DIB_DIF_MORE_RECORDS_FOLLOW) - { - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Function\"\"More records follow\","); - } - else - { - mbus_str_json_encode(str_encoded, mbus_data_record_function(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Function\":\"%s\",", str_encoded); - - len += snprintf(&buff[len], sizeof(buff) - len, - "\"StorageNumber\":%ld,", - mbus_data_record_storage_number(record)); - - if ((tariff = mbus_data_record_tariff(record)) >= 0) - { - len += snprintf(&buff[len], sizeof(buff) - len, "\"Tariff\":%ld,", - tariff); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Device\":%d,", - mbus_data_record_device(record)); - } - - mbus_str_json_encode(str_encoded, mbus_data_record_unit(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Unit\":\"%s\",", str_encoded); - } - - mbus_str_json_encode(str_encoded, mbus_data_record_value(record), sizeof(str_encoded)); - len += snprintf(&buff[len], sizeof(buff) - len, "\"Value\":\"%s\",", str_encoded); - - if (record->timestamp > 0) - { - timeinfo = gmtime (&(record->timestamp)); - strftime(timestamp,21,"%Y-%m-%dT%H:%M:%SZ",timeinfo); - // "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" - len += snprintf(&buff[len], sizeof(buff) - len, - "\"Timestamp\":\"%s\"", timestamp); - } - - len += snprintf(&buff[len], sizeof(buff) - len, "},"); - - return buff; - } - - return ""; -} - -//------------------------------------------------------------------------------ -/// Generate JSON for variable-length data -//------------------------------------------------------------------------------ -char * -mbus_data_variable_json(mbus_data_variable *data) -{ - mbus_data_record *record; - char *buff = NULL, *new_buff; - size_t len = 0, buff_size = 8192; - int i; - - if (data) - { - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "%s,", - mbus_data_variable_header_json(&(data->header))); - - len += snprintf(&buff[len], buff_size - len, "%s","\"DataRecords\":["); - - for (record = data->record, i = 0; record; record = record->next, i++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, i, -1, &(data->header))); - } - len += snprintf(&buff[len-1], buff_size - len + 1, "]}}"); - - return buff; - } - - return NULL; -} - -//------------------------------------------------------------------------------ -/// Generate JSON representation of fixed-length frame. -//------------------------------------------------------------------------------ -char * -mbus_data_fixed_json(mbus_data_fixed *data) -{ - char *buff = NULL; - char str_encoded[256]; - size_t len = 0, buff_size = 8192; - int val; - - if (data) - { - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); - len += snprintf(&buff[len], buff_size - len, "\"Id\":%d,", (int)mbus_data_bcd_decode(data->id_bcd, 4)); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_medium(data), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Medium\":\"%s\",", str_encoded); - - len += snprintf(&buff[len], buff_size - len, "\"AccessNumber\":%d,", data->tx_cnt); - len += snprintf(&buff[len], buff_size - len, "\"Status\":\"%.2X\"", data->status); - len += snprintf(&buff[len], buff_size - len, "},"); - - len += snprintf(&buff[len], buff_size - len, "\"DataRecord\":[{"); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt1_type), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); - if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) - { - val = mbus_data_bcd_decode(data->cnt1_val, 4); - } - else - { - mbus_data_int_decode(data->cnt1_val, 4, &val); - } - len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); - - len += snprintf(&buff[len], buff_size - len, "},{"); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_function(data->status), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Function\":\"%s\",", str_encoded); - - mbus_str_json_encode(str_encoded, mbus_data_fixed_unit(data->cnt2_type), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Unit\":\"%s\",", str_encoded); - if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) - { - val = mbus_data_bcd_decode(data->cnt2_val, 4); - } - else - { - mbus_data_int_decode(data->cnt2_val, 4, &val); - } - len += snprintf(&buff[len], buff_size - len, "\"Value\":%d", val); - - len += snprintf(&buff[len], buff_size - len, "}]"); - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; - } - - return NULL; -} - -//------------------------------------------------------------------------------ -/// Generate JSON representation of a general application error. -//------------------------------------------------------------------------------ -char * -mbus_data_error_json(int error) -{ - char *buff = NULL; - char str_encoded[256]; - size_t len = 0, buff_size = 8192; - - buff = (char*) malloc(buff_size); - - if (buff == NULL) - return NULL; - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - len += snprintf(&buff[len], buff_size - len, "\"SlaveInformation\":{"); - - mbus_str_json_encode(str_encoded, mbus_data_error_lookup(error), sizeof(str_encoded)); - len += snprintf(&buff[len], buff_size - len, "\"Error\"\"%s\"", str_encoded); - - len += snprintf(&buff[len], buff_size - len, "}"); - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; -} - -//------------------------------------------------------------------------------ -/// Return a string containing an JSON representation of the M-BUS frame data. -//------------------------------------------------------------------------------ -char * -mbus_frame_data_json(mbus_frame_data *data) -{ - if (data) - { - if (data->type == MBUS_DATA_TYPE_ERROR) - { - return mbus_data_error_json(data->error); - } - - if (data->type == MBUS_DATA_TYPE_FIXED) - { - return mbus_data_fixed_json(&(data->data_fix)); - } - - if (data->type == MBUS_DATA_TYPE_VARIABLE) - { - return mbus_data_variable_json(&(data->data_var)); - } - } - - return NULL; -} - - -//------------------------------------------------------------------------------ -/// Return an JSON representation of the M-BUS frame. -//------------------------------------------------------------------------------ -char * -mbus_frame_json(mbus_frame *frame) -{ - mbus_frame_data frame_data; - mbus_frame *iter; - - mbus_data_record *record; - char *buff = NULL, *new_buff; - - size_t len = 0, buff_size = 8192; - int record_cnt = 0, frame_cnt; - - if (frame) - { - memset((void *)&frame_data, 0, sizeof(mbus_frame_data)); - - if (mbus_frame_data_parse(frame, &frame_data) == -1) - { - mbus_error_str_set("M-bus data parse error."); - return NULL; - } - - if (frame_data.type == MBUS_DATA_TYPE_ERROR) - { - // - // generate JSON for error - // - return mbus_data_error_json(frame_data.error); - } - - if (frame_data.type == MBUS_DATA_TYPE_FIXED) - { - // - // generate JSON for fixed data - // - return mbus_data_fixed_json(&(frame_data.data_fix)); - } - - if (frame_data.type == MBUS_DATA_TYPE_VARIABLE) - { - // - // generate JSON for a sequence of variable data frames - // - - buff = (char*) malloc(buff_size); - - if (buff == NULL) - { - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - // include frame counter in JSON output if more than one frame - // is available (frame_cnt = -1 => not included in output) - frame_cnt = (frame->next == NULL) ? -1 : 0; - - - len += snprintf(&buff[len], buff_size - len, "{\"MBusData\":{"); - - // only print the header info for the first frame (should be - // the same for each frame in a sequence of a multi-telegram - // transfer. - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_header_json(&(frame_data.data_var.header))); - - // loop through all records in the current frame, using a global - // record count as record ID in the JSON output - for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); - } - - // free all records in the list - if (frame_data.data_var.record) - { - mbus_data_record_free(frame_data.data_var.record); - } - - frame_cnt++; - - for (iter = frame->next; iter; iter = iter->next, frame_cnt++) - { - if (mbus_frame_data_parse(iter, &frame_data) == -1) - { - mbus_error_str_set("M-bus variable data parse error."); - return NULL; - } - - // loop through all records in the current frame, using a global - // record count as record ID in the JSON output - for (record = frame_data.data_var.record; record; record = record->next, record_cnt++) - { - if ((buff_size - len) < 1024) - { - buff_size *= 2; - new_buff = (char*) realloc(buff,buff_size); - - if (new_buff == NULL) - { - free(buff); - mbus_data_record_free(frame_data.data_var.record); - return NULL; - } - - buff = new_buff; - } - - len += snprintf(&buff[len], buff_size - len, "%s", - mbus_data_variable_record_json(record, record_cnt, frame_cnt, &(frame_data.data_var.header))); - } - - // free all records in the list - if (frame_data.data_var.record) - { - mbus_data_record_free(frame_data.data_var.record); - } - } - - len += snprintf(&buff[len], buff_size - len, "}}"); - - return buff; - } - } - - return NULL; -} - //------------------------------------------------------------------------------ // diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 3e7d14b8..5ee9dd5e 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,20 +566,6 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); -// -// JSON generating functions -// -int mbus_str_json_encode(unsigned char *dst, const unsigned char *src, size_t max_len); -char *mbus_data_json(mbus_frame_data *data); -char *mbus_data_variable_json(mbus_data_variable *data); -char *mbus_data_fixed_json(mbus_data_fixed *data); -char *mbus_data_error_json(int error); -char *mbus_frame_data_json(mbus_frame_data *data); - -char *mbus_data_variable_header_json(mbus_data_variable_header *header); - -char *mbus_frame_json(mbus_frame *frame); - // // XML generating functions From db21364db9041da20b0fa8eae4332592528e8670 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:33:36 +0100 Subject: [PATCH 130/238] also add iso compatible timestamps into protoco-aux --- mbus/mbus-protocol-aux.c | 118 +++++++++++++++++++-------------------- mbus/mbus-protocol-aux.h | 2 +- mbus/mbus-protocol.h | 1 - 3 files changed, 60 insertions(+), 61 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ea21e747..635c7232 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -154,17 +154,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ - { 0x58, 1.0e-3, "°C", "Flow temperature" }, - { 0x59, 1.0e-2, "°C", "Flow temperature" }, - { 0x5A, 1.0e-1, "°C", "Flow temperature" }, - { 0x5B, 1.0e0, "°C", "Flow temperature" }, - - /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ - { 0x5C, 1.0e-3, "°C", "Return temperature" }, - { 0x5D, 1.0e-2, "°C", "Return temperature" }, - { 0x5E, 1.0e-1, "°C", "Return temperature" }, - { 0x5F, 1.0e0, "°C", "Return temperature" }, + /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ + { 0x58, 1.0e-3, "�C", "Flow temperature" }, + { 0x59, 1.0e-2, "�C", "Flow temperature" }, + { 0x5A, 1.0e-1, "�C", "Flow temperature" }, + { 0x5B, 1.0e0, "�C", "Flow temperature" }, + + /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ + { 0x5C, 1.0e-3, "�C", "Return temperature" }, + { 0x5D, 1.0e-2, "�C", "Return temperature" }, + { 0x5E, 1.0e-1, "�C", "Return temperature" }, + { 0x5F, 1.0e0, "�C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -172,11 +172,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature °C (0.001°C to 1°C) */ - { 0x64, 1.0e-3, "°C", "External temperature" }, - { 0x65, 1.0e-2, "°C", "External temperature" }, - { 0x66, 1.0e-1, "°C", "External temperature" }, - { 0x67, 1.0e0, "°C", "External temperature" }, + /* E110 01nn External Temperature �C (0.001�C to 1�C) */ + { 0x64, 1.0e-3, "�C", "External temperature" }, + { 0x65, 1.0e-2, "�C", "External temperature" }, + { 0x66, 1.0e-1, "�C", "External temperature" }, + { 0x67, 1.0e0, "�C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -608,29 +608,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x258, 1.0e-3, "°F", "Flow temperature" }, - { 0x259, 1.0e-2, "°F", "Flow temperature" }, - { 0x25A, 1.0e-1, "°F", "Flow temperature" }, - { 0x25B, 1.0e0, "°F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x25C, 1.0e-3, "°F", "Return temperature" }, - { 0x25D, 1.0e-2, "°F", "Return temperature" }, - { 0x25E, 1.0e-1, "°F", "Return temperature" }, - { 0x25F, 1.0e0, "°F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ - { 0x260, 1.0e-3, "°F", "Temperature difference" }, - { 0x261, 1.0e-2, "°F", "Temperature difference" }, - { 0x262, 1.0e-1, "°F", "Temperature difference" }, - { 0x263, 1.0e0, "°F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ - { 0x264, 1.0e-3, "°F", "External temperature" }, - { 0x265, 1.0e-2, "°F", "External temperature" }, - { 0x266, 1.0e-1, "°F", "External temperature" }, - { 0x267, 1.0e0, "°F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x258, 1.0e-3, "�F", "Flow temperature" }, + { 0x259, 1.0e-2, "�F", "Flow temperature" }, + { 0x25A, 1.0e-1, "�F", "Flow temperature" }, + { 0x25B, 1.0e0, "�F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x25C, 1.0e-3, "�F", "Return temperature" }, + { 0x25D, 1.0e-2, "�F", "Return temperature" }, + { 0x25E, 1.0e-1, "�F", "Return temperature" }, + { 0x25F, 1.0e0, "�F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ + { 0x260, 1.0e-3, "�F", "Temperature difference" }, + { 0x261, 1.0e-2, "�F", "Temperature difference" }, + { 0x262, 1.0e-1, "�F", "Temperature difference" }, + { 0x263, 1.0e0, "�F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ + { 0x264, 1.0e-3, "�F", "External temperature" }, + { 0x265, 1.0e-2, "�F", "External temperature" }, + { 0x266, 1.0e-1, "�F", "External temperature" }, + { 0x267, 1.0e0, "�F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -642,19 +642,19 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ - { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ + { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ - { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ + { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power § 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, @@ -730,7 +730,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "°C", "Temperature" }, + { 0x38, 1.0e-3, "�C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, @@ -886,7 +886,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 2, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -904,12 +904,12 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, ((record->drh.vib.vif == 0xFD) && (vife == 0x70))) { mbus_data_tm_decode(&time, record->data, 4); - if ((*value_out_str = (char*) malloc(20)) == NULL) + if ((*value_out_str = (char*) malloc(21)) == NULL) { MBUS_ERROR("Unable to allocate memory"); return -1; } - *value_out_str_size = snprintf(*value_out_str, 20, "%04d-%02d-%02dT%02d:%02d:%02d", + *value_out_str_size = snprintf(*value_out_str, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ", (time.tm_year + 1900), (time.tm_mon + 1), time.tm_mday, @@ -921,7 +921,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, else // normal integer { result = mbus_data_int_decode(record->data, 4, &value_out_int); - *value_out_real = value_out_int; + *value_out_real = value_out_int; } break; @@ -939,12 +939,12 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, ((record->drh.vib.vif == 0xFD) && (vife == 0x70))) { mbus_data_tm_decode(&time, record->data, 6); - if ((*value_out_str = (char*) malloc(20)) == NULL) + if ((*value_out_str = (char*) malloc(21)) == NULL) { MBUS_ERROR("Unable to allocate memory"); return -1; } - *value_out_str_size = snprintf(*value_out_str, 20, "%04d-%02d-%02dT%02d:%02d:%02d", + *value_out_str_size = snprintf(*value_out_str, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ", (time.tm_year + 1900), (time.tm_mon + 1), time.tm_mday, @@ -1286,7 +1286,7 @@ mbus_parse_variable_record(mbus_data_record *data) MBUS_ERROR("%s: memory allocation error\n", __PRETTY_FUNCTION__); return NULL; } - + record->storage_number = mbus_data_record_storage_number(data); record->tariff = mbus_data_record_tariff(data); record->device = mbus_data_record_device(data); @@ -2331,7 +2331,7 @@ mbus_probe_secondary_address(mbus_handle *handle, const char *mask, char *matchi if (addr == NULL) { // show error message, but procede with scan - MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", + MBUS_ERROR("Failed to generate secondary address from M-Bus reply frame: %s\n", mbus_error_str()); return MBUS_PROBE_NOTHING; } diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..ccee3eeb 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 5ee9dd5e..85b8c11b 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -566,7 +566,6 @@ int mbus_frame_direction(mbus_frame *frame); // mbus_slave_data *mbus_slave_data_get(size_t i); - // // XML generating functions // From e082b0f622668e4cebbd77067414c4128c9a521a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:52:28 +0100 Subject: [PATCH 131/238] fix encoding --- mbus/mbus-protocol-aux.c | 102 +++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 635c7232..ddf7c0a5 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -154,17 +154,17 @@ mbus_variable_vif vif_table[] = { { 0x56, 1.0e3, "kg/h", "Mass flow" }, { 0x57, 1.0e4, "kg/h", "Mass flow" }, - /* E101 10nn Flow Temperature �C (0.001�C to 1�C) */ - { 0x58, 1.0e-3, "�C", "Flow temperature" }, - { 0x59, 1.0e-2, "�C", "Flow temperature" }, - { 0x5A, 1.0e-1, "�C", "Flow temperature" }, - { 0x5B, 1.0e0, "�C", "Flow temperature" }, - - /* E101 11nn Return Temperature �C (0.001�C to 1�C) */ - { 0x5C, 1.0e-3, "�C", "Return temperature" }, - { 0x5D, 1.0e-2, "�C", "Return temperature" }, - { 0x5E, 1.0e-1, "�C", "Return temperature" }, - { 0x5F, 1.0e0, "�C", "Return temperature" }, + /* E101 10nn Flow Temperature °C (0.001°C to 1°C) */ + { 0x58, 1.0e-3, "°C", "Flow temperature" }, + { 0x59, 1.0e-2, "°C", "Flow temperature" }, + { 0x5A, 1.0e-1, "°C", "Flow temperature" }, + { 0x5B, 1.0e0, "°C", "Flow temperature" }, + + /* E101 11nn Return Temperature °C (0.001°C to 1°C) */ + { 0x5C, 1.0e-3, "°C", "Return temperature" }, + { 0x5D, 1.0e-2, "°C", "Return temperature" }, + { 0x5E, 1.0e-1, "°C", "Return temperature" }, + { 0x5F, 1.0e0, "°C", "Return temperature" }, /* E110 00nn Temperature Difference K (mK to K) */ { 0x60, 1.0e-3, "K", "Temperature difference" }, @@ -172,11 +172,11 @@ mbus_variable_vif vif_table[] = { { 0x62, 1.0e-1, "K", "Temperature difference" }, { 0x63, 1.0e0, "K", "Temperature difference" }, - /* E110 01nn External Temperature �C (0.001�C to 1�C) */ - { 0x64, 1.0e-3, "�C", "External temperature" }, - { 0x65, 1.0e-2, "�C", "External temperature" }, - { 0x66, 1.0e-1, "�C", "External temperature" }, - { 0x67, 1.0e0, "�C", "External temperature" }, + /* E110 01nn External Temperature °C (0.001°C to 1°C) */ + { 0x64, 1.0e-3, "°C", "External temperature" }, + { 0x65, 1.0e-2, "°C", "External temperature" }, + { 0x66, 1.0e-1, "°C", "External temperature" }, + { 0x67, 1.0e0, "°C", "External temperature" }, /* E110 10nn Pressure bar (1mbar to 1000mbar) */ { 0x68, 1.0e-3, "bar", "Pressure" }, @@ -608,29 +608,29 @@ mbus_variable_vif vif_table[] = { { 0x256, 1.0e0, "Reserved", "Reserved" }, { 0x257, 1.0e0, "Reserved", "Reserved" }, - /* E101 10nn Flow Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x258, 1.0e-3, "�F", "Flow temperature" }, - { 0x259, 1.0e-2, "�F", "Flow temperature" }, - { 0x25A, 1.0e-1, "�F", "Flow temperature" }, - { 0x25B, 1.0e0, "�F", "Flow temperature" }, - - /* E101 11nn Return Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x25C, 1.0e-3, "�F", "Return temperature" }, - { 0x25D, 1.0e-2, "�F", "Return temperature" }, - { 0x25E, 1.0e-1, "�F", "Return temperature" }, - { 0x25F, 1.0e0, "�F", "Return temperature" }, - - /* E110 00nn Temperature Difference 10(nn-3) �F 0.001�F to 1�F */ - { 0x260, 1.0e-3, "�F", "Temperature difference" }, - { 0x261, 1.0e-2, "�F", "Temperature difference" }, - { 0x262, 1.0e-1, "�F", "Temperature difference" }, - { 0x263, 1.0e0, "�F", "Temperature difference" }, - - /* E110 01nn External Temperature 10(nn-3) �F 0.001�F to 1�F */ - { 0x264, 1.0e-3, "�F", "External temperature" }, - { 0x265, 1.0e-2, "�F", "External temperature" }, - { 0x266, 1.0e-1, "�F", "External temperature" }, - { 0x267, 1.0e0, "�F", "External temperature" }, + /* E101 10nn Flow Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x258, 1.0e-3, "°F", "Flow temperature" }, + { 0x259, 1.0e-2, "°F", "Flow temperature" }, + { 0x25A, 1.0e-1, "°F", "Flow temperature" }, + { 0x25B, 1.0e0, "°F", "Flow temperature" }, + + /* E101 11nn Return Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x25C, 1.0e-3, "°F", "Return temperature" }, + { 0x25D, 1.0e-2, "°F", "Return temperature" }, + { 0x25E, 1.0e-1, "°F", "Return temperature" }, + { 0x25F, 1.0e0, "°F", "Return temperature" }, + + /* E110 00nn Temperature Difference 10(nn-3) °F 0.001°F to 1°F */ + { 0x260, 1.0e-3, "°F", "Temperature difference" }, + { 0x261, 1.0e-2, "°F", "Temperature difference" }, + { 0x262, 1.0e-1, "°F", "Temperature difference" }, + { 0x263, 1.0e0, "°F", "Temperature difference" }, + + /* E110 01nn External Temperature 10(nn-3) °F 0.001°F to 1°F */ + { 0x264, 1.0e-3, "°F", "External temperature" }, + { 0x265, 1.0e-2, "°F", "External temperature" }, + { 0x266, 1.0e-1, "°F", "External temperature" }, + { 0x267, 1.0e0, "°F", "External temperature" }, /* E110 1nnn Reserved */ { 0x268, 1.0e0, "Reserved", "Reserved" }, @@ -642,19 +642,19 @@ mbus_variable_vif vif_table[] = { { 0x26E, 1.0e0, "Reserved", "Reserved" }, { 0x26F, 1.0e0, "Reserved", "Reserved" }, - /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) �F 0.001�F to 1�F */ - { 0x270, 1.0e-3, "�F", "Cold / Warm Temperature Limit" }, - { 0x271, 1.0e-2, "�F", "Cold / Warm Temperature Limit" }, - { 0x272, 1.0e-1, "�F", "Cold / Warm Temperature Limit" }, - { 0x273, 1.0e0, "�F", "Cold / Warm Temperature Limit" }, + /* E111 00nn Cold / Warm Temperature Limit 10(nn-3) °F 0.001°F to 1°F */ + { 0x270, 1.0e-3, "°F", "Cold / Warm Temperature Limit" }, + { 0x271, 1.0e-2, "°F", "Cold / Warm Temperature Limit" }, + { 0x272, 1.0e-1, "°F", "Cold / Warm Temperature Limit" }, + { 0x273, 1.0e0, "°F", "Cold / Warm Temperature Limit" }, - /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) �C 0.001�C to 1�C */ - { 0x274, 1.0e-3, "�C", "Cold / Warm Temperature Limit" }, - { 0x275, 1.0e-2, "�C", "Cold / Warm Temperature Limit" }, - { 0x276, 1.0e-1, "�C", "Cold / Warm Temperature Limit" }, - { 0x277, 1.0e0, "�C", "Cold / Warm Temperature Limit" }, + /* E111 01nn Cold / Warm Temperature Limit 10(nn-3) °C 0.001°C to 1°C */ + { 0x274, 1.0e-3, "°C", "Cold / Warm Temperature Limit" }, + { 0x275, 1.0e-2, "°C", "Cold / Warm Temperature Limit" }, + { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, + { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power � 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power ° 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, @@ -730,7 +730,7 @@ mbus_variable_vif fixed_table[] = { { 0x36, 1.0e1, "m^3/h", "Volume flow" }, { 0x37, 1.0e2, "m^3/h", "Volume flow" }, - { 0x38, 1.0e-3, "�C", "Temperature" }, + { 0x38, 1.0e-3, "°C", "Temperature" }, { 0x39, 1.0e0, "Units for H.C.A.", "H.C.A." }, From 32a4ddd91123ac3844fcc4b6cb0d2bee4d557dba Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 12 Mar 2018 09:54:30 +0100 Subject: [PATCH 132/238] fix encoding --- mbus/mbus-protocol-aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index ddf7c0a5..8877d62c 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -654,7 +654,7 @@ mbus_variable_vif vif_table[] = { { 0x276, 1.0e-1, "°C", "Cold / Warm Temperature Limit" }, { 0x277, 1.0e0, "°C", "Cold / Warm Temperature Limit" }, - /* E111 1nnn cumul. count max power ° 10(nnn-3) W 0.001W to 10000W */ + /* E111 1nnn cumul. count max power § 10(nnn-3) W 0.001W to 10000W */ { 0x278, 1.0e-3, "W", "Cumul count max power" }, { 0x279, 1.0e-3, "W", "Cumul count max power" }, { 0x27A, 1.0e-1, "W", "Cumul count max power" }, From a8b3304f1835527595467b0b1a57ea8643b68d39 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 08:33:03 +0100 Subject: [PATCH 133/238] revert build/configure to main repo --- build.sh | 3 +-- configure.ac | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 40874a5c..34c2799b 100755 --- a/build.sh +++ b/build.sh @@ -15,8 +15,7 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure \ - && autoreconf + && ./configure fi make diff --git a/configure.ac b/configure.ac index edd30c2d..a2efd560 100644 --- a/configure.ac +++ b/configure.ac @@ -14,9 +14,9 @@ AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/l AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AM_PROG_LIBTOOL # fix for automake 1.11 & 1.12 m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -AM_PROG_LIBTOOL LDFLAGS="$LDFLAGS -version-info 0:8:0" From 2b9909d5e76c6bc314499c218abca02af01fae41 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 13 Mar 2018 08:43:16 +0100 Subject: [PATCH 134/238] retry macbuild --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 34c2799b..40874a5c 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,8 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure + && ./configure \ + && autoreconf fi make From 149bf9b18e4759be6deb2bed53330bc74e978619 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 12:03:40 +0200 Subject: [PATCH 135/238] testwise revert that change to proof if it really was the cause --- mbus/mbus-serial.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 09801e26..ec4f1e7f 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -246,10 +246,10 @@ mbus_serial_data_free(mbus_handle *handle) return; } - if (serial_data->device != NULL) - { + //if (serial_data->device != NULL) + //{ free(serial_data->device); - } + //} free(serial_data); handle->auxdata = NULL; } From 881c5f9e8e27f6f944c41fd311a0ca02625fe3d2 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 15:28:20 +0200 Subject: [PATCH 136/238] add debug logging for segfault on disconnect when device got unplugged --- mbus/mbus-serial.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index ec4f1e7f..130aab54 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -222,12 +222,26 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) int mbus_serial_disconnect(mbus_handle *handle) { + MBUS_ERROR("%s: start disconnect\n", __PRETTY_FUNCTION__); if (handle == NULL) { return -1; } + // Make sure serial connection is open + #ifdef _WIN32 + if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) + #else + if (isatty(handle->fd) == 0) + #endif + { + MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); + //return -1; + } + + MBUS_ERROR("%s: disconnect before close\n", __PRETTY_FUNCTION__); close(handle->fd); + MBUS_ERROR("%s: end disconnect\n", __PRETTY_FUNCTION__); return 0; } @@ -270,7 +284,11 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) } // Make sure serial connection is open + #ifdef _WIN32 + if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) + #else if (isatty(handle->fd) == 0) + #endif { MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); return -1; From 9165fa64a5e230742b4e5306bde35d7e195da349 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 20:23:13 +0200 Subject: [PATCH 137/238] Revert "add debug logging for segfault on disconnect when device got unplugged" This reverts commit 881c5f9e8e27f6f944c41fd311a0ca02625fe3d2. --- mbus/mbus-serial.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index 130aab54..ec4f1e7f 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -222,26 +222,12 @@ mbus_serial_set_baudrate(mbus_handle *handle, long baudrate) int mbus_serial_disconnect(mbus_handle *handle) { - MBUS_ERROR("%s: start disconnect\n", __PRETTY_FUNCTION__); if (handle == NULL) { return -1; } - // Make sure serial connection is open - #ifdef _WIN32 - if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) - #else - if (isatty(handle->fd) == 0) - #endif - { - MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); - //return -1; - } - - MBUS_ERROR("%s: disconnect before close\n", __PRETTY_FUNCTION__); close(handle->fd); - MBUS_ERROR("%s: end disconnect\n", __PRETTY_FUNCTION__); return 0; } @@ -284,11 +270,7 @@ mbus_serial_send_frame(mbus_handle *handle, mbus_frame *frame) } // Make sure serial connection is open - #ifdef _WIN32 - if (GetFileType(getHandle()) != FILE_TYPE_CHAR ) - #else if (isatty(handle->fd) == 0) - #endif { MBUS_ERROR("%s: connection not open\n", __PRETTY_FUNCTION__); return -1; From 072e89cd54da1b5303085a1e928c14039aac6bb9 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 20:26:49 +0200 Subject: [PATCH 138/238] removed logging again and add checks to make sure double disconnect is impossible --- mbus/mbus-serial.c | 6 ++++++ mbus/mbus-tcp.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index ec4f1e7f..a7879191 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -227,7 +227,13 @@ mbus_serial_disconnect(mbus_handle *handle) return -1; } + if (handle->fd == NULL) + { + return -1; + } + close(handle->fd); + handle->fd = NULL; return 0; } diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index bb05f801..77da12b2 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -173,12 +173,18 @@ mbus_tcp_disconnect(mbus_handle *handle) return -1; } + if (handle->fd == NULL) + { + return -1; + } + #ifdef _WIN32 closesocket(handle->fd); WSACleanup(); #else close(handle->fd); #endif + handle->fd = NULL; return 0; } From 3aecabeab49a1972d17a0f5c5ab029ec26b933e9 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 22:05:27 +0200 Subject: [PATCH 139/238] change code to prevent compiler warnings --- mbus/mbus-tcp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 77da12b2..28435940 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -173,7 +173,7 @@ mbus_tcp_disconnect(mbus_handle *handle) return -1; } - if (handle->fd == NULL) + if (handle->fd == -1) { return -1; } @@ -184,7 +184,7 @@ mbus_tcp_disconnect(mbus_handle *handle) #else close(handle->fd); #endif - handle->fd = NULL; + handle->fd = -1; return 0; } From 1c8f27dde81bdd2266535bfe9418440ec43be3df Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 26 Mar 2018 22:15:56 +0200 Subject: [PATCH 140/238] also change to -1 for serial --- mbus/mbus-serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index a7879191..ac6e3e68 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -227,13 +227,13 @@ mbus_serial_disconnect(mbus_handle *handle) return -1; } - if (handle->fd == NULL) + if (handle->fd == -1) { return -1; } close(handle->fd); - handle->fd = NULL; + handle->fd = -1; return 0; } From e7198cea5a5a4452d5cd009c4ef9c9bea77c8a77 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Mar 2018 17:10:46 +0200 Subject: [PATCH 141/238] remove one change ... mac ok again? --- build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 40874a5c..34c2799b 100755 --- a/build.sh +++ b/build.sh @@ -15,8 +15,7 @@ else *) libtoolize --ltdl --copy --force ;; esac \ && automake --add-missing --copy \ && autoconf \ - && ./configure \ - && autoreconf + && ./configure fi make From cddd857d398cb2bb1e4b787fd57bd80bee87aec4 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 28 Mar 2018 20:24:56 +0200 Subject: [PATCH 142/238] sync with master --- mbus/mbus-serial.c | 2 +- mbus/mbus-tcp.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-serial.c b/mbus/mbus-serial.c index ac6e3e68..cc4b3431 100755 --- a/mbus/mbus-serial.c +++ b/mbus/mbus-serial.c @@ -227,7 +227,7 @@ mbus_serial_disconnect(mbus_handle *handle) return -1; } - if (handle->fd == -1) + if (handle->fd < 0) { return -1; } diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 28435940..7d784368 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -173,7 +173,7 @@ mbus_tcp_disconnect(mbus_handle *handle) return -1; } - if (handle->fd == -1) + if (handle->fd < 0) { return -1; } From 05134e7e608111455ce64dfe9293cd7bffcd686a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 23 Apr 2018 22:38:30 +0200 Subject: [PATCH 143/238] try offering FCB function --- mbus/mbus-protocol-aux.c | 36 ++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol-aux.h | 5 +++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 8877d62c..ff3ed572 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1930,6 +1930,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..143c7eee 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; @@ -293,7 +293,8 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * * @return Zero when successful. */ -int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle From bdf0a92547276fc3e324667959fe15e6da8bb228 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 23 Apr 2018 22:49:15 +0200 Subject: [PATCH 144/238] try to allow sending request with set FCB bit when seected correctly before --- mbus/mbus-protocol-aux.c | 36 ++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol-aux.h | 1 + 2 files changed, 37 insertions(+) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index f9e2b4d4..8742f2a2 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1933,6 +1933,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index ccee3eeb..9b97b070 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -294,6 +294,7 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * @return Zero when successful. */ int mbus_send_request_frame(mbus_handle * handle, int address); +int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle From 075ae5cdd15a633835990d4f89074f6b5dd9437e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 23 Apr 2018 22:38:30 +0200 Subject: [PATCH 145/238] try offering FCB function --- mbus/mbus-protocol-aux.c | 36 ++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol-aux.h | 5 +++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 8877d62c..ff3ed572 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1930,6 +1930,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..143c7eee 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; @@ -293,7 +293,8 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * * @return Zero when successful. */ -int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle From 132bdafc38ccf655d55ca5f7216be277ad5e6c83 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 20 Feb 2019 21:51:07 +0100 Subject: [PATCH 146/238] Implement negative BCD number (Type A) According to W4B21021.pdf Appendix A a hex code Fh in the MSD position signals a negative BCD number. (cherry picked from commit 2f9fa5ccc8aa032556ab77b7cafcb24670b6bf8d) --- mbus/mbus-protocol.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 703b5dfd..8e91ecd2 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -466,9 +466,9 @@ mbus_data_bcd_encode(unsigned char *bcd_data, size_t bcd_data_size, int value) int v0, v1, v2, x1, x2; size_t i; - if (bcd_data && bcd_data_size && (value >= 0)) + if (bcd_data && bcd_data_size) { - v2 = value; + v2 = abs(value); for (i = 0; i < bcd_data_size; i++) { @@ -482,6 +482,11 @@ mbus_data_bcd_encode(unsigned char *bcd_data, size_t bcd_data_size, int value) bcd_data[bcd_data_size-1-i] = (x2 << 4) | x1; } + if (value < 0) + { + bcd_data[bcd_data_size-1] |= 0xF0; + } + return 0; } @@ -503,8 +508,20 @@ mbus_data_bcd_decode(unsigned char *bcd_data, size_t bcd_data_size) { for (i = bcd_data_size; i > 0; i--) { - val = (val * 10) + ((bcd_data[i-1]>>4) & 0xF); - val = (val * 10) + ( bcd_data[i-1] & 0xF); + val *= 10; + + if (bcd_data[i-1]>>4 < 0xA) + { + val += ((bcd_data[i-1]>>4) & 0xF); + } + + val = (val * 10) + (bcd_data[i-1] & 0xF); + } + + // hex code Fh in the MSD position signals a negative BCD number + if (bcd_data[bcd_data_size-1]>>4 == 0xF) + { + val *= -1; } return val; From 7986caa299562708f65fd8014054fc53e36081a3 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 20 Feb 2019 21:58:28 +0100 Subject: [PATCH 147/238] Add product string of Hydrometer Sharky 775 (cherry picked from commit 36a85d373781f5772a21a13ec46047f0fcecc2ed) --- mbus/mbus-protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 8e91ecd2..7d2691a5 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -508,14 +508,14 @@ mbus_data_bcd_decode(unsigned char *bcd_data, size_t bcd_data_size) { for (i = bcd_data_size; i > 0; i--) { - val *= 10; + val = (val * 10); if (bcd_data[i-1]>>4 < 0xA) { val += ((bcd_data[i-1]>>4) & 0xF); } - val = (val * 10) + (bcd_data[i-1] & 0xF); + val = (val * 10) + ( bcd_data[i-1] & 0xF); } // hex code Fh in the MSD position signals a negative BCD number @@ -1110,6 +1110,9 @@ mbus_data_product_name(mbus_data_variable_header *header) case 0x28: strcpy(buff,"ABB F95 Typ US770"); break; + case 0x2F: + strcpy(buff,"Hydrometer Sharky 775"); + break; } } else if (manufacturer == mbus_manufacturer_id("JAN")) From 5b93cebbb23a22dfe3a152c609480a30f8d85dae Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Fri, 22 Feb 2019 19:08:04 +0100 Subject: [PATCH 148/238] Prepare new release 0.9.0 (cherry picked from commit 2dc3daaf7080cb77640e6caee3154585b8196a37) --- configure.ac | 4 ++-- libmbus.spec | 17 ++++++++++------- release_notes.txt | 9 +++++++++ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index a2efd560..b99ef16a 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ dnl ---------------------------------------------------------------------------- LT_CONFIG_LTDL_DIR([libltdl]) -AC_INIT([libmbus], [0.8.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) AC_CONFIG_AUX_DIR([libltdl/config]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) @@ -18,7 +18,7 @@ AM_PROG_LIBTOOL # fix for automake 1.11 & 1.12 m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) -LDFLAGS="$LDFLAGS -version-info 0:8:0" +LDFLAGS="$LDFLAGS -version-info 0:9:0" dnl ---------------------- dnl diff --git a/libmbus.spec b/libmbus.spec index 57f9678b..06160f75 100644 --- a/libmbus.spec +++ b/libmbus.spec @@ -11,10 +11,10 @@ Summary: Open source M-bus (Meter-Bus) library Name: libmbus -Version: 0.8.0 +Version: 0.9.0 Release: 1 -Source: http://www.rscada.se/public-dist/%{name}-%{version}.tar.gz -URL: http://www.rscada.se/libmbus/ +Source: https://github.com/rscada/%{name}/archive/%{version}.tar.gz +URL: https://github.com/rscada/libmbus/ License: BSD Vendor: Raditex Control AB Packager: Stefan Wahren @@ -68,9 +68,8 @@ rm -rf "%buildroot" %{_bindir}/mbus-serial-* %{_bindir}/mbus-tcp-* %{_libdir}/libmbus.so* -# man pages doesn't exist in this version -# %{_mandir}/man1/libmbus.1 -# %{_mandir}/man1/mbus-* +%{_mandir}/man1/libmbus.1 +%{_mandir}/man1/mbus-* %files devel %defattr (-,root,root) @@ -80,5 +79,9 @@ rm -rf "%buildroot" %{_libdir}/pkgconfig/libmbus.pc %changelog +* Fri Feb 22 2019 Stefan Wahren - 0.9.0-1 +- switch to github repo +- enable man pages + * Fri Mar 29 2013 Stefan Wahren - 0.8.0-1 -- Initial package based on the last official release \ No newline at end of file +- Initial package based on the last official release diff --git a/release_notes.txt b/release_notes.txt index 6929cc6e..a5b14b94 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,5 +1,14 @@ Release notes for libmbus +Version 0.9.0 (2019-02-22): + +Added support for negative BCD numbers (type A) and date time CP48 (type I), +new program (set primary address), extended XML output (storage number, +tariff, device), echo cancelation and better retry handling. Also this version +has countless bug fixes. + +Many thanks to all contributers + Version 0.8.0 (2012-06-18): -------------------------- From ed8cabb6009c400b75febeae7ab3770c13ca380a Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Sun, 5 May 2019 10:23:27 +0200 Subject: [PATCH 149/238] try appveyor build again --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index a5b2b0d4..2614f129 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,5 +6,6 @@ configuration: - Debug - Release clone_folder: 'c:\projects\%APPVEYOR_PROJECT_NAME%' +build: MSBuild test_script: - echo %cd% From 3920410963ea6f7295bbd40753bed541a82301ef Mon Sep 17 00:00:00 2001 From: lvogt <36930594+lvogt@users.noreply.github.com> Date: Mon, 8 Jul 2019 10:38:20 +0200 Subject: [PATCH 150/238] Fix prefixes (#148) (cherry picked from commit 62ac3678ffb343560cb5d42fcc83ed35b1f5afa8) --- mbus/mbus-protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 7d2691a5..ac061ffb 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -1584,7 +1584,7 @@ mbus_data_fixed_unit(int medium_unit_byte) snprintf(buff, sizeof(buff), "10 m^3"); break; case 0x2E: - snprintf(buff, sizeof(buff), "m^3"); + snprintf(buff, sizeof(buff), "100 m^3"); break; case 0x2F: @@ -1828,7 +1828,7 @@ mbus_unit_prefix(int exp) break; case 9: - snprintf(buff, sizeof(buff), "T"); + snprintf(buff, sizeof(buff), "G"); break; default: From f5a73d2d1bd883943698dd00c676e639dc1dbcd8 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 16 Oct 2019 23:00:46 +0200 Subject: [PATCH 151/238] make sure VERSION define is there (also for MacOS) --- mbus/mbus.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mbus/mbus.c b/mbus/mbus.c index df584e92..d5dca2e6 100644 --- a/mbus/mbus.c +++ b/mbus/mbus.c @@ -15,6 +15,11 @@ #else #include "../config.h" #endif + +#ifndef VERSION +#define VERSION "0.9.0" +#endif + // // // From 324b2420f94b5646964299c4c78a86b81f7c0a4b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 23 Apr 2018 22:38:30 +0200 Subject: [PATCH 152/238] try offering FCB function --- mbus/mbus-protocol-aux.c | 36 ++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol-aux.h | 5 +++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 5ddba9fb..c932f7e1 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1924,6 +1924,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..143c7eee 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; @@ -293,7 +293,8 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * * @return Zero when successful. */ -int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle From 1b1887043be6c4325d49e23a6dfff863a64752b9 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Sat, 21 Mar 2020 10:50:33 +0100 Subject: [PATCH 153/238] refactor: clean up some compiler warnings (#152) (cherry picked from commit 6edab86078b33f6c870215df2fb605b8fb2fab60) --- mbus/mbus-protocol-aux.c | 8 +------- test/mbus_parse.c | 3 ++- test/mbus_parse_hex.c | 5 +++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 8742f2a2..2bb52d88 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -788,8 +788,6 @@ mbus_register_found_event(mbus_handle * handle, void (*event)(mbus_handle * hand int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, double *value_out, char **quantity_out) { - double exponent = 0.0; - int i; medium_unit = medium_unit & 0x3F; if (unit_out == NULL || value_out == NULL || quantity_out == NULL) @@ -810,7 +808,7 @@ int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, do break; default: - for(i=0; fixed_table[i].vif < 0xfff; ++i) + for(int i=0; fixed_table[i].vif < 0xfff; ++i) { if (fixed_table[i].vif == medium_unit) { @@ -823,7 +821,6 @@ int mbus_fixed_normalize(int medium_unit, long medium_value, char **unit_out, do *unit_out = strdup("Unknown"); *quantity_out = strdup("Unknown"); - exponent = 0.0; *value_out = 0.0; return -1; } @@ -838,7 +835,6 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, unsigned char vif, vife; struct tm time; int value_out_int; - long value_out_long; long long value_out_long_long; *value_out_real = 0.0; *value_out_str = NULL; @@ -1041,7 +1037,6 @@ int mbus_vif_unit_normalize(int vif, double value, char **unit_out, double *value_out, char **quantity_out) { int i; - double exponent = 1.0; unsigned newVif = vif & 0xF7F; /* clear extension bit */ MBUS_DEBUG("vif_unit_normalize = 0x%03X \n", vif); @@ -1066,7 +1061,6 @@ mbus_vif_unit_normalize(int vif, double value, char **unit_out, double *value_ou MBUS_ERROR("%s: Unknown VIF 0x%03X\n", __PRETTY_FUNCTION__, newVif); *unit_out = strdup("Unknown (VIF=0x%.02X)"); *quantity_out = strdup("Unknown"); - exponent = 0.0; *value_out = 0.0; return -1; } diff --git a/test/mbus_parse.c b/test/mbus_parse.c index 2421d908..4c99da66 100644 --- a/test/mbus_parse.c +++ b/test/mbus_parse.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { FILE *fp = NULL; - size_t buff_len, len; + size_t len; int normalized = 0; unsigned char buf[1024]; mbus_frame reply; @@ -53,6 +53,7 @@ main(int argc, char *argv[]) if (ferror(fp) != 0) { fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file); + fclose(fp); return 1; } diff --git a/test/mbus_parse_hex.c b/test/mbus_parse_hex.c index 2cd1ce2d..0d6b2686 100644 --- a/test/mbus_parse_hex.c +++ b/test/mbus_parse_hex.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { FILE *fp = NULL; - size_t buff_len, len; + size_t buff_len; int result, normalized = 0; unsigned char raw_buff[4096], buff[4096]; mbus_frame reply; @@ -48,11 +48,12 @@ main(int argc, char *argv[]) } memset(raw_buff, 0, sizeof(raw_buff)); - len = fread(raw_buff, 1, sizeof(raw_buff), fp); + fread(raw_buff, 1, sizeof(raw_buff), fp); if (ferror(fp) != 0) { fprintf(stderr, "%s: failed to read '%s'\n", argv[0], file); + fclose(fp); return 1; } From 9e1c52dc748e4ea4ad7ff03bfdc93398199ad5ee Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 17 Mar 2020 21:25:08 +0100 Subject: [PATCH 154/238] build: add cmake support feat: add cmake support chore: remove old code revert: remove mbus_data_record_unit build: do not break existing building system (cherry picked from commit d96dcfad09e885a6e440eb00bbb016afd75bb105) --- .gitignore | 7 +- CMakeLists.txt | 150 ++++++++++++++++++++++++++++++++++++++++++ README.md | 32 ++++++++- bin/CMakeLists.txt | 19 ++++++ build.sh | 24 ++----- cmake/Config.cmake.in | 4 ++ mbus/config.h.in | 59 +++++++++++++++++ test/CMakeLists.txt | 5 ++ 8 files changed, 279 insertions(+), 21 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 bin/CMakeLists.txt create mode 100644 cmake/Config.cmake.in create mode 100644 mbus/config.h.in create mode 100644 test/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 085383d5..1136a1aa 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ test/Makefile.in /compile config.guess config.sub -config.h.in configure /depcomp /install-sh @@ -72,3 +71,9 @@ test/test-frames/*.xml.new test/error-frames/*.xml.new test/unsupported-frames/*.xml.new +/build/ +_build/ + +# IDE +/.vscode/ +CMakeLists.txt.user \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..d3dafe4b --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,150 @@ +cmake_minimum_required(VERSION 3.5) + +project(libmbus LANGUAGES CXX C) + +set(PROJECT_VERSION "0.9.0") + +if(CMAKE_BUILD_TYPE STREQUAL "") + message(STATUS "CMAKE_BUILD_TYPE empty setting to Debug") + set(CMAKE_BUILD_TYPE "Debug") +endif() + +option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) +option(LIBMBUS_BUILD_TESTS "build tests" OFF) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_C_STANDARD 11) + +# Append our module directory to CMake +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) + +# Set the output of the libraries and executables. +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) + +# +# static analysis +# + +if(LIBMBUS_RUN_CLANG_TIDY) + find_program( + CLANG_TIDY_EXE + NAMES "clang-tidy" + DOC "/usr/bin/clang-tidy") + if(NOT CLANG_TIDY_EXE) + message(WARNING "clang-tidy not found.") + else() + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}") + endif() +endif(LIBMBUS_RUN_CLANG_TIDY) + +include(CheckIncludeFile) + +check_include_file(dlfcn.h HAVE_DLFCN_H) +check_include_file(inttypes.h HAVE_INTTYPES_H) +check_include_file(memory.h HAVE_MEMORY_H) +check_include_file(stdlib.h HAVE_STDINT_H) +check_include_file(stdint.h HAVE_STDLIB_H) +check_include_file(strings.h HAVE_STRINGS_H) +check_include_file(string.h HAVE_STRING_H) +check_include_file(sys/stat.h HAVE_SYS_STAT_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(unistd.h HAVE_UNISTD_H) + +# +# library +# +set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") + +set(PACKAGE_VERSION "${PROJECT_VERSION}") +set(VERSION "${PROJECT_VERSION}") +configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in + ${CMAKE_CURRENT_LIST_DIR}/config.h) + +add_library( + ${PROJECT_NAME} + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.c + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.h + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.c + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.h + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.c + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.h + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.c + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.h + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c + ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h) +target_include_directories( + ${PROJECT_NAME} + PUBLIC $ + $ + $) +target_link_libraries(${PROJECT_NAME} PRIVATE m) +target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) + +if(CLANG_TIDY_EXE) + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY + "${DO_CLANG_TIDY}") +endif() + +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + +# +# examples +# + +if(LIBMBUS_BUILD_EXAMPLES) + message(STATUS "building examples") + add_subdirectory(bin) +endif() + +# +# tests +# + +if(LIBMBUS_BUILD_TESTS) + message(STATUS "building tests") + enable_testing() + add_subdirectory(test) +endif() + +# +# install +# + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) + +set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) +install( + TARGETS ${PROJECT_NAME} + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib) + +install( + EXPORT ${PROJECT_NAME}Targets + DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} + NAMESPACE ${PROJECT_NAME}:: + COMPONENT dev) + +configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR}) +write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake + COMPATIBILITY SameMajorVersion) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} + COMPONENT dev) + +# BUG: installing empty dirs https://gitlab.kitware.com/cmake/cmake/issues/17122 +install( + DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/mbus/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mbus/ + COMPONENT dev + FILES_MATCHING + PATTERN "*.h") diff --git a/README.md b/README.md index 27d393c0..133c243d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) ![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) +# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) + +![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) libmbus is an open source library for the M-bus (Meter-Bus) protocol. @@ -8,4 +10,32 @@ signals on the M-Bus, and the protocol and data format used in transmissions on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle the communication with M-Bus devices. + +## BUILD + +with cmake + +```bash +rm -rf _build +mkdir _build +cd _build +# configure +# e.g. on linux +cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON +# e.g. for a target device +cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/foo-bar-baz.cmake +# compile +cmake --build . -j +# install - optional +cmake --build . --target install +``` + +## CONSUME + +```cmake +find_package(libmbus) +add_executable(my_app main.cpp) +target_link_libraries(my_app libmbus::libmbus) +``` + For more information see http://www.rscada.se/libmbus diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt new file mode 100644 index 00000000..73e15002 --- /dev/null +++ b/bin/CMakeLists.txt @@ -0,0 +1,19 @@ +function(add_example SRCS) + add_executable(${SRCS} ${CMAKE_CURRENT_LIST_DIR}/${SRCS}.c) + target_link_libraries(${SRCS} PRIVATE libmbus::libmbus) +endfunction() + +add_example(mbus-serial-request-data) +add_example(mbus-serial-request-data-multi-reply) +add_example(mbus-serial-scan) +add_example(mbus-serial-scan-secondary) +add_example(mbus-serial-select-secondary) +add_example(mbus-serial-set-address) +add_example(mbus-serial-switch-baudrate) +add_example(mbus-tcp-application-reset) +add_example(mbus-tcp-raw-send) +add_example(mbus-tcp-request-data) +add_example(mbus-tcp-request-data-multi-reply) +add_example(mbus-tcp-scan) +add_example(mbus-tcp-scan-secondary) +add_example(mbus-tcp-select-secondary) diff --git a/build.sh b/build.sh index 34c2799b..d4ce3c74 100755 --- a/build.sh +++ b/build.sh @@ -1,21 +1,7 @@ #!/bin/sh -# -if [ -f Makefile ]; then - # use existing automake files - echo >> /dev/null -else - # regenerate automake files - echo "Running autotools..." - - autoheader \ - && aclocal \ - && case \ - $(uname) in Darwin*) glibtoolize --ltdl --copy --force ;; \ - *) libtoolize --ltdl --copy --force ;; esac \ - && automake --add-missing --copy \ - && autoconf \ - && ./configure -fi - -make +rm -rf _build +mkdir _build +cd _build +cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON +cmake --build . diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 00000000..9c15f36a --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,4 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/mbus/config.h.in b/mbus/config.h.in new file mode 100644 index 00000000..369c7c80 --- /dev/null +++ b/mbus/config.h.in @@ -0,0 +1,59 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_MEMORY_H "@HAVE_MEMORY_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDINT_H "@HAVE_STDINT_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STDLIB_H "@HAVE_STDLIB_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRINGS_H "@HAVE_STRINGS_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_STRING_H "@HAVE_STRING_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_STAT_H "@HAVE_SYS_STAT_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TYPES_H "@HAVE_SYS_TYPES_H@" + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H "@HAVE_UNISTD_H@" + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libmbus" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "info@rscada.se" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libmbus" + +/* Define to the full name and version of this package. */ +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libmbus" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.rscada.se/libmbus/" + +/* Define to the version of this package. */ +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" + +/* Version number of package */ +#cmakedefine VERSION "@PACKAGE_VERSION@" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..0303d236 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(mbus_parse ${CMAKE_CURRENT_LIST_DIR}/mbus_parse.c) +target_link_libraries(mbus_parse PRIVATE libmbus::libmbus) + +add_executable(mbus_parse_hex ${CMAKE_CURRENT_LIST_DIR}/mbus_parse_hex.c) +target_link_libraries(mbus_parse_hex PRIVATE libmbus::libmbus) From 5ceab3c61e1a05fa85f8f46d5c432b1e0d04ee31 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Fri, 20 Mar 2020 15:38:29 +0100 Subject: [PATCH 155/238] build: add coverage information (cherry picked from commit 89db118821b39943a38dd24a8b3e4b675782d7cf) --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d3dafe4b..4e9ce4f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ endif() option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) option(LIBMBUS_BUILD_TESTS "build tests" OFF) +option(LIBMBUS_ENABLE_COVERAGE "Build with coverage support" ON) +option(LIBMBUS_RUN_CLANG_TIDY "Use Clang-Tidy for static analysis" OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -42,6 +44,35 @@ if(LIBMBUS_RUN_CLANG_TIDY) endif() endif(LIBMBUS_RUN_CLANG_TIDY) +if(LIBMBUS_ENABLE_COVERAGE) + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message( + WARNING + "Code coverage results with an optimised (non-Debug) build may be misleading" + ) + endif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + # https://discuss.circleci.com/t/problems-using-lcov-gcov-for-c-code/13898 + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # using Clang + message(STATUS "Not doing coverage...") + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # using GCC + message(STATUS "Building with code coverage...") + set(CMAKE_BUILD_TYPE DEBUG) + set(CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage" + ) + set(CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage " + ) + set(CMAKE_EXE_LINKER_FLAGS + "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") + set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") + link_libraries(-lgcov) + endif() +endif() + include(CheckIncludeFile) check_include_file(dlfcn.h HAVE_DLFCN_H) From a015027c7c622a1adc2fbbfaa08e8eedb030be05 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 09:22:41 +0100 Subject: [PATCH 156/238] build: add debian package (cherry picked from commit e864d27fbf175607cb972e979043d378dfa31cbd) --- CMakeLists.txt | 128 ++++++++++++++++++++++++++++++---------------- cmake-format.yaml | 15 ++++++ 2 files changed, 99 insertions(+), 44 deletions(-) create mode 100644 cmake-format.yaml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e9ce4f5..477ddf84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,23 @@ cmake_minimum_required(VERSION 3.5) -project(libmbus LANGUAGES CXX C) - -set(PROJECT_VERSION "0.9.0") +project(libmbus LANGUAGES CXX C VERSION "0.9.0") if(CMAKE_BUILD_TYPE STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE empty setting to Debug") set(CMAKE_BUILD_TYPE "Debug") endif() +# ############################################################################## +# default options -> changed with e.g. cd build && cmake .. +# -DLIBMBUS_BUILD_TESTS=ON +# ############################################################################## + option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) option(LIBMBUS_BUILD_TESTS "build tests" OFF) -option(LIBMBUS_ENABLE_COVERAGE "Build with coverage support" ON) -option(LIBMBUS_RUN_CLANG_TIDY "Use Clang-Tidy for static analysis" OFF) +option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" ON) +option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) +option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) +option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -27,9 +32,9 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) -# +# ############################################################################## # static analysis -# +# ############################################################################## if(LIBMBUS_RUN_CLANG_TIDY) find_program( @@ -46,12 +51,9 @@ endif(LIBMBUS_RUN_CLANG_TIDY) if(LIBMBUS_ENABLE_COVERAGE) if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - message( - WARNING - "Code coverage results with an optimised (non-Debug) build may be misleading" - ) - endif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") - # https://discuss.circleci.com/t/problems-using-lcov-gcov-for-c-code/13898 + message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") + endif() + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # using Clang message(STATUS "Not doing coverage...") @@ -59,16 +61,10 @@ if(LIBMBUS_ENABLE_COVERAGE) # using GCC message(STATUS "Building with code coverage...") set(CMAKE_BUILD_TYPE DEBUG) - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage" - ) - set(CMAKE_C_FLAGS - "${CMAKE_C_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage " - ) - set(CMAKE_EXE_LINKER_FLAGS - "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") - set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage ") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") link_libraries(-lgcov) endif() endif() @@ -86,15 +82,15 @@ check_include_file(sys/stat.h HAVE_SYS_STAT_H) check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(unistd.h HAVE_UNISTD_H) -# +# ############################################################################## # library -# +# ############################################################################## + set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") set(PACKAGE_VERSION "${PROJECT_VERSION}") set(VERSION "${PROJECT_VERSION}") -configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in - ${CMAKE_CURRENT_LIST_DIR}/config.h) +configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_DIR}/config.h) add_library( ${PROJECT_NAME} @@ -109,32 +105,29 @@ add_library( ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h) target_include_directories( - ${PROJECT_NAME} - PUBLIC $ - $ - $) + ${PROJECT_NAME} PUBLIC $ $ + $) target_link_libraries(${PROJECT_NAME} PRIVATE m) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) if(CLANG_TIDY_EXE) - set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY - "${DO_CLANG_TIDY}") + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}") endif() add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) -# +# ############################################################################## # examples -# +# ############################################################################## if(LIBMBUS_BUILD_EXAMPLES) message(STATUS "building examples") add_subdirectory(bin) endif() -# +# ############################################################################## # tests -# +# ############################################################################## if(LIBMBUS_BUILD_TESTS) message(STATUS "building tests") @@ -142,9 +135,9 @@ if(LIBMBUS_BUILD_TESTS) add_subdirectory(test) endif() -# +# ############################################################################## # install -# +# ############################################################################## include(GNUInstallDirs) include(CMakePackageConfigHelpers) @@ -162,20 +155,67 @@ install( NAMESPACE ${PROJECT_NAME}:: COMPONENT dev) -configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake - INSTALL_DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR}) -write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake - COMPATIBILITY SameMajorVersion) +configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION + ${LIBMBUS_CONFIG_INSTALL_DIR}) +write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY SameMajorVersion) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} COMPONENT dev) -# BUG: installing empty dirs https://gitlab.kitware.com/cmake/cmake/issues/17122 install( DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/mbus/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mbus/ COMPONENT dev FILES_MATCHING PATTERN "*.h") + +# ############################################################################## +# package +# mkdir build ; cd build ; cmake .. -DLIBMBUS_PACKAGE_DEB=ON ; cpack .. +# ############################################################################## + +include(InstallRequiredSystemLibraries) + +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open source M-bus (Meter-Bus) library.") +set(CPACK_PACKAGE_DESCRIPTION + "libmbus is an open source library for the M-bus (Meter-Bus) protocol. +The Meter-Bus is a standard for reading out meter data from electricity meters, +heat meters, gas meters, etc. The M-bus standard deals with both the electrical +signals on the M-Bus, and the protocol and data format used in transmissions +on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle +the communication with M-Bus devices. + +For more information see http://www.rscada.se/libmbus") + +set(CPACK_PACKAGE_VENDOR "Raditex Control AB") +set(CPACK_PACKAGE_CONTACT "Stefan Wahren ") +set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/rscada/libmbus/") +set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") +set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") +set(CPACK_PACKAGE_RELEASE 1) +set(CPACK_COMPONENTS_ALL devel libs) +set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) + +set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") +set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_COMPONENTS_ALL Libraries ApplicationData) + +if(LIBMBUS_PACKAGE_DEB) + set(CPACK_GENERATOR "DEB") + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Stefan Wahren ") + set(CPACK_DEBIAN_PACKAGE_SECTION "Development/Languages/C and C++") + set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) + set(CPACK_DEBIAN_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}" + ) +endif() + +if(LIBMBUS_PACKAGE_RPM) + set(CPACK_GENERATOR "RPM") + set(CPACK_RPM_PACKAGE_LICENSE "BSD") +endif() + +include(CPack) diff --git a/cmake-format.yaml b/cmake-format.yaml new file mode 100644 index 00000000..60329ed6 --- /dev/null +++ b/cmake-format.yaml @@ -0,0 +1,15 @@ +# https://github.com/cheshirekow/cmake_format + +# How wide to allow formatted cmake files +line_width: 120 + +# How many spaces to tab for indent +tab_size: 2 + +# Format command names consistently as 'lower' or 'upper' case +command_case: "lower" + +first_comment_is_literal: False + +# enable comment markup parsing and reflow +enable_markup: False From 9f1cbe10b7f8aa93064785ecb7b6480d3d519871 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 09:38:47 +0100 Subject: [PATCH 157/238] feat: add github actions * feat: add github actions * Update ccpp.yml * build: build and install deb in container * build: clean up (cherry picked from commit 433b3c4219a2cff611c4cfe5967697e89872c034) --- .github/workflows/ccpp.yml | 20 ++++++++++++++++++++ build.sh | 10 ++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/ccpp.yml diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml new file mode 100644 index 00000000..fcf122bd --- /dev/null +++ b/.github/workflows/ccpp.yml @@ -0,0 +1,20 @@ +name: CMake + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: build examples and tests + run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON && cmake --build . -j + + debian: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: build debian package + run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_PACKAGE_DEB=ON && cpack .. && sudo dpkg -i *.deb && ls /usr/lib diff --git a/build.sh b/build.sh index d4ce3c74..2179070f 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,17 @@ #!/bin/sh + rm -rf _build mkdir _build cd _build cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON cmake --build . + +# build deb + +# rm -rf _build +# mkdir _build +# cd _build +# cmake .. -DLIBMBUS_PACKAGE_DEB=ON +# cpack .. +# dpkg -i *.deb From 7a93d1999f76fcd9c39b89e9e7be28592c54a3f9 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 11:11:43 +0100 Subject: [PATCH 158/238] build: add dockerfiles for deb and rpm (cherry picked from commit 576da85302951406d1c470bf9f4420f6f0301db4) --- .dockerignore | 2 ++ Dockerfile.deb | 14 ++++++++++++++ Dockerfile.rpm | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile.deb create mode 100644 Dockerfile.rpm diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..caa4fdd8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/_build +/build diff --git a/Dockerfile.deb b/Dockerfile.deb new file mode 100644 index 00000000..1db6923d --- /dev/null +++ b/Dockerfile.deb @@ -0,0 +1,14 @@ +# docker build . -f Dockerfile.deb -t deb_builder + +FROM ubuntu + +RUN apt update -y && apt install -y cmake gcc g++ make +COPY . /tmp +RUN cd /tmp && \ + mkdir build && \ + cd build && \ + cmake .. -DLIBMBUS_PACKAGE_DEB=ON && \ + cpack .. && \ + ls -al && \ + dpkg -i *.deb + diff --git a/Dockerfile.rpm b/Dockerfile.rpm new file mode 100644 index 00000000..2f70df96 --- /dev/null +++ b/Dockerfile.rpm @@ -0,0 +1,14 @@ +# docker build . -f Dockerfile.rpm -t rpm_builder + +FROM fedora + +RUN dnf install -y cmake gcc g++ make rpm-build +COPY . /tmp +RUN cd /tmp && \ + mkdir build && \ + cd build && \ + cmake .. -DLIBMBUS_PACKAGE_RPM=ON && \ + cpack .. && \ + ls -al && \ + rpm -i *.rpm + From b1b44a50d66b1aa9f4b22bf9c9481df1969dc1c9 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 13:41:26 +0100 Subject: [PATCH 159/238] build: add documentation (cherry picked from commit 5a3d13e7add6aefc733f59ca9bf3d1aa38003237) --- .github/workflows/ccpp.yml | 8 +++++++ CMakeLists.txt | 43 ++++++++++++++++++++++++++++++++++++-- doxygen.cfg => Doxyfile.in | 9 +++++--- build.sh | 7 +++++++ 4 files changed, 62 insertions(+), 5 deletions(-) rename doxygen.cfg => Doxyfile.in (99%) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index fcf122bd..a2e06292 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -18,3 +18,11 @@ jobs: - uses: actions/checkout@v2 - name: build debian package run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_PACKAGE_DEB=ON && cpack .. && sudo dpkg -i *.deb && ls /usr/lib + + doc: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: build doxygen documentation + run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_DOCS=ON && cmake --build . --target doc + diff --git a/CMakeLists.txt b/CMakeLists.txt index 477ddf84..000d633b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ cmake_minimum_required(VERSION 3.5) -project(libmbus LANGUAGES CXX C VERSION "0.9.0") +project( + libmbus + LANGUAGES CXX C + VERSION "0.9.0") if(CMAKE_BUILD_TYPE STREQUAL "") message(STATUS "CMAKE_BUILD_TYPE empty setting to Debug") @@ -18,6 +21,7 @@ option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" ON) option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) +option(LIBMBUS_BUILD_DOCS "build documentation" OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -200,7 +204,8 @@ set(CPACK_COMPONENTS_ALL devel libs) set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +set(CPACK_PACKAGE_FILE_NAME + "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") set(CPACK_COMPONENTS_ALL Libraries ApplicationData) if(LIBMBUS_PACKAGE_DEB) @@ -219,3 +224,37 @@ if(LIBMBUS_PACKAGE_RPM) endif() include(CPack) + +# ############################################################################## +# doc +# mkdir build ; cd build ; cmake .. -DLIBMBUS_BUILD_DOCS=ON ; cmake --build . --target doc +# ############################################################################## + +if(LIBMBUS_BUILD_DOCS) + message(STATUS "building with documentation") + # Generate targets for documentation + # check if Doxygen is installed + find_package(Doxygen) + + if(Doxygen_FOUND) + # set input and output files + set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) + set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + + # request to configure the file + configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) + + # note the option ALL which allows to build the docs together with the application + add_custom_target( + doc ALL + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + VERBATIM) + + message(STATUS "Setup up the Doxygen documention build") + + else(Doxygen_FOUND) + message(WARNING "Doxygen need to be installed to generate the doxygen documentation") + endif(Doxygen_FOUND) +endif() diff --git a/doxygen.cfg b/Doxyfile.in similarity index 99% rename from doxygen.cfg rename to Doxyfile.in index ea1b569d..b8393df7 100644 --- a/doxygen.cfg +++ b/Doxyfile.in @@ -25,13 +25,13 @@ DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = libmbus +PROJECT_NAME = "@CMAKE_PROJECT_NAME@" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = +PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -581,7 +581,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = mbus +INPUT = @CMAKE_CURRENT_LIST_DIR@/mbus # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -1628,3 +1628,6 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES + + +USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_LIST_DIR@/README.md diff --git a/build.sh b/build.sh index 2179070f..e815272d 100755 --- a/build.sh +++ b/build.sh @@ -15,3 +15,10 @@ cmake --build . # cmake .. -DLIBMBUS_PACKAGE_DEB=ON # cpack .. # dpkg -i *.deb + +# build doc + +# mkdir build +# cd build +# cmake .. -DLIBMBUS_BUILD_DOCS=ON +# cmake --build . --target doc From 9d36bf5352f1bff059eea549dd96f822ed702606 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 13:54:57 +0100 Subject: [PATCH 160/238] build: install doxygen in ci (cherry picked from commit 6fb724698f1d525caaa723a01311707e058cb872) --- .github/workflows/ccpp.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a2e06292..9b9b4d7f 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -23,6 +23,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: build doxygen documentation + run: sudo apt install -y doxygen + - name: build doxygen documentation run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_DOCS=ON && cmake --build . --target doc From bd680292833a2e787274d583ba8bef599377f0fc Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Mon, 23 Mar 2020 14:07:59 +0100 Subject: [PATCH 161/238] build: remove old build system (cherry picked from commit bd2fa5759b06cabf324ed37644a4153e79a54e0d) --- Makefile-static | 25 ----------- Makefile.am | 20 --------- bin/Makefile-static | 24 ----------- bin/Makefile.am | 102 -------------------------------------------- build-deb.sh | 25 ----------- configure.ac | 44 ------------------- libmbus.pc.in | 12 ------ libmbus.spec | 87 ------------------------------------- mbus/Makefile.am | 20 --------- test/Makefile.am | 25 ----------- 10 files changed, 384 deletions(-) delete mode 100644 Makefile-static delete mode 100644 Makefile.am delete mode 100644 bin/Makefile-static delete mode 100644 bin/Makefile.am delete mode 100755 build-deb.sh delete mode 100644 configure.ac delete mode 100644 libmbus.pc.in delete mode 100644 libmbus.spec delete mode 100644 mbus/Makefile.am delete mode 100644 test/Makefile.am diff --git a/Makefile-static b/Makefile-static deleted file mode 100644 index 40308ad3..00000000 --- a/Makefile-static +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2010 -# Robert Johansson -# Raditex AB. -# All rights reserved. - -LIB = libmbus.so - -CFLAGS = -Wall -W -g -fPIC -I. -HEADERS = mbus.h mbus-protocol.h -OBJS = mbus.o mbus-protocol.o - -$(LIB): $(OBJS) - gcc -shared -o $(LIB) $(OBJS) - -all: $(LIB) - -clean: - rm -rf *.o *core core $(LIB) - -test: - (cd test && make && ./generate_xml.sh test-frames) - -install: all - cp $(LIB) /usr/local/freescada/lib - cp $(HEADERS) /usr/local/freescada/include diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index fd519e14..00000000 --- a/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# -# -# -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libmbus.pc - - -docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION) -dist_docdir = $(DESTDIR)$(docdir) -doc_DATA = README.md \ - COPYING \ - hardware/MBus_USB.pdf \ - hardware/MBus_USB.txt - -SUBDIRS = mbus bin -ACLOCAL = aclocal -I . -ACLOCAL_AMFLAGS = -Werror -I m4 diff --git a/bin/Makefile-static b/bin/Makefile-static deleted file mode 100644 index 2b04b493..00000000 --- a/bin/Makefile-static +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (C) 2011, Robert Johansson, Raditex AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@rscada.se -# -CFLAGS=-Wall -g -I.. -LDFLAGS=-L.. -lm -lmbus - -all: mbus-tcp-scan mbus-tcp-request-data - -%.o: %.c - $(CC) -c $(CFLAGS) $< -o $@ - -mbus-tcp-scan: mbus-tcp-scan.o mbus-tcp.o - gcc -o $@ $^ $(LDFLAGS) - -mbus-tcp-request-data: mbus-tcp-request-data.o mbus-tcp.o - gcc -o $@ $^ $(LDFLAGS) - -clean: - rm -rf mbus-tcp-request-data mbus-tcp-scan *.o *~ diff --git a/bin/Makefile.am b/bin/Makefile.am deleted file mode 100644 index 7c9ce412..00000000 --- a/bin/Makefile.am +++ /dev/null @@ -1,102 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (C) 2010, Raditex AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@rscada.se -# -# ------------------------------------------------------------------------------ -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ - -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src - -noinst_HEADERS = -bin_PROGRAMS = mbus-tcp-scan mbus-tcp-request-data mbus-tcp-request-data-multi-reply \ - mbus-tcp-select-secondary mbus-tcp-scan-secondary \ - mbus-serial-scan mbus-serial-request-data mbus-serial-request-data-multi-reply \ - mbus-serial-select-secondary mbus-serial-scan-secondary \ - mbus-serial-switch-baudrate mbus-tcp-raw-send mbus-tcp-application-reset \ - mbus-serial-set-address - -# tcp -mbus_tcp_scan_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_scan_LDADD = -lmbus -lm -mbus_tcp_scan_SOURCES = mbus-tcp-scan.c - -mbus_tcp_request_data_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_request_data_LDADD = -lmbus -lm -mbus_tcp_request_data_SOURCES = mbus-tcp-request-data.c - -mbus_tcp_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_request_data_multi_reply_LDADD = -lmbus -lm -mbus_tcp_request_data_multi_reply_SOURCES = mbus-tcp-request-data-multi-reply.c - -mbus_tcp_select_secondary_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_select_secondary_LDADD = -lmbus -lm -mbus_tcp_select_secondary_SOURCES = mbus-tcp-select-secondary.c - -mbus_tcp_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_scan_secondary_LDADD = -lmbus -lm -mbus_tcp_scan_secondary_SOURCES = mbus-tcp-scan-secondary.c - -mbus_tcp_raw_send_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_raw_send_LDADD = -lmbus -lm -mbus_tcp_raw_send_SOURCES = mbus-tcp-raw-send.c - -mbus_tcp_application_reset_LDFLAGS = -L$(top_builddir)/mbus -mbus_tcp_application_reset_LDADD = -lmbus -lm -mbus_tcp_application_reset_SOURCES = mbus-tcp-application-reset.c - -# serial -mbus_serial_scan_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_scan_LDADD = -lmbus -lm -mbus_serial_scan_SOURCES = mbus-serial-scan.c - -mbus_serial_request_data_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_request_data_LDADD = -lmbus -lm -mbus_serial_request_data_SOURCES = mbus-serial-request-data.c - -mbus_serial_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_request_data_multi_reply_LDADD = -lmbus -lm -mbus_serial_request_data_multi_reply_SOURCES = mbus-serial-request-data-multi-reply.c - -mbus_serial_select_secondary_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_select_secondary_LDADD = -lmbus -lm -mbus_serial_select_secondary_SOURCES = mbus-serial-select-secondary.c - -mbus_serial_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_scan_secondary_LDADD = -lmbus -lm -mbus_serial_scan_secondary_SOURCES = mbus-serial-scan-secondary.c - -mbus_serial_switch_baudrate_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_switch_baudrate_LDADD = -lmbus -lm -mbus_serial_switch_baudrate_SOURCES = mbus-serial-switch-baudrate.c - -mbus_serial_set_address_LDFLAGS = -L$(top_builddir)/mbus -mbus_serial_set_address_LDADD = -lmbus -lm -mbus_serial_set_address_SOURCES = mbus-serial-set-address.c - -# man pages -dist_man_MANS = libmbus.1 \ - mbus-tcp-scan.1 \ - mbus-tcp-request-data.1 \ - mbus-tcp-request-data-multi-reply.1 \ - mbus-tcp-select-secondary.1 \ - mbus-tcp-scan-secondary.1 \ - mbus-tcp-raw-send.1 \ - mbus-serial-scan.1 \ - mbus-serial-request-data.1 \ - mbus-serial-request-data-multi-reply.1 \ - mbus-serial-select-secondary.1 \ - mbus-serial-scan-secondary.1 \ - mbus-serial-switch-baudrate.1 - -.pod.1: - pod2man --release=$(VERSION) --center=$(PACKAGE) $< \ - >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true - @if grep '\' $@ >/dev/null 2>&1; \ - then \ - echo "$@ has some POD errors!"; false; \ - fi diff --git a/build-deb.sh b/build-deb.sh deleted file mode 100755 index 77f3a6be..00000000 --- a/build-deb.sh +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (C) 2012, Robert Johansson , Raditex Control AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@raditex.nu -# -# ------------------------------------------------------------------------------ - -if [ ! -f Makefile ]; then - # - # regenerate automake files - # - echo "Running autotools..." - - autoheader \ - && aclocal \ - && libtoolize --ltdl --copy --force \ - && automake --add-missing --copy \ - && autoconf -fi - -debuild -i -us -uc -b -#sudo pbuilder build $(NAME)_$(VERSION)-1.dsc diff --git a/configure.ac b/configure.ac deleted file mode 100644 index b99ef16a..00000000 --- a/configure.ac +++ /dev/null @@ -1,44 +0,0 @@ -dnl ---------------------------------------------------------------------------- -dnl Copyright (C) 2010, Raditex AB -dnl All rights reserved. -dnl -dnl rSCADA -dnl http://www.rSCADA.se -dnl info@rscada.se -dnl -dnl ---------------------------------------------------------------------------- - -LT_CONFIG_LTDL_DIR([libltdl]) - -AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) -AC_CONFIG_AUX_DIR([libltdl/config]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) - -AM_PROG_LIBTOOL -# fix for automake 1.11 & 1.12 -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) - -LDFLAGS="$LDFLAGS -version-info 0:9:0" - -dnl ---------------------- -dnl -AC_PROG_CC - -AC_CONFIG_HEADERS([config.h]) -AC_CONFIG_FILES([Makefile mbus/Makefile test/Makefile bin/Makefile libmbus.pc]) -AC_OUTPUT - - -echo \ -"---------------------------------------------------------- -Configuration: - - Source location: ${srcdir} - Compile: ${CC} - Compiler flags: ${CFLAGS} - Linker flags: ${LDFLAGS} - Host system type: ${host} - Install path: ${prefix} - - See config.h for further configuration. -----------------------------------------------------------" diff --git a/libmbus.pc.in b/libmbus.pc.in deleted file mode 100644 index 6c1b7d8b..00000000 --- a/libmbus.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libmbus -Description: Open source M-bus (Meter-Bus) library. -Requires: -Version: @PACKAGE_VERSION@ -URL: http://www.rscada.se/libmbus/ -Libs: -L${libdir} -lmbus -lm -Cflags: -I${includedir} diff --git a/libmbus.spec b/libmbus.spec deleted file mode 100644 index 06160f75..00000000 --- a/libmbus.spec +++ /dev/null @@ -1,87 +0,0 @@ -# -# spec file for package libmbus -# -# Copyright (c) 2010-2013, Raditex Control AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@rscada.se -# - -Summary: Open source M-bus (Meter-Bus) library -Name: libmbus -Version: 0.9.0 -Release: 1 -Source: https://github.com/rscada/%{name}/archive/%{version}.tar.gz -URL: https://github.com/rscada/libmbus/ -License: BSD -Vendor: Raditex Control AB -Packager: Stefan Wahren -Group: Development/Languages/C and C++ -BuildRoot: {_tmppath}/%{name}-%{version}-build -AutoReqProv: on - -%description -libmbus: M-bus Library from Raditex Control (http://www.rscada.se) - -libmbus is an open source library for the M-bus (Meter-Bus) protocol. -The Meter-Bus is a standard for reading out meter data from electricity meters, -heat meters, gas meters, etc. The M-bus standard deals with both the electrical -signals on the M-Bus, and the protocol and data format used in transmissions -on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle -the communication with M-Bus devices. - -For more information see http://www.rscada.se/libmbus - -%package devel -License: BSD -Summary: Development libraries and header files for using the M-bus library -Group: Development/Libraries/C and C++ -AutoReqProv: on -Requires: %{name} = %{version} - -%description devel -This package contains all necessary include files and libraries needed -to compile and link applications which use the M-bus (Meter-Bus) library. - -%prep -q -%setup -q -# workaround to get it's build -autoreconf - -%build -./configure --prefix=/usr -make - -%install -rm -Rf "%buildroot" -mkdir "%buildroot" -make install DESTDIR="%buildroot" - -%clean -rm -rf "%buildroot" - -%files -%defattr (-,root,root) -%doc COPYING README.md -%{_bindir}/mbus-serial-* -%{_bindir}/mbus-tcp-* -%{_libdir}/libmbus.so* -%{_mandir}/man1/libmbus.1 -%{_mandir}/man1/mbus-* - -%files devel -%defattr (-,root,root) -%{_includedir}/mbus -%{_libdir}/libmbus.a -%{_libdir}/libmbus.la -%{_libdir}/pkgconfig/libmbus.pc - -%changelog -* Fri Feb 22 2019 Stefan Wahren - 0.9.0-1 -- switch to github repo -- enable man pages - -* Fri Mar 29 2013 Stefan Wahren - 0.8.0-1 -- Initial package based on the last official release diff --git a/mbus/Makefile.am b/mbus/Makefile.am deleted file mode 100644 index b0749871..00000000 --- a/mbus/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (C) 2010, Raditex AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@rscada.se -# -# ------------------------------------------------------------------------------ -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ - -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) - -includedir = $(prefix)/include/mbus -include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h - -lib_LTLIBRARIES = libmbus.la -libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c - diff --git a/test/Makefile.am b/test/Makefile.am deleted file mode 100644 index c373fa48..00000000 --- a/test/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------------------------------------------------ -# Copyright (C) 2010, Raditex AB -# All rights reserved. -# -# rSCADA -# http://www.rSCADA.se -# info@rscada.se -# -# ------------------------------------------------------------------------------ -PACKAGE = @PACKAGE@ -VERSION = @VERSION@ - -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/mbus - -noinst_HEADERS = -noinst_PROGRAMS = mbus_parse mbus_parse_hex - -mbus_parse_LDFLAGS = -L$(top_builddir)/mbus -mbus_parse_LDADD = -lmbus -lm -mbus_parse_SOURCES = mbus_parse.c - -mbus_parse_hex_LDFLAGS = -L$(top_builddir)/mbus -mbus_parse_hex_LDADD = -lmbus -lm -mbus_parse_hex_SOURCES = mbus_parse_hex.c - From 02b64d56e63a0d78b7d3c9806d7605535336a4b4 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 25 Mar 2020 09:23:09 +0100 Subject: [PATCH 162/238] build: do not use gnu style warnings for msvc (cherry picked from commit ff2e50a38a76827fcf0cab6fd440274b17f036a6) --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 000d633b..9599870f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,8 +111,12 @@ add_library( target_include_directories( ${PROJECT_NAME} PUBLIC $ $ $) -target_link_libraries(${PROJECT_NAME} PRIVATE m) -target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) +if(LINUX) + target_link_libraries(${PROJECT_NAME} PRIVATE m) +endif() +if(NOT MSVC) + target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) +endif() if(CLANG_TIDY_EXE) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}") @@ -151,8 +155,8 @@ install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib) - + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT lib) install( EXPORT ${PROJECT_NAME}Targets DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} From 2c48a8d1e7dc7c9c21d02bdc4664aeb802fda1eb Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 25 Mar 2020 10:27:12 +0100 Subject: [PATCH 163/238] build: add also android (cherry picked from commit 155e245b613bb8eef01fba9fd31ebc49525905a8) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9599870f..d82796c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,7 +111,7 @@ add_library( target_include_directories( ${PROJECT_NAME} PUBLIC $ $ $) -if(LINUX) +if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android) target_link_libraries(${PROJECT_NAME} PRIVATE m) endif() if(NOT MSVC) From 7f7a5852c475d203a7b4b338ae88c2c7fe930faf Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 25 Mar 2020 11:27:34 +0100 Subject: [PATCH 164/238] build: add pkg config file (cherry picked from commit 724822b3abc6cceb6d4ab108508c8266e1483c01) --- CMakeLists.txt | 13 +++++++++++++ libmbus.pc.in | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 libmbus.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index d82796c2..d89d82a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,19 @@ endif() include(GNUInstallDirs) include(CMakePackageConfigHelpers) +set(INSTALL_PKGCONFIG_DIR + "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" + CACHE PATH "Installation directory for pkgconfig (.pc) files") +set(INSTALL_INC_DIR + "${CMAKE_INSTALL_PREFIX}/mbus" + CACHE PATH "Installation directory for headers") +set(INSTALL_LIB_DIR + "${CMAKE_INSTALL_PREFIX}/lib" + CACHE PATH "Installation directory for libraries") + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmbus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}") + set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install( TARGETS ${PROJECT_NAME} diff --git a/libmbus.pc.in b/libmbus.pc.in new file mode 100644 index 00000000..1baf5a3e --- /dev/null +++ b/libmbus.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=@INSTALL_LIB_DIR@ +includedir=@INSTALL_INC_DIR@ + +Name: libmbus +Description: Open source M-bus (Meter-Bus) library. +Requires: +Version: @PROJECT_VERSION@ +URL: http://www.rscada.se/libmbus/ +Libs: -L${libdir} -lmbus -lm +Cflags: -I${includedir} \ No newline at end of file From 5de5782cadcdf794714399ca39ed072052bd4527 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 31 Mar 2020 21:38:51 +0200 Subject: [PATCH 165/238] test: update generate-xml script (cherry picked from commit b0f413037a1121bc477ac8ea216f40c1d6e47e45) --- .github/workflows/ccpp.yml | 9 ++++++++- CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 9b9b4d7f..f7922e15 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -9,7 +9,13 @@ jobs: steps: - uses: actions/checkout@v2 - name: build examples and tests - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON && cmake --build . -j + run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. + + - name: generate test frames + run: ./test/generate-xml.sh test/test-frames build/bin/mbus_parse_hex + + - name: install and run gcovr + run: sudo pip install gcovr && gcovr build/. debian: runs-on: ubuntu-latest @@ -21,6 +27,7 @@ jobs: doc: runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 - name: build doxygen documentation diff --git a/CMakeLists.txt b/CMakeLists.txt index d89d82a3..29d0fbaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ endif() option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) option(LIBMBUS_BUILD_TESTS "build tests" OFF) -option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" ON) +option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" OFF) option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) From 4356766a3d66d063309876fdaed84e9a3dcdc11f Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 31 Mar 2020 21:07:19 +0200 Subject: [PATCH 166/238] build: apply suggestions from code review Co-Authored-By: Anonymous Maarten (cherry picked from commit fffdca0504ec374e50bebe9152591b11b1092c6f) --- CMakeLists.txt | 12 ++++++------ mbus/config.h.in | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 29d0fbaf..b5533f78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ if(LIBMBUS_RUN_CLANG_TIDY) endif(LIBMBUS_RUN_CLANG_TIDY) if(LIBMBUS_ENABLE_COVERAGE) - if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + if(NOT CMAKE_BUILD_TYPE MATCHES "(Debug)|(RelWithDebInfo)") message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") endif() @@ -94,7 +94,7 @@ set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") set(PACKAGE_VERSION "${PROJECT_VERSION}") set(VERSION "${PROJECT_VERSION}") -configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_DIR}/config.h) +configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_DIR}/config.h @ONLY) add_library( ${PROJECT_NAME} @@ -111,7 +111,7 @@ add_library( target_include_directories( ${PROJECT_NAME} PUBLIC $ $ $) -if(CMAKE_SYSTEM_NAME STREQUAL Linux OR CMAKE_SYSTEM_NAME STREQUAL Android) +if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") target_link_libraries(${PROJECT_NAME} PRIVATE m) endif() if(NOT MSVC) @@ -151,13 +151,13 @@ include(GNUInstallDirs) include(CMakePackageConfigHelpers) set(INSTALL_PKGCONFIG_DIR - "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" + "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") set(INSTALL_INC_DIR - "${CMAKE_INSTALL_PREFIX}/mbus" + "${CMAKE_INSTALL_INCLUDEDIR}/mbus" CACHE PATH "Installation directory for headers") set(INSTALL_LIB_DIR - "${CMAKE_INSTALL_PREFIX}/lib" + "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmbus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc @ONLY) diff --git a/mbus/config.h.in b/mbus/config.h.in index 369c7c80..9b818f65 100644 --- a/mbus/config.h.in +++ b/mbus/config.h.in @@ -1,6 +1,3 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@" @@ -35,19 +32,19 @@ #define LT_OBJDIR ".libs/" /* Name of package */ -#define PACKAGE "libmbus" +#define PACKAGE "@PROJECT_NAME@" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "info@rscada.se" /* Define to the full name of this package. */ -#define PACKAGE_NAME "libmbus" +#define PACKAGE_NAME "@PROJECT_NAME@" /* Define to the full name and version of this package. */ #cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" /* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libmbus" +#define PACKAGE_TARNAME "@PROJECT_NAME@" /* Define to the home page for this package. */ #define PACKAGE_URL "http://www.rscada.se/libmbus/" From 6f0c62279eeec631fca96da936dc430fa4f59d47 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 31 Mar 2020 23:45:53 +0200 Subject: [PATCH 167/238] chore: apply suggestions from code review Co-Authored-By: Anonymous Maarten (cherry picked from commit 505c25aa9b08914cddf1a46652003f919de5d7a2) --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5533f78..1d92f0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,7 +168,7 @@ install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib + ARCHIVE DESTINATION ${INSTALL_LIB_DIR} COMPONENT dev RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT lib) install( EXPORT ${PROJECT_NAME}Targets @@ -187,7 +187,7 @@ install( install( DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/mbus/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mbus/ + DESTINATION ${INSTALL_INC_DIR} COMPONENT dev FILES_MATCHING PATTERN "*.h") From 0d3ef9e77cc555f6b9c2f358bbbc8e73db131b27 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 1 Apr 2020 15:52:21 +0200 Subject: [PATCH 168/238] build: symplify clang tidy (cherry picked from commit b58aca44323650c4c75943bc201f4c21f9bfaa75) --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d92f0d9..d07524a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ if(LIBMBUS_RUN_CLANG_TIDY) message(WARNING "clang-tidy not found.") else() message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") - set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}") endif() endif(LIBMBUS_RUN_CLANG_TIDY) @@ -119,7 +118,7 @@ if(NOT MSVC) endif() if(CLANG_TIDY_EXE) - set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}") + set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") endif() add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) From 6ae15b6d7d52e71b93bb6abbf446411a70c20acc Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 1 Apr 2020 15:53:54 +0200 Subject: [PATCH 169/238] chore: simplify cmake (cherry picked from commit 989404de8381ec25f6d028fa82fb4fd8b66fdd38) --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d07524a9..41cb669c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,8 +29,7 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_C_STANDARD 11) # Append our module directory to CMake -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_BINARY_DIR}") # Set the output of the libraries and executables. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) @@ -166,7 +165,7 @@ set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT lib + LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib ARCHIVE DESTINATION ${INSTALL_LIB_DIR} COMPONENT dev RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT lib) install( From 50858f075ea4e2dff59319c251fd3c5da1f183ea Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Wed, 1 Apr 2020 22:38:53 +0200 Subject: [PATCH 170/238] chore: apply suggestions from code review Co-Authored-By: Anonymous Maarten (cherry picked from commit f3a62d560b26bc23399415d7e2651f792f4dfa25) --- CMakeLists.txt | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41cb669c..a581d600 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,19 +96,19 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_D add_library( ${PROJECT_NAME} - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.c - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.h - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.c - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.h - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.c - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.h - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.c - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.h - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c - ${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h) + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.c" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.h" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.c" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.h" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.c" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.h" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.c" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.h" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c" + "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h") target_include_directories( - ${PROJECT_NAME} PUBLIC $ $ - $) + ${PROJECT_NAME} PUBLIC "$" "$" + "$") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") target_link_libraries(${PROJECT_NAME} PRIVATE m) endif() @@ -165,27 +165,27 @@ set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install( TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT lib - ARCHIVE DESTINATION ${INSTALL_LIB_DIR} COMPONENT dev - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT lib) + LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib + ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT dev + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lib) install( EXPORT ${PROJECT_NAME}Targets - DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} + DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" NAMESPACE ${PROJECT_NAME}:: COMPONENT dev) configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION - ${LIBMBUS_CONFIG_INSTALL_DIR}) + "${LIBMBUS_CONFIG_INSTALL_DIR}") write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY SameMajorVersion) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION ${LIBMBUS_CONFIG_INSTALL_DIR} + DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" COMPONENT dev) install( - DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/mbus/ - DESTINATION ${INSTALL_INC_DIR} + DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/mbus/" + DESTINATION "${INSTALL_INC_DIR}" COMPONENT dev FILES_MATCHING PATTERN "*.h") From 7ddfc6459873ad840dc26d97fe0ccf2ffcc63888 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 14 Apr 2020 10:29:22 +0200 Subject: [PATCH 171/238] build: add devel package (cherry picked from commit f31fbea81701f5c33c523ee3ebcdf8fb4bbf21bb) --- CMakeLists.txt | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a581d600..dd438084 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) option(LIBMBUS_BUILD_DOCS "build documentation" OFF) +option(BUILD_SHARED_LIBS "build shared lib" ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -107,8 +108,9 @@ add_library( "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c" "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h") target_include_directories( - ${PROJECT_NAME} PUBLIC "$" "$" - "$") + ${PROJECT_NAME} + PUBLIC "$" "$" + "$") if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") target_link_libraries(${PROJECT_NAME} PRIVATE m) endif() @@ -159,7 +161,10 @@ set(INSTALL_LIB_DIR CACHE PATH "Installation directory for libraries") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmbus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}") +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc + DESTINATION "${INSTALL_PKGCONFIG_DIR}" + COMPONENT dev) set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install( @@ -211,17 +216,33 @@ For more information see http://www.rscada.se/libmbus") set(CPACK_PACKAGE_VENDOR "Raditex Control AB") set(CPACK_PACKAGE_CONTACT "Stefan Wahren ") set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/rscada/libmbus/") +set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_DEBIAN_PACKAGE_DEBUG ON) set(CPACK_PACKAGE_RELEASE 1) -set(CPACK_COMPONENTS_ALL devel libs) -set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) + +# create 2 components, libmbus, libmbus-dev +set(CPACK_COMPONENTS_ALL lib dev) +set(CPACK_COMPONENT_LIB_DESCRIPTION + "FreeSCADA M-Bus Library. + A free and open-source library for M-Bus (Meter Bus) from the rSCADA project. + ") +set(CPACK_DEBIAN_LIB_PACKAGE_SECTION libs) + +set(CPACK_COMPONENT_DEVEL_DESCRIPTION + "FreeSCADA M-Bus Library Development files. +A free and open-source library for M-Bus (Meter Bus) from the rSCADA project, +including development files.") +set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION libdevel) + +set(CPACK_COMPONENT_DEVEL_DEPENDS lib) set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") -set(CPACK_COMPONENTS_ALL Libraries ApplicationData) if(LIBMBUS_PACKAGE_DEB) set(CPACK_GENERATOR "DEB") From 41d5b63d6de19d8b1639a4ac95c4fef041409c81 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 14 Apr 2020 11:01:07 +0200 Subject: [PATCH 172/238] fix: unit tests (cherry picked from commit 9f9c7a5dbfdf6d5a849e9f76b60e8c400a7e1222) --- test/generate-xml.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index d03aa1fe..02e2d888 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -12,23 +12,25 @@ # #------------------------------------------------------------------------------ -# Check if mbus_parse_hex exists -if [ ! -x ./mbus_parse_hex ]; then - echo "mbus_parse_hex not found" - exit 3 -fi - # Check commandline parameter -if [ $# -ne 1 ]; then +if [ $# -ne 2 ]; then echo "usage: $0 directory" exit 3 fi directory="$1" -# Check directory +# Check if mbus_parse_hex exists +if [ ! -x $2 ]; then + echo "mbus_parse_hex not found" + exit 3 +fi + +mbus_parse_hex="$2" + +# # Check directory if [ ! -d "$directory" ]; then - echo "usage: $0 directory" + echo "$directory not found" exit 3 fi @@ -40,7 +42,7 @@ for hexfile in "$directory"/*.hex; do filename=`basename $hexfile .hex` # Parse hex file and write XML in file - ./mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new" + $mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new" result=$? # Check parsing result @@ -74,4 +76,3 @@ for hexfile in "$directory"/*.hex; do esac done - From ce9b50dde23c27066c495b686abd7e009b1f3d05 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 14 Apr 2020 11:22:40 +0200 Subject: [PATCH 173/238] docs: add better usage to generate xml script (cherry picked from commit ee3a69e5dfc8f8a89c6d75c92b276c44747a7758) --- test/generate-xml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index 02e2d888..84e52bdb 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -14,7 +14,7 @@ # Check commandline parameter if [ $# -ne 2 ]; then - echo "usage: $0 directory" + echo "usage: $0 path_to_directory_with_xml_files path_to_mbus_parse_hex_with_filename" exit 3 fi From de83c2e2e06d98b79330094ccfde614a90d364d2 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Tue, 14 Apr 2020 11:36:39 +0200 Subject: [PATCH 174/238] fix: debian package blank line in value of field Description (cherry picked from commit 716fe0358cbc9149be4574f67af9f59b746952f2) --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd438084..c35713f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,10 +226,8 @@ set(CPACK_PACKAGE_RELEASE 1) # create 2 components, libmbus, libmbus-dev set(CPACK_COMPONENTS_ALL lib dev) -set(CPACK_COMPONENT_LIB_DESCRIPTION - "FreeSCADA M-Bus Library. - A free and open-source library for M-Bus (Meter Bus) from the rSCADA project. - ") +set(CPACK_COMPONENT_LIB_DESCRIPTION "FreeSCADA M-Bus Library. + A free and open-source library for M-Bus (Meter Bus) from the rSCADA project.") set(CPACK_DEBIAN_LIB_PACKAGE_SECTION libs) set(CPACK_COMPONENT_DEVEL_DESCRIPTION From d7eacdc38f33391161d1bd2e28906948d7547a0d Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Fri, 24 Apr 2020 09:55:01 +0200 Subject: [PATCH 175/238] chore: make path to tests optional (cherry picked from commit f569816788887b2052761d1574d6662b75238172) --- .github/workflows/ccpp.yml | 2 +- build.sh | 12 ++++++------ test/generate-xml.sh | 25 +++++++++++++++++-------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index f7922e15..b9428015 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -12,7 +12,7 @@ jobs: run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. - name: generate test frames - run: ./test/generate-xml.sh test/test-frames build/bin/mbus_parse_hex + run: ./test/generate-xml.sh test/test-frames - name: install and run gcovr run: sudo pip install gcovr && gcovr build/. diff --git a/build.sh b/build.sh index e815272d..04ea869c 100755 --- a/build.sh +++ b/build.sh @@ -1,17 +1,17 @@ #!/bin/sh -rm -rf _build -mkdir _build -cd _build +rm -rf build +mkdir build +cd build cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON cmake --build . # build deb -# rm -rf _build -# mkdir _build -# cd _build +# rm -rf build +# mkdir build +# cd build # cmake .. -DLIBMBUS_PACKAGE_DEB=ON # cpack .. # dpkg -i *.deb diff --git a/test/generate-xml.sh b/test/generate-xml.sh index 84e52bdb..6a3231ff 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -13,24 +13,33 @@ #------------------------------------------------------------------------------ # Check commandline parameter -if [ $# -ne 2 ]; then +if [ $# -ne 1 ]; then + echo "usage: $0 path_to_directory_with_xml_files" + echo "or" echo "usage: $0 path_to_directory_with_xml_files path_to_mbus_parse_hex_with_filename" exit 3 fi directory="$1" -# Check if mbus_parse_hex exists -if [ ! -x $2 ]; then - echo "mbus_parse_hex not found" +# # Check directory +if [ ! -d "$directory" ]; then + echo "$directory not found" exit 3 fi -mbus_parse_hex="$2" +# Default location is this one +mbus_parse_hex="build/bin/mbus_parse_hex" -# # Check directory -if [ ! -d "$directory" ]; then - echo "$directory not found" +# though can be overriten +if [ $# -eq 2 ]; then + mbus_parse_hex="$2" +fi + +# Check if mbus_parse_hex exists +if [ ! -x $mbus_parse_hex ]; then + echo "mbus_parse_hex not found" + echo "path to mbus_parse_hex: $mbus_parse_hex" exit 3 fi From 9aad79d1c0ee47fbee6fd4257b2c8c4e54ba7e8f Mon Sep 17 00:00:00 2001 From: Carlos Gomes Martinho Date: Fri, 24 Apr 2020 15:14:15 +0200 Subject: [PATCH 176/238] chore: run tests also with pull requests (cherry picked from commit ba18321e115787a6c3d1cfdf9035c80091fa528c) --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index b9428015..1478bc32 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -1,6 +1,6 @@ name: CMake -on: [push] +on: [push, pull_request] jobs: build: From 40f410884e2f7a8334e76da3dba6ae0d4b399a05 Mon Sep 17 00:00:00 2001 From: Matthias Deimbacher Date: Fri, 15 May 2020 19:05:36 +0200 Subject: [PATCH 177/238] fix: add missing declaration to header (#160) (cherry picked from commit b5e59aa52f9067a5c18862f9651c592fb56a9219) --- mbus/mbus-protocol.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 85b8c11b..74188ab8 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -554,6 +554,8 @@ const char *mbus_data_fixed_function(int status); long mbus_data_record_storage_number(mbus_data_record *record); long mbus_data_record_tariff(mbus_data_record *record); int mbus_data_record_device(mbus_data_record *record); +const char *mbus_data_record_unit(mbus_data_record *record); +const char *mbus_data_record_value(mbus_data_record *record); // // M-Bus frame data struct access/write functions From 9d32d74af568cfaf7a3104f2248770415aa21779 Mon Sep 17 00:00:00 2001 From: Fabian Pflug Date: Fri, 5 Jun 2020 13:05:43 +0200 Subject: [PATCH 178/238] Add product strings for Sensoco devices (#161) (cherry picked from commit 643022388d6038677736a0fbf1b37980b60ebfd3) --- mbus/mbus-protocol.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index ac061ffb..23d6c501 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -1218,6 +1218,31 @@ mbus_data_product_name(mbus_data_variable_header *header) break; } } + else if (manufacturer == mbus_manufacturer_id("SEO") || manufacturer == mbus_manufacturer_id("GTE")) + { + switch (header->id_bcd[3]) + { + case 0x30: + strcpy(buff,"Sensoco PT100"); + break; + case 0x41: + strcpy(buff,"Sensoco 2-NTC"); + break; + case 0x45: + strcpy(buff,"Sensoco Laser Light"); + break; + case 0x48: + strcpy(buff,"Sensoco ADIO"); + break; + case 0x51: + case 0x61: + strcpy(buff,"Sensoco THU"); + break; + case 0x80: + strcpy(buff,"Sensoco PulseCounter for E-Meter"); + break; + } + } else if (manufacturer == mbus_manufacturer_id("SEN")) { switch (header->version) From 38c3bb0c4011ba8505018bc767a821b62fe827d4 Mon Sep 17 00:00:00 2001 From: Fabian Pflug Date: Fri, 5 Jun 2020 13:12:44 +0200 Subject: [PATCH 179/238] Added more medium definitions according to DIN EN 13757-7:2018-06 (#162) (cherry picked from commit 23d8ee4844bfbaf0fef99993e8bb50ad19d2430c) --- mbus/mbus-protocol.c | 127 +++++++++++++++++++++++++++++++++++++++++-- mbus/mbus-protocol.h | 17 ++++++ 2 files changed, 139 insertions(+), 5 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 23d6c501..a7935c08 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -1691,12 +1691,40 @@ mbus_data_fixed_unit(int medium_unit_byte) // Heat / Cooling load meter ♣ 0000 1101 OD // Bus / System 0000 1110 0E // Unknown Medium 0000 1111 0F -// Reserved .......... 10 to 15 +// Irrigation Water (Non Drinkable) 0001 0000 10 +// Water data logger 0001 0001 11 +// Gas data logger 0001 0010 12 +// Gas converter 0001 0011 13 +// Heat Value 0001 0100 14 +// Hot Water (>=90°C) (Non Drinkable) 0001 0101 15 // Cold Water 0001 0110 16 // Dual Water 0001 0111 17 // Pressure 0001 1000 18 // A/D Converter 0001 1001 19 -// Reserved .......... 20 to FF +// Smoke detector 0001 1010 1A +// Room sensor (e.g. Temperature or Humidity) 0001 1011 1B +// Gas detector 0001 1100 1C +// Reserved for Sensors .......... 1D to 1F +// Breaker (Electricity) 0010 0000 20 +// Valve (Gas or Water) 0010 0001 21 +// Reserved for Switching Units .......... 22 to 24 +// Customer Unit (Display) 0010 0101 25 +// Reserved for End User Units .......... 26 to 27 +// Waste Water (Non Drinkable) 0010 1000 28 +// Waste 0010 1001 29 +// Reserved for CO2 0010 1010 2A +// Reserved for environmental meter .......... 2B to 2F +// Service tool 0011 0000 30 +// Gateway 0011 0001 31 +// Unidirectional Repeater 0011 0010 32 +// Bidirectional Repeater 0011 0011 33 +// Reserved for System Units .......... 34 to 35 +// Radio Control Unit (System Side) 0011 0110 36 +// Radio Control Unit (Meter Side) 0011 0111 37 +// Bus Control Unit (Meter Side) 0011 1000 38 +// Reserved for System Units .......... 38 to 3F +// Reserved .......... 40 to FE +// Placeholder 1111 1111 FF //------------------------------------------------------------------------------ /// @@ -1734,7 +1762,7 @@ mbus_data_variable_medium_lookup(unsigned char medium) break; case MBUS_VARIABLE_DATA_MEDIUM_HOT_WATER: - snprintf(buff, sizeof(buff), "Hot water"); + snprintf(buff, sizeof(buff), "Warm water (30-90°C)"); break; case MBUS_VARIABLE_DATA_MEDIUM_WATER: @@ -1773,6 +1801,30 @@ mbus_data_variable_medium_lookup(unsigned char medium) snprintf(buff, sizeof(buff), "Unknown Medium"); break; + case MBUS_VARIABLE_DATA_MEDIUM_IRRIGATION: + snprintf(buff, sizeof(buff), "Irrigation Water"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_WATER_LOGGER: + snprintf(buff, sizeof(buff), "Water Logger"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_GAS_LOGGER: + snprintf(buff, sizeof(buff), "Gas Logger"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_GAS_CONV: + snprintf(buff, sizeof(buff), "Gas Converter"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_COLORIFIC: + snprintf(buff, sizeof(buff), "Calorific value"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_BOIL_WATER: + snprintf(buff, sizeof(buff), "Hot water (>90°C)"); + break; + case MBUS_VARIABLE_DATA_MEDIUM_COLD_WATER: snprintf(buff, sizeof(buff), "Cold water"); break; @@ -1789,8 +1841,73 @@ mbus_data_variable_medium_lookup(unsigned char medium) snprintf(buff, sizeof(buff), "A/D Converter"); break; - case 0x10: // - 0x15 - case 0x20: // - 0xFF + case MBUS_VARIABLE_DATA_MEDIUM_SMOKE: + snprintf(buff, sizeof(buff), "Smoke Detector"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_ROOM_SENSOR: + snprintf(buff, sizeof(buff), "Ambient Sensor"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_GAS_DETECTOR: + snprintf(buff, sizeof(buff), "Gas Detector"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_BREAKER_E: + snprintf(buff, sizeof(buff), "Breaker: Electricity"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_VALVE: + snprintf(buff, sizeof(buff), "Valve: Gas or Water"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_CUSTOMER_UNIT: + snprintf(buff, sizeof(buff), "Customer Unit: Display Device"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_WASTE_WATER: + snprintf(buff, sizeof(buff), "Waste Water"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_GARBAGE: + snprintf(buff, sizeof(buff), "Garbage"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_SERVICE_UNIT: + snprintf(buff, sizeof(buff), "Service Unit"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_RC_SYSTEM: + snprintf(buff, sizeof(buff), "Radio Converter: System"); + break; + + case MBUS_VARIABLE_DATA_MEDIUM_RC_METER: + snprintf(buff, sizeof(buff), "Radio Converter: Meter"); + break; + + case 0x22: + case 0x23: + case 0x24: + case 0x26: + case 0x27: + case 0x2A: + case 0x2B: + case 0x2C: + case 0x2D: + case 0x2E: + case 0x2F: + case 0x31: + case 0x32: + case 0x33: + case 0x34: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: snprintf(buff, sizeof(buff), "Reserved"); break; diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 74188ab8..16932645 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -487,10 +487,27 @@ typedef struct _mbus_data_secondary_address { #define MBUS_VARIABLE_DATA_MEDIUM_HEAT_COOL 0x0D #define MBUS_VARIABLE_DATA_MEDIUM_BUS 0x0E #define MBUS_VARIABLE_DATA_MEDIUM_UNKNOWN 0x0F +#define MBUS_VARIABLE_DATA_MEDIUM_IRRIGATION 0x10 +#define MBUS_VARIABLE_DATA_MEDIUM_WATER_LOGGER 0x11 +#define MBUS_VARIABLE_DATA_MEDIUM_GAS_LOGGER 0x12 +#define MBUS_VARIABLE_DATA_MEDIUM_GAS_CONV 0x13 +#define MBUS_VARIABLE_DATA_MEDIUM_COLORIFIC 0x14 +#define MBUS_VARIABLE_DATA_MEDIUM_BOIL_WATER 0x15 #define MBUS_VARIABLE_DATA_MEDIUM_COLD_WATER 0x16 #define MBUS_VARIABLE_DATA_MEDIUM_DUAL_WATER 0x17 #define MBUS_VARIABLE_DATA_MEDIUM_PRESSURE 0x18 #define MBUS_VARIABLE_DATA_MEDIUM_ADC 0x19 +#define MBUS_VARIABLE_DATA_MEDIUM_SMOKE 0x1A +#define MBUS_VARIABLE_DATA_MEDIUM_ROOM_SENSOR 0x1B +#define MBUS_VARIABLE_DATA_MEDIUM_GAS_DETECTOR 0x1C +#define MBUS_VARIABLE_DATA_MEDIUM_BREAKER_E 0x20 +#define MBUS_VARIABLE_DATA_MEDIUM_VALVE 0x21 +#define MBUS_VARIABLE_DATA_MEDIUM_CUSTOMER_UNIT 0x25 +#define MBUS_VARIABLE_DATA_MEDIUM_WASTE_WATER 0x28 +#define MBUS_VARIABLE_DATA_MEDIUM_GARBAGE 0x29 +#define MBUS_VARIABLE_DATA_MEDIUM_SERVICE_UNIT 0x30 +#define MBUS_VARIABLE_DATA_MEDIUM_RC_SYSTEM 0x36 +#define MBUS_VARIABLE_DATA_MEDIUM_RC_METER 0x37 // // Returns the manufacturer ID or zero if the given From 84f87a7134ebf88c4d2ac3342a3f42fa2deb172c Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sat, 27 Jun 2020 16:10:17 +0200 Subject: [PATCH 180/238] Fix Linux build target Linux uses lib as prefix, which results into unintended liblibmbus.so So avoid such a prefix. (cherry picked from commit 1e25cf10964237384762deac7b24749affaef42d) --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c35713f1..c47a94c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,8 @@ if(NOT MSVC) target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) endif() +set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") + if(CLANG_TIDY_EXE) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") endif() From acd9840d639ba9742ce918907cb30856f20b62e1 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 28 Jun 2020 10:28:40 +0200 Subject: [PATCH 181/238] Improve BCD decoding (#167) * Introduce mbus_data_bcd_decode_hex The convert function mbus_data_bcd_decode (BCD to decimal) suffers from information loss in case of hexacimal digits. So introduce a new function mbus_data_bcd_decode_hex (BCD to hexadecimal), which isn't affected and use this for default XML output. But keep mbus_data_bcd_decode for normalized output. (cherry picked from commit 17a73287c2bebb2973c70029f921932cf8fd74c6) --- mbus/mbus-protocol.c | 68 +++++++++++++------ mbus/mbus-protocol.h | 1 + test/test-frames/EFE_Engelmann-WaterStar.xml | 2 +- test/test-frames/ELS_Elster-F96-Plus.xml | 4 +- .../SLB_CF-Compact-Integral-MK-MaXX.xml | 2 +- test/test-frames/abb_f95.xml | 4 +- test/test-frames/electricity-meter-1.xml | 2 +- test/test-frames/electricity-meter-2.xml | 2 +- .../test-frames/landis+gyr_ultraheat_t230.xml | 2 +- test/test-frames/siemens_water.xml | 2 +- test/test-frames/siemens_wfh21.xml | 2 +- 11 files changed, 58 insertions(+), 33 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index a7935c08..c8d5f030 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -495,7 +495,7 @@ mbus_data_bcd_encode(unsigned char *bcd_data, size_t bcd_data_size, int value) //------------------------------------------------------------------------------ /// -/// Decode BCD data +/// Decode BCD data (decimal) /// //------------------------------------------------------------------------------ long long @@ -530,6 +530,30 @@ mbus_data_bcd_decode(unsigned char *bcd_data, size_t bcd_data_size) return -1; } +//------------------------------------------------------------------------------ +/// +/// Decode BCD data (hexadecimal) +/// +//------------------------------------------------------------------------------ +long long +mbus_data_bcd_decode_hex(unsigned char *bcd_data, size_t bcd_data_size) +{ + long long val = 0; + size_t i; + + if (bcd_data) + { + for (i = bcd_data_size; i > 0; i--) + { + val = (val << 8) | bcd_data[i-1]; + } + + return val; + } + + return -1; +} + //------------------------------------------------------------------------------ /// /// Decode INTEGER data @@ -2735,8 +2759,8 @@ mbus_data_record_decode(mbus_data_record *record) case 0x09: // 2 digit BCD (8 bit) - int_val = (int)mbus_data_bcd_decode(record->data, 1); - snprintf(buff, sizeof(buff), "%d", int_val); + int_val = (int)mbus_data_bcd_decode_hex(record->data, 1); + snprintf(buff, sizeof(buff), "%X", int_val); if (debug) printf("%s: DIF 0x%.2x was decoded using 2 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -2745,8 +2769,8 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0A: // 4 digit BCD (16 bit) - int_val = (int)mbus_data_bcd_decode(record->data, 2); - snprintf(buff, sizeof(buff), "%d", int_val); + int_val = (int)mbus_data_bcd_decode_hex(record->data, 2); + snprintf(buff, sizeof(buff), "%X", int_val); if (debug) printf("%s: DIF 0x%.2x was decoded using 4 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -2755,8 +2779,8 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0B: // 6 digit BCD (24 bit) - int_val = (int)mbus_data_bcd_decode(record->data, 3); - snprintf(buff, sizeof(buff), "%d", int_val); + int_val = (int)mbus_data_bcd_decode_hex(record->data, 3); + snprintf(buff, sizeof(buff), "%X", int_val); if (debug) printf("%s: DIF 0x%.2x was decoded using 6 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -2765,8 +2789,8 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0C: // 8 digit BCD (32 bit) - int_val = (int)mbus_data_bcd_decode(record->data, 4); - snprintf(buff, sizeof(buff), "%d", int_val); + int_val = (int)mbus_data_bcd_decode_hex(record->data, 4); + snprintf(buff, sizeof(buff), "%X", int_val); if (debug) printf("%s: DIF 0x%.2x was decoded using 8 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -2775,8 +2799,8 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0E: // 12 digit BCD (48 bit) - long_long_val = mbus_data_bcd_decode(record->data, 6); - snprintf(buff, sizeof(buff), "%lld", long_long_val); + long_long_val = mbus_data_bcd_decode_hex(record->data, 6); + snprintf(buff, sizeof(buff), "%llX", long_long_val); if (debug) printf("%s: DIF 0x%.2x was decoded using 12 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -3766,8 +3790,8 @@ mbus_data_variable_header_print(mbus_data_variable_header *header) { if (header) { - printf("%s: ID = %lld\n", __PRETTY_FUNCTION__, - mbus_data_bcd_decode(header->id_bcd, 4)); + printf("%s: ID = %llX\n", __PRETTY_FUNCTION__, + mbus_data_bcd_decode_hex(header->id_bcd, 4)); printf("%s: Manufacturer = 0x%.2X%.2X\n", __PRETTY_FUNCTION__, header->manufacturer[1], header->manufacturer[0]); @@ -3868,7 +3892,7 @@ mbus_data_fixed_print(mbus_data_fixed *data) if (data) { - printf("%s: ID = %lld\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode(data->id_bcd, 4)); + printf("%s: ID = %llX\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode_hex(data->id_bcd, 4)); printf("%s: Access # = 0x%.2X\n", __PRETTY_FUNCTION__, data->tx_cnt); printf("%s: Status = 0x%.2X\n", __PRETTY_FUNCTION__, data->status); printf("%s: Function = %s\n", __PRETTY_FUNCTION__, mbus_data_fixed_function(data->status)); @@ -3877,7 +3901,7 @@ mbus_data_fixed_print(mbus_data_fixed *data) printf("%s: Unit1 = %s\n", __PRETTY_FUNCTION__, mbus_data_fixed_unit(data->cnt1_type)); if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) { - printf("%s: Counter1 = %lld\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode(data->cnt1_val, 4)); + printf("%s: Counter1 = %llX\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode_hex(data->cnt1_val, 4)); } else { @@ -3889,7 +3913,7 @@ mbus_data_fixed_print(mbus_data_fixed *data) printf("%s: Unit2 = %s\n", __PRETTY_FUNCTION__, mbus_data_fixed_unit(data->cnt2_type)); if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) { - printf("%s: Counter2 = %lld\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode(data->cnt2_val, 4)); + printf("%s: Counter2 = %llX\n", __PRETTY_FUNCTION__, mbus_data_bcd_decode_hex(data->cnt2_val, 4)); } else { @@ -4020,7 +4044,7 @@ mbus_data_variable_header_xml(mbus_data_variable_header *header) { len += snprintf(&buff[len], sizeof(buff) - len, " \n"); - len += snprintf(&buff[len], sizeof(buff) - len, " %lld\n", mbus_data_bcd_decode(header->id_bcd, 4)); + len += snprintf(&buff[len], sizeof(buff) - len, " %llX\n", mbus_data_bcd_decode_hex(header->id_bcd, 4)); len += snprintf(&buff[len], sizeof(buff) - len, " %s\n", mbus_decode_manufacturer(header->manufacturer[0], header->manufacturer[1])); len += snprintf(&buff[len], sizeof(buff) - len, " %d\n", header->version); @@ -4198,7 +4222,7 @@ mbus_data_fixed_xml(mbus_data_fixed *data) len += snprintf(&buff[len], buff_size - len, "\n\n"); len += snprintf(&buff[len], buff_size - len, " \n"); - len += snprintf(&buff[len], buff_size - len, " %lld\n", mbus_data_bcd_decode(data->id_bcd, 4)); + len += snprintf(&buff[len], buff_size - len, " %llX\n", mbus_data_bcd_decode_hex(data->id_bcd, 4)); mbus_str_xml_encode(str_encoded, mbus_data_fixed_medium(data), sizeof(str_encoded)); len += snprintf(&buff[len], buff_size - len, " %s\n", str_encoded); @@ -4216,7 +4240,7 @@ mbus_data_fixed_xml(mbus_data_fixed *data) len += snprintf(&buff[len], buff_size - len, " %s\n", str_encoded); if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) { - len += snprintf(&buff[len], buff_size - len, " %lld\n", mbus_data_bcd_decode(data->cnt1_val, 4)); + len += snprintf(&buff[len], buff_size - len, " %llX\n", mbus_data_bcd_decode_hex(data->cnt1_val, 4)); } else { @@ -4235,7 +4259,7 @@ mbus_data_fixed_xml(mbus_data_fixed *data) len += snprintf(&buff[len], buff_size - len, " %s\n", str_encoded); if ((data->status & MBUS_DATA_FIXED_STATUS_FORMAT_MASK) == MBUS_DATA_FIXED_STATUS_FORMAT_BCD) { - len += snprintf(&buff[len], buff_size - len, " %lld\n", mbus_data_bcd_decode(data->cnt2_val, 4)); + len += snprintf(&buff[len], buff_size - len, " %llX\n", mbus_data_bcd_decode_hex(data->cnt2_val, 4)); } else { @@ -4594,9 +4618,9 @@ mbus_frame_get_secondary_address(mbus_frame *frame) return NULL; } - id = (unsigned long) mbus_data_bcd_decode(data->data_var.header.id_bcd, 4); + id = (unsigned long) mbus_data_bcd_decode_hex(data->data_var.header.id_bcd, 4); - snprintf(addr, sizeof(addr), "%08lu%02X%02X%02X%02X", + snprintf(addr, sizeof(addr), "%08lX%02X%02X%02X%02X", id, data->data_var.header.manufacturer[0], data->data_var.header.manufacturer[1], diff --git a/mbus/mbus-protocol.h b/mbus/mbus-protocol.h index 16932645..2d4f5a17 100755 --- a/mbus/mbus-protocol.h +++ b/mbus/mbus-protocol.h @@ -627,6 +627,7 @@ int mbus_data_bcd_encode(unsigned char *bcd_data, size_t bcd_data_size, int valu int mbus_data_int_encode(unsigned char *int_data, size_t int_data_size, int value); long long mbus_data_bcd_decode(unsigned char *bcd_data, size_t bcd_data_size); +long long mbus_data_bcd_decode_hex(unsigned char *bcd_data, size_t bcd_data_size); int mbus_data_int_decode(unsigned char *int_data, size_t int_data_size, int *value); int mbus_data_long_decode(unsigned char *int_data, size_t int_data_size, long *value); int mbus_data_long_long_decode(unsigned char *int_data, size_t int_data_size, long long *value); diff --git a/test/test-frames/EFE_Engelmann-WaterStar.xml b/test/test-frames/EFE_Engelmann-WaterStar.xml index 278bbc16..2c4a5363 100644 --- a/test/test-frames/EFE_Engelmann-WaterStar.xml +++ b/test/test-frames/EFE_Engelmann-WaterStar.xml @@ -6,7 +6,7 @@ EFE 0 Engelmann WaterStar - Hot water + Warm water (30-90°C) 12 27 0000 diff --git a/test/test-frames/ELS_Elster-F96-Plus.xml b/test/test-frames/ELS_Elster-F96-Plus.xml index 41b3e1f9..1bcedc83 100644 --- a/test/test-frames/ELS_Elster-F96-Plus.xml +++ b/test/test-frames/ELS_Elster-F96-Plus.xml @@ -48,14 +48,14 @@ Value during error state 0 Power (W) - 144445223 + DDDDEBBD Value during error state 0 Volume flow (m m^3/h) - 1445223 + DDEBBD diff --git a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml index 05020492..c2492218 100644 --- a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml +++ b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml @@ -58,7 +58,7 @@ Instantaneous value 0 Temperature Difference (1e-2 deg C) - 1500018 + F00018 diff --git a/test/test-frames/abb_f95.xml b/test/test-frames/abb_f95.xml index 4ddaadf9..2b14a587 100644 --- a/test/test-frames/abb_f95.xml +++ b/test/test-frames/abb_f95.xml @@ -30,14 +30,14 @@ Value during error state 0 Power (1e-1 W) - 144521543 + DDEBB4DD Value during error state 0 Volume flow (1e-4 m^3/h) - 1521543 + EBB4DD diff --git a/test/test-frames/electricity-meter-1.xml b/test/test-frames/electricity-meter-1.xml index 5a32f2ef..98069b99 100644 --- a/test/test-frames/electricity-meter-1.xml +++ b/test/test-frames/electricity-meter-1.xml @@ -2,7 +2,7 @@ - 5000244 + 500023E SBC 18 diff --git a/test/test-frames/electricity-meter-2.xml b/test/test-frames/electricity-meter-2.xml index d5a1c478..810c9c1a 100644 --- a/test/test-frames/electricity-meter-2.xml +++ b/test/test-frames/electricity-meter-2.xml @@ -2,7 +2,7 @@ - 5000345 + 50002E5 @@@ 18 diff --git a/test/test-frames/landis+gyr_ultraheat_t230.xml b/test/test-frames/landis+gyr_ultraheat_t230.xml index 1bd0ef3a..ea3a8791 100644 --- a/test/test-frames/landis+gyr_ultraheat_t230.xml +++ b/test/test-frames/landis+gyr_ultraheat_t230.xml @@ -72,7 +72,7 @@ Instantaneous value 0 Temperature Difference (1e-1 deg C) - 1500002 + F00002 diff --git a/test/test-frames/siemens_water.xml b/test/test-frames/siemens_water.xml index a8ec54af..8cc6c65a 100644 --- a/test/test-frames/siemens_water.xml +++ b/test/test-frames/siemens_water.xml @@ -6,7 +6,7 @@ LSE 153 Siemens WFH21 - Hot water + Warm water (30-90°C) 235 00 0000 diff --git a/test/test-frames/siemens_wfh21.xml b/test/test-frames/siemens_wfh21.xml index 8f3b7901..7bff369f 100644 --- a/test/test-frames/siemens_wfh21.xml +++ b/test/test-frames/siemens_wfh21.xml @@ -6,7 +6,7 @@ LSE 153 Siemens WFH21 - Hot water + Warm water (30-90°C) 218 00 0000 From e1f0592868d1748859bc6d0a549fa5af0e425ca7 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 1 Jul 2020 00:15:09 +0200 Subject: [PATCH 182/238] fix travis tests and adjust to new way to execute tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39fe165c..6da105e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,4 @@ os: script: - ./build.sh - - cd test && make && ./generate-xml.sh test-frames + - ./test/generate-xml.sh test/test-frames From 2302459df80e968dfc81ce8f813fd163149ccdc9 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 12:06:39 +0200 Subject: [PATCH 183/238] Also generate normalized XML In order to increase the test coverage also generate the normalized version of XML output. (cherry picked from commit bf177d1fe7e64242638ac82068414f772b6d13ed) --- test/generate-xml.sh | 52 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index 6a3231ff..b9662d93 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -37,51 +37,71 @@ if [ $# -eq 2 ]; then fi # Check if mbus_parse_hex exists -if [ ! -x $mbus_parse_hex ]; then +if [ ! -x "$mbus_parse_hex" ]; then echo "mbus_parse_hex not found" echo "path to mbus_parse_hex: $mbus_parse_hex" exit 3 fi -for hexfile in "$directory"/*.hex; do - if [ ! -f "$hexfile" ]; then - continue - fi +generate_xml() { + directory="$1" + hexfile="$2" + mode="$3" - filename=`basename $hexfile .hex` + filename=$(basename "$hexfile" .hex) + + if [ "$mode" = "normalized" ]; then + options="-n" + mode=".norm" + else + options="" + mode="" + fi # Parse hex file and write XML in file - $mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new" + "$mbus_parse_hex" $options "$hexfile" > "$directory/$filename$mode.xml.new" result=$? # Check parsing result if [ $result -ne 0 ]; then echo "Unable to generate XML for $hexfile" - rm "$directory/$filename.xml.new" - continue + rm "$directory/$filename$mode.xml.new" + return 1 fi # Compare old XML with new XML and write in file - diff -u "$directory/$filename.xml" "$directory/$filename.xml.new" 2> /dev/null > "$directory/$filename.dif" + diff -u "$directory/$filename$mode.xml" "$directory/$filename$mode.xml.new" 2> /dev/null > "$directory/$filename$mode.dif" result=$? case "$result" in 0) # XML equal -> remove new - rm "$directory/$filename.xml.new" - rm "$directory/$filename.dif" + rm "$directory/$filename$mode.xml.new" + rm "$directory/$filename$mode.dif" ;; 1) # different -> print diff - cat "$directory/$filename.dif" && rm "$directory/$filename.dif" + cat "$directory/$filename$mode.dif" && rm "$directory/$filename$mode.dif" echo "" ;; *) # no old -> rename XML - echo "Create $filename.xml" - mv "$directory/$filename.xml.new" "$directory/$filename.xml" - rm "$directory/$filename.dif" + echo "Create $filename$mode.xml" + mv "$directory/$filename$mode.xml.new" "$directory/$filename$mode.xml" + rm "$directory/$filename$mode.dif" ;; esac + + return $result +} + +for hexfile in "$directory"/*.hex; do + if [ ! -f "$hexfile" ]; then + continue + fi + + generate_xml "$directory" "$hexfile" "default" + + generate_xml "$directory" "$hexfile" "normalized" done From 0f473329d942c54f7f98be4b9425017ff7ac3002 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 12:55:05 +0200 Subject: [PATCH 184/238] Add normalized XML files of test frames (cherry picked from commit 97997942134e5e5517051b2014926d4553a975af) --- test/test-frames/ACW_Itron-BM-plus-m.norm.xml | 87 ++++ .../ACW_Itron-CYBLE-M-Bus-14.norm.xml | 79 ++++ test/test-frames/EDC.norm.xml | 231 +++++++++++ .../EFE_Engelmann-Elster-SensoStar-2.norm.xml | 229 +++++++++++ .../EFE_Engelmann-WaterStar.norm.xml | 113 ++++++ test/test-frames/ELS_Elster-F96-Plus.norm.xml | 151 +++++++ test/test-frames/ELV-Elvaco-CMa10.norm.xml | 121 ++++++ .../EMU_EMU-Professional-375-M-Bus.norm.xml | 287 +++++++++++++ test/test-frames/Elster-F2.norm.xml | 133 ++++++ .../FIN-Finder-7E.23.8.230.0020.norm.xml | 69 ++++ test/test-frames/GWF-MTKcoder.norm.xml | 31 ++ test/test-frames/LGB_G350.norm.xml | 65 +++ test/test-frames/REL-Relay-Padpuls2.norm.xml | 63 +++ .../SBC_Saia-Burgess-ALE3.norm.xml | 191 +++++++++ test/test-frames/SEN_Pollustat.norm.xml | 143 +++++++ .../SEN_Sensus-PolluStat-E.norm.xml | 95 +++++ .../SEN_Sensus-PolluTherm.norm.xml | 87 ++++ .../SLB_CF-Compact-Integral-MK-MaXX.norm.xml | 139 +++++++ test/test-frames/THI_cma10.norm.xml | 121 ++++++ .../test-frames/ZRM_Minol-Minocal-C2.norm.xml | 335 ++++++++++++++++ test/test-frames/abb_delta.norm.xml | 153 +++++++ test/test-frames/abb_f95.norm.xml | 131 ++++++ test/test-frames/allmess_cf50.norm.xml | 95 +++++ test/test-frames/berg_dz_plus.norm.xml | 169 ++++++++ test/test-frames/electricity-meter-1.norm.xml | 191 +++++++++ test/test-frames/electricity-meter-2.norm.xml | 191 +++++++++ test/test-frames/els_falcon.norm.xml | 87 ++++ test/test-frames/els_tmpa_telegramm1.norm.xml | 63 +++ test/test-frames/elv_temp_humid.norm.xml | 121 ++++++ test/test-frames/emh_diz.norm.xml | 43 ++ .../engelmann_sensostar2c.norm.xml | 225 +++++++++++ test/test-frames/example_data_01.norm.xml | 63 +++ test/test-frames/example_data_02.norm.xml | 63 +++ test/test-frames/filler.norm.xml | 23 ++ test/test-frames/frame1.norm.xml | 23 ++ test/test-frames/frame2.norm.xml | 43 ++ test/test-frames/gmc_emmod206.norm.xml | 215 ++++++++++ test/test-frames/itron_bm_+m.norm.xml | 87 ++++ test/test-frames/itron_cf_51.norm.xml | 147 +++++++ test/test-frames/itron_cf_55.norm.xml | 119 ++++++ test/test-frames/itron_cf_echo_2.norm.xml | 119 ++++++ ...itron_cyble_m-bus_v1.4_cold_water.norm.xml | 79 ++++ .../itron_cyble_m-bus_v1.4_gas.norm.xml | 79 ++++ .../itron_cyble_m-bus_v1.4_water.norm.xml | 79 ++++ .../itron_integral_mk_maxx.norm.xml | 139 +++++++ test/test-frames/kamstrup_382_005.norm.xml | 75 ++++ .../kamstrup_multical_601.norm.xml | 259 ++++++++++++ .../landis+gyr_ultraheat_t230.norm.xml | 327 +++++++++++++++ test/test-frames/manual_frame2.norm.xml | 23 ++ test/test-frames/manual_frame3.norm.xml | 43 ++ test/test-frames/manual_frame7.norm.xml | 23 ++ test/test-frames/metrona_pollutherm.norm.xml | 95 +++++ .../test-frames/metrona_ultraheat_xs.norm.xml | 379 ++++++++++++++++++ test/test-frames/minol_minocal_c2.norm.xml | 335 ++++++++++++++++ test/test-frames/minol_minocal_wr3.norm.xml | 285 +++++++++++++ test/test-frames/nzr_dhz_5_63.norm.xml | 71 ++++ test/test-frames/oms_frame1.norm.xml | 39 ++ test/test-frames/oms_frame2.norm.xml | 55 +++ test/test-frames/oms_frame3.norm.xml | 87 ++++ test/test-frames/ram_modularis.norm.xml | 311 ++++++++++++++ test/test-frames/rel_padpuls2.norm.xml | 63 +++ test/test-frames/rel_padpuls3.norm.xml | 63 +++ test/test-frames/sen_pollusonic_2.norm.xml | 23 ++ test/test-frames/sen_pollutherm.norm.xml | 90 +++++ test/test-frames/siemens_water.norm.xml | 95 +++++ test/test-frames/siemens_wfh21.norm.xml | 103 +++++ .../sontex_supercal_531_telegram1.norm.xml | 111 +++++ test/test-frames/svm_f22_telegram1.norm.xml | 133 ++++++ test/test-frames/tch_telegramm1.norm.xml | 95 +++++ test/test-frames/wmbus-converted.norm.xml | 23 ++ 70 files changed, 8723 insertions(+) create mode 100644 test/test-frames/ACW_Itron-BM-plus-m.norm.xml create mode 100644 test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml create mode 100644 test/test-frames/EDC.norm.xml create mode 100644 test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml create mode 100644 test/test-frames/EFE_Engelmann-WaterStar.norm.xml create mode 100644 test/test-frames/ELS_Elster-F96-Plus.norm.xml create mode 100644 test/test-frames/ELV-Elvaco-CMa10.norm.xml create mode 100644 test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml create mode 100644 test/test-frames/Elster-F2.norm.xml create mode 100644 test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml create mode 100644 test/test-frames/GWF-MTKcoder.norm.xml create mode 100644 test/test-frames/LGB_G350.norm.xml create mode 100644 test/test-frames/REL-Relay-Padpuls2.norm.xml create mode 100644 test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml create mode 100644 test/test-frames/SEN_Pollustat.norm.xml create mode 100644 test/test-frames/SEN_Sensus-PolluStat-E.norm.xml create mode 100644 test/test-frames/SEN_Sensus-PolluTherm.norm.xml create mode 100644 test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml create mode 100644 test/test-frames/THI_cma10.norm.xml create mode 100644 test/test-frames/ZRM_Minol-Minocal-C2.norm.xml create mode 100644 test/test-frames/abb_delta.norm.xml create mode 100644 test/test-frames/abb_f95.norm.xml create mode 100644 test/test-frames/allmess_cf50.norm.xml create mode 100644 test/test-frames/berg_dz_plus.norm.xml create mode 100644 test/test-frames/electricity-meter-1.norm.xml create mode 100644 test/test-frames/electricity-meter-2.norm.xml create mode 100644 test/test-frames/els_falcon.norm.xml create mode 100644 test/test-frames/els_tmpa_telegramm1.norm.xml create mode 100644 test/test-frames/elv_temp_humid.norm.xml create mode 100644 test/test-frames/emh_diz.norm.xml create mode 100644 test/test-frames/engelmann_sensostar2c.norm.xml create mode 100644 test/test-frames/example_data_01.norm.xml create mode 100644 test/test-frames/example_data_02.norm.xml create mode 100644 test/test-frames/filler.norm.xml create mode 100644 test/test-frames/frame1.norm.xml create mode 100644 test/test-frames/frame2.norm.xml create mode 100644 test/test-frames/gmc_emmod206.norm.xml create mode 100644 test/test-frames/itron_bm_+m.norm.xml create mode 100644 test/test-frames/itron_cf_51.norm.xml create mode 100644 test/test-frames/itron_cf_55.norm.xml create mode 100644 test/test-frames/itron_cf_echo_2.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml create mode 100644 test/test-frames/itron_integral_mk_maxx.norm.xml create mode 100644 test/test-frames/kamstrup_382_005.norm.xml create mode 100644 test/test-frames/kamstrup_multical_601.norm.xml create mode 100644 test/test-frames/landis+gyr_ultraheat_t230.norm.xml create mode 100644 test/test-frames/manual_frame2.norm.xml create mode 100644 test/test-frames/manual_frame3.norm.xml create mode 100644 test/test-frames/manual_frame7.norm.xml create mode 100644 test/test-frames/metrona_pollutherm.norm.xml create mode 100644 test/test-frames/metrona_ultraheat_xs.norm.xml create mode 100644 test/test-frames/minol_minocal_c2.norm.xml create mode 100644 test/test-frames/minol_minocal_wr3.norm.xml create mode 100644 test/test-frames/nzr_dhz_5_63.norm.xml create mode 100644 test/test-frames/oms_frame1.norm.xml create mode 100644 test/test-frames/oms_frame2.norm.xml create mode 100644 test/test-frames/oms_frame3.norm.xml create mode 100644 test/test-frames/ram_modularis.norm.xml create mode 100644 test/test-frames/rel_padpuls2.norm.xml create mode 100644 test/test-frames/rel_padpuls3.norm.xml create mode 100644 test/test-frames/sen_pollusonic_2.norm.xml create mode 100644 test/test-frames/sen_pollutherm.norm.xml create mode 100644 test/test-frames/siemens_water.norm.xml create mode 100644 test/test-frames/siemens_wfh21.norm.xml create mode 100644 test/test-frames/sontex_supercal_531_telegram1.norm.xml create mode 100644 test/test-frames/svm_f22_telegram1.norm.xml create mode 100644 test/test-frames/tch_telegramm1.norm.xml create mode 100644 test/test-frames/wmbus-converted.norm.xml diff --git a/test/test-frames/ACW_Itron-BM-plus-m.norm.xml b/test/test-frames/ACW_Itron-BM-plus-m.norm.xml new file mode 100644 index 00000000..fead0d15 --- /dev/null +++ b/test/test-frames/ACW_Itron-BM-plus-m.norm.xml @@ -0,0 +1,87 @@ + + + + + 11490378 + ACW + 14 + Itron BM +m + Cold water + 10 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11490378.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 54.321000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T11:11:00Z + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + + Firmware version + 2.000000 + + + + Instantaneous value + 0 + + Software version + 6.000000 + + + + Manufacturer specific + 0 + + + 00 01 75 13 + + + diff --git a/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml b/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml new file mode 100644 index 00000000..943c741d --- /dev/null +++ b/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml @@ -0,0 +1,79 @@ + + + + + 9011523 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Water + 37 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 9011523.000000 + + + + Instantaneous value + 0 + - + cust. ID + 09LA076755 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T14:26:00Z + + + + Instantaneous value + 0 + - + bat. time + 2516.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.031000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.031000 + + + + Manufacturer specific + 0 + + + 00 01 1F + + + diff --git a/test/test-frames/EDC.norm.xml b/test/test-frames/EDC.norm.xml new file mode 100644 index 00000000..c43be60c --- /dev/null +++ b/test/test-frames/EDC.norm.xml @@ -0,0 +1,231 @@ + + + + + 11120895 + EDC + 2 + + Heat: Outlet + 23 + 00 + 0000 + + + + Instantaneous value + 0 + 0 + 0 + Wh + Energy + 35000.000000 + + + + Instantaneous value + 0 + 0 + 0 + Wh + Energy + 465000.000000 + + + + Instantaneous value + 0 + 0 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 0 + °C + Flow temperature + 21.536703 + + + + Instantaneous value + 0 + 0 + 0 + °C + Return temperature + 21.605042 + + + + Instantaneous value + 0 + 0 + 1 + °C + Flow temperature + 92.000000 + + + + Instantaneous value + 0 + 0 + 1 + °C + Return temperature + 92.000000 + + + + Instantaneous value + 0 + 0 + 0 + m^3/h + Volume flow + 0.000707 + + + + Instantaneous value + 0 + 0 + 1 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 0 + 0 + m^3/h + Volume flow + 0.357622 + + + + Maximum value + 0 + 0 + 1 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + 0 + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Maximum value + 0 + 0 + 0 + W + Power + 18511.912109 + + + + Maximum value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-07-10T15:25:00Z + + + + Instantaneous value + 0 + 0 + 0 + - + C + 3571.000000 + + + + Instantaneous value + 0 + 0 + 1 + - + C + 413.000000 + + + + Instantaneous value + 0 + 0 + 0 + - + c + 1.000000 + + + + Instantaneous value + 0 + 0 + 1 + - + c + 1.000000 + + + + Manufacturer specific + 0 + + + + + + diff --git a/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml b/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml new file mode 100644 index 00000000..95229632 --- /dev/null +++ b/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml @@ -0,0 +1,229 @@ + + + + + 24083345 + EFE + 0 + Engelmann / Elster SensoStar 2 + Heat: Outlet + 102 + 27 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 24083345.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-12T14:23:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-12-31 + + + + Instantaneous value + 0 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + m^3/h + Volume flow + 0.025000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + W + Power + 11.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 22.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 21.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.090000 + + + + Instantaneous value + 0 + s + On time + 45273600.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000011 + + + diff --git a/test/test-frames/EFE_Engelmann-WaterStar.norm.xml b/test/test-frames/EFE_Engelmann-WaterStar.norm.xml new file mode 100644 index 00000000..c0e11e42 --- /dev/null +++ b/test/test-frames/EFE_Engelmann-WaterStar.norm.xml @@ -0,0 +1,113 @@ + + + + + 4990254 + EFE + 0 + Engelmann WaterStar + Warm water (30-90°C) + 12 + 27 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 4990254.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T12:10:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 0.332000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.331000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 0.332000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-12-31 + + + + Instantaneous value + 0 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + m^3/h + Volume flow + 2.070000 + + + + Instantaneous value + 0 + s + On time + 102902400.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000008 + + + diff --git a/test/test-frames/ELS_Elster-F96-Plus.norm.xml b/test/test-frames/ELS_Elster-F96-Plus.norm.xml new file mode 100644 index 00000000..e2407b37 --- /dev/null +++ b/test/test-frames/ELS_Elster-F96-Plus.norm.xml @@ -0,0 +1,151 @@ + + + + + 44493951 + ELS + 47 + Elster F96 Plus + Heat: Outlet + 161 + 70 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 13131113.000000 + + + + Value during error state + 0 + m^3/h + Volume flow + 131.113000 + + + + Instantaneous value + 0 + °C + Flow temperature + 22.700000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.100000 + + + + Instantaneous value + 0 + s + Operating time + 63072000.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T13:09:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-05-31 + + + diff --git a/test/test-frames/ELV-Elvaco-CMa10.norm.xml b/test/test-frames/ELV-Elvaco-CMa10.norm.xml new file mode 100644 index 00000000..13a95962 --- /dev/null +++ b/test/test-frames/ELV-Elvaco-CMa10.norm.xml @@ -0,0 +1,121 @@ + + + + + 24011561 + ELV + 22 + Elvaco CMa10 + Other + 63 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 2.000000 + + + + Instantaneous value + 0 + - + %RH + 54.100000 + + + + Minimum value + 0 + - + %RH + 33.640000 + + + + Maximum value + 0 + - + %RH + 73.630000 + + + + Instantaneous value + 0 + °C + External temperature + 20.940000 + + + + Minimum value + 0 + °C + External temperature + 13.720000 + + + + Maximum value + 0 + °C + External temperature + 29.780000 + + + + Instantaneous value + 0 + s + Averaging Duration + 86400.000000 + + + + Instantaneous value + 1 + °C + External temperature + 20.920000 + + + + Instantaneous value + 2 + 0 + 0 + °C + External temperature + 20.790000 + + + + Instantaneous value + 0 + + Fabrication No + 24011561.000000 + + + + Instantaneous value + 0 + + Software version + 262144.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml b/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml new file mode 100644 index 00000000..e1d3388b --- /dev/null +++ b/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml @@ -0,0 +1,287 @@ + + + + + 32629 + EMU + 16 + EMU Professional 3/75 M-Bus + Electricity + 2 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 32629.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 1364.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 7854.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + W + Power + -2.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + W + Power + -2.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 14.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 14.000000 + + + + Instantaneous value + 0 + V + Voltage + 225.700000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Minimum value + 0 + V + Voltage + 187.400000 + + + + Minimum value + 0 + V + Voltage + 0.000000 + + + + Minimum value + 0 + V + Voltage + 0.000000 + + + + Maximum value + 0 + V + Voltage + 241.000000 + + + + Maximum value + 0 + V + Voltage + 0.000000 + + + + Maximum value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + -0.066000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + A + Current + -0.066000 + + + + Instantaneous value + 0 + + Manufacturer specific + 13.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 500.000000 + + + + Instantaneous value + 0 + + Reset counter + 56.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/Elster-F2.norm.xml b/test/test-frames/Elster-F2.norm.xml new file mode 100644 index 00000000..c8fdec54 --- /dev/null +++ b/test/test-frames/Elster-F2.norm.xml @@ -0,0 +1,133 @@ + + + + + 802657 + SVM + 8 + Elster F2 / Deltamess F2 + Heat: Outlet + 70 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5272000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 1204.270000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 917.690000 + + + + Instantaneous value + 0 + °C + Flow temperature + 28.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 34.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + s + On time + 149014800.000000 + + + + Instantaneous value + 0 + s + Operating time + 149014800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2013-06-29T12:12:00Z + + + + Instantaneous value + 0 + 0 + 1 + Units for H.C.A. + H.C.A. + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Units for H.C.A. + H.C.A. + 0.000000 + + + + More records follow + 0 + + + C4 09 01 01 12 00 01 01 01 07 57 26 80 00 CD 4E 08 04 07 A3 FF 03 57 26 80 00 04 04 0D 02 FF 0F 05 3C FF 62 E7 62 96 0A 89 0A 02 00 15 40 17 01 00 00 63 42 + + + diff --git a/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml b/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml new file mode 100644 index 00000000..118a1f5c --- /dev/null +++ b/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml @@ -0,0 +1,69 @@ + + + + + 23006207 + FIN + 35 + + Electricity + 146 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 1728680.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 1728680.000000 + + + + Instantaneous value + 0 + V + Voltage + 230.000000 + + + + Instantaneous value + 0 + A + Current + 0.600000 + + + + Instantaneous value + 0 + W + Power + 90.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -30.000000 + + + diff --git a/test/test-frames/GWF-MTKcoder.norm.xml b/test/test-frames/GWF-MTKcoder.norm.xml new file mode 100644 index 00000000..6cadee12 --- /dev/null +++ b/test/test-frames/GWF-MTKcoder.norm.xml @@ -0,0 +1,31 @@ + + + + + 182007 + GWF + 53 + + Water + 76 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 182007.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 269.000000 + + + diff --git a/test/test-frames/LGB_G350.norm.xml b/test/test-frames/LGB_G350.norm.xml new file mode 100644 index 00000000..acc91446 --- /dev/null +++ b/test/test-frames/LGB_G350.norm.xml @@ -0,0 +1,65 @@ + + + + + 12082058 + LGB + 64 + + Gas + 64 + 00 + 0000 + + + + Instantaneous value + 1 + m^3 + Volume + 10834.092000 + + + + Instantaneous value + 1 + - + Time point (date & time) + 2016-07-22T08:00:00Z + + + + Instantaneous value + 0 + + Fabrication No + G0017591208205814 + + + + Instantaneous value + 0 + 0 + 1 + + Digital Output + 1.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Special supplier information + 15.000000 + + + diff --git a/test/test-frames/REL-Relay-Padpuls2.norm.xml b/test/test-frames/REL-Relay-Padpuls2.norm.xml new file mode 100644 index 00000000..b5b14405 --- /dev/null +++ b/test/test-frames/REL-Relay-Padpuls2.norm.xml @@ -0,0 +1,63 @@ + + + + + 11216301 + REL + 65 + + Gas + 177 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 28760.810000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 1900-01-00T00:00:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 1 + m^3 + Volume + 25973.820000 + + + + Instantaneous value + 1 + - + Time point (date) + 2015-12-31 + + + + Manufacturer specific + 0 + + + C0 01 01 0C + + + diff --git a/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml b/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml new file mode 100644 index 00000000..cc646d79 --- /dev/null +++ b/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml @@ -0,0 +1,191 @@ + + + + + 19000055 + SBC + 22 + Saia-Burgess ALE3 + Electricity + 191 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 2930.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 2930.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 60.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 60.000000 + + + + Instantaneous value + 0 + V + Voltage + 223.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + diff --git a/test/test-frames/SEN_Pollustat.norm.xml b/test/test-frames/SEN_Pollustat.norm.xml new file mode 100644 index 00000000..a69a6eec --- /dev/null +++ b/test/test-frames/SEN_Pollustat.norm.xml @@ -0,0 +1,143 @@ + + + + + 11788 + SEN + 6 + + Heat / Cooling load meter + 62 + 00 + 0000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2015-04-07T14:59:00Z + + + + Value during error state + 0 + - + Time point (date & time) + 2000-01-01T00:00:00Z + + + + Value during error state + 0 + + Error flags + 67108864.000000 + + + + Instantaneous value + 0 + s + On time + 15803026.000000 + + + + Instantaneous value + 0 + s + Operating time + 15145636.000000 + + + + Instantaneous value + 0 + Wh + Energy + 39831000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 6162.878000 + + + + Instantaneous value + 0 + W + Power + -170.721784 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 3.230039 + + + + Instantaneous value + 0 + °C + Flow temperature + 31.147324 + + + + Instantaneous value + 0 + °C + Return temperature + 31.193100 + + + + Instantaneous value + 0 + K + Temperature difference + -0.045776 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 11582321.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 756.000000 + + + + Instantaneous value + 0 + + Fabrication No + 11788.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + -19184.000000 + + + diff --git a/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml b/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml new file mode 100644 index 00000000..e0ac268c --- /dev/null +++ b/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml @@ -0,0 +1,95 @@ + + + + + 21265095 + SEN + 14 + Sensus PolluStat E + Heat: Outlet + 181 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.100000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.200000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 21265095.000000 + + + + Instantaneous value + 0 + + Customer location + 21265095.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/SEN_Sensus-PolluTherm.norm.xml b/test/test-frames/SEN_Sensus-PolluTherm.norm.xml new file mode 100644 index 00000000..c46e40da --- /dev/null +++ b/test/test-frames/SEN_Sensus-PolluTherm.norm.xml @@ -0,0 +1,87 @@ + + + + + 24351689 + SEN + 11 + Sensus PolluTherm + Heat: Outlet + 84 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 0.000000 + + + + Value during error state + 0 + °C + Return temperature + 0.000000 + + + + Value during error state + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 24351689.000000 + + + + Instantaneous value + 0 + + Customer location + 24351689.000000 + + + diff --git a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml new file mode 100644 index 00000000..a5e4a4a8 --- /dev/null +++ b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml @@ -0,0 +1,139 @@ + + + + + 11817314 + SLB + 6 + CF Compact / Integral MK MaXX + Heat: Outlet + 3 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11817314.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.020000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 21.800000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.000000 + + + + Instantaneous value + 0 + K + Temperature difference + -0.180000 + + + + Value during error state + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + s + Operating time + 101606400.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T14:02:00Z + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 3.210000 + + + + Instantaneous value + 0 + + Firmware version + 3.000000 + + + + Instantaneous value + 0 + + Software version + 18.000000 + + + + Manufacturer specific + 0 + + + 00 16 + + + diff --git a/test/test-frames/THI_cma10.norm.xml b/test/test-frames/THI_cma10.norm.xml new file mode 100644 index 00000000..86e149a6 --- /dev/null +++ b/test/test-frames/THI_cma10.norm.xml @@ -0,0 +1,121 @@ + + + + + 2 + ELV + 21 + Elvaco CMa10 + Other + 13 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 2.000000 + + + + Instantaneous value + 0 + - + %RH + 46.600000 + + + + Minimum value + 0 + - + %RH + 37.820000 + + + + Maximum value + 0 + - + %RH + 51.220000 + + + + Instantaneous value + 0 + °C + External temperature + 22.620000 + + + + Minimum value + 0 + °C + External temperature + 22.500000 + + + + Maximum value + 0 + °C + External temperature + 23.260000 + + + + Instantaneous value + 0 + s + Averaging Duration + 0.000000 + + + + Value during error state + 1 + °C + External temperature + 0.000000 + + + + Value during error state + 2 + 0 + 0 + °C + External temperature + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 2.000000 + + + + Instantaneous value + 0 + + Software version + 772.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml b/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml new file mode 100644 index 00000000..7ac242fe --- /dev/null +++ b/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml @@ -0,0 +1,335 @@ + + + + + 31425084 + ZRM + 129 + Minol Minocal C2 + Heat: Outlet + 115 + 27 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date & time) + 2015-01-01T00:00:00Z + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 10 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.074000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 0.043000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + W + Power + 2000.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + °C + Flow temperature + 20.710000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.380000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T12:45:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2014-03-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 33 + 0 + 0 + - + Time point (date) + 2014-02-01 + + + + Instantaneous value + 33 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 34 + 0 + 0 + - + Time point (date) + 2014-01-01 + + + + Instantaneous value + 34 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 35 + 0 + 0 + - + Time point (date) + 2013-12-01 + + + + Instantaneous value + 35 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 36 + 0 + 0 + - + Time point (date) + 2013-11-01 + + + + Instantaneous value + 36 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 37 + 0 + 0 + - + Time point (date) + 2013-10-01 + + + + Instantaneous value + 37 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 38 + 0 + 0 + - + Time point (date) + 2013-09-01 + + + + Instantaneous value + 38 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 39 + 0 + 0 + - + Time point (date) + 2013-08-01 + + + + Instantaneous value + 39 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2014-03-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/abb_delta.norm.xml b/test/test-frames/abb_delta.norm.xml new file mode 100644 index 00000000..6b82deb6 --- /dev/null +++ b/test/test-frames/abb_delta.norm.xml @@ -0,0 +1,153 @@ + + + + + 78563412 + ABB + 2 + ABB Delta-Meter + Electricity + 69 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 1000000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/abb_f95.norm.xml b/test/test-frames/abb_f95.norm.xml new file mode 100644 index 00000000..52f18667 --- /dev/null +++ b/test/test-frames/abb_f95.norm.xml @@ -0,0 +1,131 @@ + + + + + 26718590 + HYD + 40 + ABB F95 Typ US770 + Heat: Outlet + 115 + 50 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.074200 + + + + Value during error state + 0 + W + Power + 1311041.300000 + + + + Value during error state + 0 + m^3/h + Volume flow + 11.041300 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.400000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.400000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T16:34:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date & time) + 2011-04-30T23:59:00Z + + + + Instantaneous value + 1 + - + Time point (date & time) + 2012-04-30T23:59:00Z + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date & time) + 2011-12-31T23:59:00Z + + + + Instantaneous value + 0 + s + Operating time + 311590800.000000 + + + diff --git a/test/test-frames/allmess_cf50.norm.xml b/test/test-frames/allmess_cf50.norm.xml new file mode 100644 index 00000000..2195924e --- /dev/null +++ b/test/test-frames/allmess_cf50.norm.xml @@ -0,0 +1,95 @@ + + + + + 2205100 + SLB + 2 + Allmess Megacontrol CF-50 + Heat: Outlet + 0 + 88 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.300000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 128.800000 + + + + Instantaneous value + 0 + °C + Return temperature + 51.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 77.230000 + + + + Instantaneous value + 0 + - + Time point (date) + 2012-01-12 + + + + Instantaneous value + 0 + s + Operating time + 292291200.000000 + + + + Manufacturer specific + 0 + + + 60 00 + + + diff --git a/test/test-frames/berg_dz_plus.norm.xml b/test/test-frames/berg_dz_plus.norm.xml new file mode 100644 index 00000000..b4def167 --- /dev/null +++ b/test/test-frames/berg_dz_plus.norm.xml @@ -0,0 +1,169 @@ + + + + + 0 + ABB + 2 + ABB Delta-Meter + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + More records follow + 0 + + + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + diff --git a/test/test-frames/electricity-meter-1.norm.xml b/test/test-frames/electricity-meter-1.norm.xml new file mode 100644 index 00000000..49b42973 --- /dev/null +++ b/test/test-frames/electricity-meter-1.norm.xml @@ -0,0 +1,191 @@ + + + + + 500023E + SBC + 18 + + Electricity + 19 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 12520.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 12520.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 17744330.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 17744330.000000 + + + + Instantaneous value + 0 + V + Voltage + 237.000000 + + + + Instantaneous value + 0 + A + Current + 3.200000 + + + + Instantaneous value + 0 + W + Power + 790.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -180.000000 + + + + Instantaneous value + 0 + V + Voltage + 231.000000 + + + + Instantaneous value + 0 + A + Current + 3.500000 + + + + Instantaneous value + 0 + W + Power + 810.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -150.000000 + + + + Instantaneous value + 0 + V + Voltage + 228.000000 + + + + Instantaneous value + 0 + A + Current + 6.900000 + + + + Instantaneous value + 0 + W + Power + 1600.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -320.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 3200.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -650.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 4.000000 + + + diff --git a/test/test-frames/electricity-meter-2.norm.xml b/test/test-frames/electricity-meter-2.norm.xml new file mode 100644 index 00000000..c8d95e23 --- /dev/null +++ b/test/test-frames/electricity-meter-2.norm.xml @@ -0,0 +1,191 @@ + + + + + 50002E5 + @@@ + 18 + + Electricity + 37 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 2540.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 2540.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 4441280.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 4441280.000000 + + + + Instantaneous value + 0 + V + Voltage + 233.000000 + + + + Instantaneous value + 0 + A + Current + 0.100000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 234.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 235.000000 + + + + Instantaneous value + 0 + A + Current + 0.100000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 4.000000 + + + diff --git a/test/test-frames/els_falcon.norm.xml b/test/test-frames/els_falcon.norm.xml new file mode 100644 index 00000000..c0f2ff4d --- /dev/null +++ b/test/test-frames/els_falcon.norm.xml @@ -0,0 +1,87 @@ + + + + + 70112345 + ELS + 10 + Elster Falcon + Water + 2 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 1234.567000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2007-02-06T13:58:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2007-01-01 + + + + Instantaneous value + 1 + m^3 + Volume + 456.951000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Maximum value + 0 + m^3/h + Volume flow + 5.945000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 6.137000 + + + + Manufacturer specific + 0 + + + 0E 42 20 01 01 01 00 05 08 5E 01 20 3D 12 08 3D 12 08 00 + + + diff --git a/test/test-frames/els_tmpa_telegramm1.norm.xml b/test/test-frames/els_tmpa_telegramm1.norm.xml new file mode 100644 index 00000000..16a06819 --- /dev/null +++ b/test/test-frames/els_tmpa_telegramm1.norm.xml @@ -0,0 +1,63 @@ + + + + + 70112345 + ELS + 2 + Elster TMP-A + Water + 2 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 1234.567000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2007-02-06T13:58:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2007-01-01 + + + + Instantaneous value + 1 + m^3 + Volume + 456.951000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Manufacturer specific + 0 + + + 00 + + + diff --git a/test/test-frames/elv_temp_humid.norm.xml b/test/test-frames/elv_temp_humid.norm.xml new file mode 100644 index 00000000..369720a5 --- /dev/null +++ b/test/test-frames/elv_temp_humid.norm.xml @@ -0,0 +1,121 @@ + + + + + 54000834 + ELV + 50 + Elvaco CMa11 + Other + 242 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 0.000000 + + + + Instantaneous value + 0 + - + %RH + 45.640000 + + + + Minimum value + 0 + - + %RH + 45.520000 + + + + Maximum value + 0 + - + %RH + 58.120000 + + + + Instantaneous value + 0 + °C + External temperature + 22.560000 + + + + Minimum value + 0 + °C + External temperature + 21.600000 + + + + Maximum value + 0 + °C + External temperature + 23.390000 + + + + Instantaneous value + 0 + s + Averaging Duration + 86400.000000 + + + + Instantaneous value + 1 + °C + External temperature + 22.760000 + + + + Instantaneous value + 2 + 0 + 0 + °C + External temperature + 22.690000 + + + + Instantaneous value + 0 + + Fabrication No + 54000834.000000 + + + + Instantaneous value + 0 + + Software version + 262144.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/emh_diz.norm.xml b/test/test-frames/emh_diz.norm.xml new file mode 100644 index 00000000..7a9a6fc9 --- /dev/null +++ b/test/test-frames/emh_diz.norm.xml @@ -0,0 +1,43 @@ + + + + + 623702 + EMH + 0 + EMH DIZ + Electricity + 7 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 4090.000000 + + + + Instantaneous value + 1 + 0 + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/engelmann_sensostar2c.norm.xml b/test/test-frames/engelmann_sensostar2c.norm.xml new file mode 100644 index 00000000..97331437 --- /dev/null +++ b/test/test-frames/engelmann_sensostar2c.norm.xml @@ -0,0 +1,225 @@ + + + + + 10380010 + EFE + 1 + Engelmann SensoStar 2C + Heat: Outlet + 30 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10380010.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-06-06T20:50:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 12.900000 + + + + Instantaneous value + 0 + Wh + Energy + 800000.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 95.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 43.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 52.580000 + + + + Instantaneous value + 0 + s + Operating time + 43718400.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.100000 + + + + Instantaneous value + 1 + - + Time point (date) + 2011-12-31 + + + + Instantaneous value + 1 + m^3 + Volume + 12.900000 + + + + Instantaneous value + 1 + Wh + Energy + 800000.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date) + 2010-12-31 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 8.400000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 500000.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 3 + 0 + Wh + Energy + 0.000000 + + + diff --git a/test/test-frames/example_data_01.norm.xml b/test/test-frames/example_data_01.norm.xml new file mode 100644 index 00000000..54ba0bb1 --- /dev/null +++ b/test/test-frames/example_data_01.norm.xml @@ -0,0 +1,63 @@ + + + + + 3575845 + AMT + 52 + + Heat: Outlet + 158 + 00 + B627 + + + + Instantaneous value + 0 + Wh + Energy + 1389817000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 504647.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 41.737434 + + + + Instantaneous value + 0 + °C + Return temperature + 35.463650 + + + diff --git a/test/test-frames/example_data_02.norm.xml b/test/test-frames/example_data_02.norm.xml new file mode 100644 index 00000000..d135aae2 --- /dev/null +++ b/test/test-frames/example_data_02.norm.xml @@ -0,0 +1,63 @@ + + + + + 3575845 + AMT + 52 + + Heat: Outlet + 161 + 00 + B627 + + + + Instantaneous value + 0 + Wh + Energy + 1389817000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 504647.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 41.211052 + + + + Instantaneous value + 0 + °C + Return temperature + 35.385593 + + + diff --git a/test/test-frames/filler.norm.xml b/test/test-frames/filler.norm.xml new file mode 100644 index 00000000..f7a01342 --- /dev/null +++ b/test/test-frames/filler.norm.xml @@ -0,0 +1,23 @@ + + + + + 17677731 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5000.000000 + + + diff --git a/test/test-frames/frame1.norm.xml b/test/test-frames/frame1.norm.xml new file mode 100644 index 00000000..92877062 --- /dev/null +++ b/test/test-frames/frame1.norm.xml @@ -0,0 +1,23 @@ + + + + + 10060958 + LSE + 22 + + Bus/System + 123 + 00 + 0000 + + + + Manufacturer specific + 0 + + + 5F 42 01 11 FF FF FF FF 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + diff --git a/test/test-frames/frame2.norm.xml b/test/test-frames/frame2.norm.xml new file mode 100644 index 00000000..0b29cb81 --- /dev/null +++ b/test/test-frames/frame2.norm.xml @@ -0,0 +1,43 @@ + + + + + 12345678 + PAD + 1 + + Water + 85 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 12.565000 + + + + Maximum value + 5 + 0 + 0 + m^3/h + Volume flow + 0.113000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 218370.000000 + + + diff --git a/test/test-frames/gmc_emmod206.norm.xml b/test/test-frames/gmc_emmod206.norm.xml new file mode 100644 index 00000000..da2ec220 --- /dev/null +++ b/test/test-frames/gmc_emmod206.norm.xml @@ -0,0 +1,215 @@ + + + + + 12345678 + GMC + 230 + GMC-I A230 EMMOD 206 + Electricity + 2 + 00 + 0000 + + + + Instantaneous value + 0 + 0 + 1 + V + Voltage + 86.400000 + + + + Instantaneous value + 0 + 0 + 2 + V + Voltage + 95.900000 + + + + Instantaneous value + 0 + 0 + 3 + V + Voltage + 105.600000 + + + + Instantaneous value + 0 + 0 + 1 + A + Current + 0.957000 + + + + Instantaneous value + 0 + 0 + 2 + A + Current + 1.055000 + + + + Instantaneous value + 0 + 0 + 3 + A + Current + 1.150000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 224.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -202.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 103880.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 150000.000000 + + + + Instantaneous value + 0 + 1 + 1 + Wh + Energy + 201590.000000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 250000.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 300910.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 350000.000000 + + + + Instantaneous value + 0 + 1 + 3 + Wh + Energy + 402370.000000 + + + + Instantaneous value + 0 + 2 + 3 + Wh + Energy + 450000.000000 + + + + Instantaneous value + 2 + 0 + 1 + W + Power + 224.000000 + + + + Instantaneous value + 4 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 6 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 8 + 0 + 1 + W + Power + 202.000000 + + + diff --git a/test/test-frames/itron_bm_+m.norm.xml b/test/test-frames/itron_bm_+m.norm.xml new file mode 100644 index 00000000..cfe33275 --- /dev/null +++ b/test/test-frames/itron_bm_+m.norm.xml @@ -0,0 +1,87 @@ + + + + + 11490378 + ACW + 14 + Itron BM +m + Cold water + 41 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11490378.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 54.321000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:29:00Z + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + + Firmware version + 2.000000 + + + + Instantaneous value + 0 + + Software version + 6.000000 + + + + Manufacturer specific + 0 + + + 00 00 8F 13 + + + diff --git a/test/test-frames/itron_cf_51.norm.xml b/test/test-frames/itron_cf_51.norm.xml new file mode 100644 index 00000000..88f69345 --- /dev/null +++ b/test/test-frames/itron_cf_51.norm.xml @@ -0,0 +1,147 @@ + + + + + 11155185 + ACW + 10 + Itron CF 51 + Heat / Cooling load meter + 27 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11155185.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 999.900000 + + + + Value during error state + 0 + °C + Return temperature + 999.900000 + + + + Value during error state + 0 + K + Temperature difference + 9999.990000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:24:00Z + + + + Instantaneous value + 0 + s + Operating time + 8985600.000000 + + + + Instantaneous value + 0 + + Firmware version + 11.000000 + + + + Instantaneous value + 0 + + Software version + 26.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 321.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Manufacturer specific + 0 + + + 03 20 + + + diff --git a/test/test-frames/itron_cf_55.norm.xml b/test/test-frames/itron_cf_55.norm.xml new file mode 100644 index 00000000..f035c35d --- /dev/null +++ b/test/test-frames/itron_cf_55.norm.xml @@ -0,0 +1,119 @@ + + + + + 11127667 + ACW + 11 + Itron CF 55 + Heat: Inlet + 11 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11127667.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 999.900000 + + + + Value during error state + 0 + °C + Return temperature + 999.900000 + + + + Value during error state + 0 + K + Temperature difference + 9999.990000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T11:47:00Z + + + + Instantaneous value + 0 + s + Operating time + 21772800.000000 + + + + Instantaneous value + 0 + + Firmware version + 10.000000 + + + + Instantaneous value + 0 + + Software version + 21.000000 + + + + Manufacturer specific + 0 + + + 03 20 + + + diff --git a/test/test-frames/itron_cf_echo_2.norm.xml b/test/test-frames/itron_cf_echo_2.norm.xml new file mode 100644 index 00000000..d8ec6093 --- /dev/null +++ b/test/test-frames/itron_cf_echo_2.norm.xml @@ -0,0 +1,119 @@ + + + + + 11100091 + ACW + 9 + Itron CF Echo 2 + Heat: Outlet + 81 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11100091.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Value during error state + 0 + m^3/h + Volume flow + 999.999000 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.090000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:29:00Z + + + + Instantaneous value + 0 + s + Operating time + 33264000.000000 + + + + Instantaneous value + 0 + + Firmware version + 19.000000 + + + + Instantaneous value + 0 + + Software version + 45.000000 + + + + Manufacturer specific + 0 + + + 20 00 + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml new file mode 100644 index 00000000..da7eb622 --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml @@ -0,0 +1,79 @@ + + + + + 10020380 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Cold water + 161 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10020380.000000 + + + + Instantaneous value + 0 + - + cust. ID + + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-10-25T15:39:00Z + + + + Instantaneous value + 0 + - + bat. time + 4050.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 453.500000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 453.500000 + + + + Manufacturer specific + 0 + + + 00 04 1F + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml new file mode 100644 index 00000000..a325227b --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml @@ -0,0 +1,79 @@ + + + + + 10020387 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Gas + 154 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10020387.000000 + + + + Instantaneous value + 0 + - + cust. ID + + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-10-25T15:43:00Z + + + + Instantaneous value + 0 + - + bat. time + 4050.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.260000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.250000 + + + + Manufacturer specific + 0 + + + 00 02 1F + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml new file mode 100644 index 00000000..4e120cdc --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml @@ -0,0 +1,79 @@ + + + + + 12000071 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Water + 10 + 30 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 12000071.000000 + + + + Instantaneous value + 0 + - + cust. ID + TEST CYBLE + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:43:00Z + + + + Instantaneous value + 0 + - + bat. time + 4338.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 123.490000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.200000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Manufacturer specific + 0 + + + 10 01 1F + + + diff --git a/test/test-frames/itron_integral_mk_maxx.norm.xml b/test/test-frames/itron_integral_mk_maxx.norm.xml new file mode 100644 index 00000000..bfc94867 --- /dev/null +++ b/test/test-frames/itron_integral_mk_maxx.norm.xml @@ -0,0 +1,139 @@ + + + + + 11817314 + SLB + 6 + CF Compact / Integral MK MaXX + Heat: Outlet + 93 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11817314.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.020000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 21.200000 + + + + Instantaneous value + 0 + °C + Return temperature + 21.100000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.070000 + + + + Value during error state + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + s + Operating time + 34300800.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T14:17:00Z + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 3.210000 + + + + Instantaneous value + 0 + + Firmware version + 3.000000 + + + + Instantaneous value + 0 + + Software version + 18.000000 + + + + Manufacturer specific + 0 + + + 00 16 + + + diff --git a/test/test-frames/kamstrup_382_005.norm.xml b/test/test-frames/kamstrup_382_005.norm.xml new file mode 100644 index 00000000..d3246e19 --- /dev/null +++ b/test/test-frames/kamstrup_382_005.norm.xml @@ -0,0 +1,75 @@ + + + + + 14839120 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 4 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + s + On time + 32400.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 1 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 0.000000 + + + + Manufacturer specific + 0 + + + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 + + + diff --git a/test/test-frames/kamstrup_multical_601.norm.xml b/test/test-frames/kamstrup_multical_601.norm.xml new file mode 100644 index 00000000..769a90b4 --- /dev/null +++ b/test/test-frames/kamstrup_multical_601.norm.xml @@ -0,0 +1,259 @@ + + + + + 6855817 + KAM + 8 + Kamstrup Multical 601 + Heat: Outlet + 4 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 6855817.000000 + + + + Instantaneous value + 0 + Wh + Energy + 37351000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 561.080000 + + + + Instantaneous value + 0 + s + On time + 3546000.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 101.690000 + + + + Instantaneous value + 0 + °C + Return temperature + 46.160000 + + + + Instantaneous value + 0 + K + Temperature difference + 55.530000 + + + + Instantaneous value + 0 + W + Power + 34700.000000 + + + + Maximum value + 0 + W + Power + 44800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.543000 + + + + Maximum value + 0 + m^3/h + Volume flow + 0.628000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + 0 + 3 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-01-05T15:26:00Z + + + + Instantaneous value + 1 + Wh + Energy + 33361000.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 500.980000 + + + + Maximum value + 1 + W + Power + 55000.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 1.027000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 2 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 3 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2010-12-31 + + + + Manufacturer specific + 0 + + + 00 00 00 00 E7 E4 00 00 63 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B C9 A5 02 34 53 00 00 E0 B2 03 00 89 9C 68 00 00 00 00 00 01 00 01 07 07 09 01 03 00 00 00 00 00 + + + diff --git a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml new file mode 100644 index 00000000..d30f1cd5 --- /dev/null +++ b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml @@ -0,0 +1,327 @@ + + + + + 66660205 + LUG + 7 + Landis & Gyr Ultraheat T230 + Heat: Outlet + 1 + 10 + 0000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + s + Averaging Duration + 8.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 19.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 19.700000 + + + + Instantaneous value + 0 + K + Temperature difference + -0.200000 + + + + Instantaneous value + 0 + + Fabrication No + 66660205.000000 + + + + Instantaneous value + 0 + 1 + 0 + s + Averaging Duration + 420.000000 + + + + Value during error state + 0 + s + On time + 13568400.000000 + + + + Instantaneous value + 0 + s + On time + 13568400.000000 + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + 5 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 30.700000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 50.700000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 41065374.600000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 40953732.300000 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Value during error state + 1 + s + On time + 12488400.000000 + + + + Instantaneous value + 1 + s + Operating time + 0.000000 + + + + Instantaneous value + 1 + 5 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 1 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 1 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + 1 + 0 + °C + Flow temperature + 30.700000 + + + + Maximum value + 1 + 1 + 0 + °C + Return temperature + 50.700000 + + + + Instantaneous value + 510 + 0 + 0 + - + Time point (date & time) + 2127-01-01T00:00:00Z + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T12:04:00Z + + + + Manufacturer specific + 0 + + + 09 07 00 66 01 + + + diff --git a/test/test-frames/manual_frame2.norm.xml b/test/test-frames/manual_frame2.norm.xml new file mode 100644 index 00000000..c6124757 --- /dev/null +++ b/test/test-frames/manual_frame2.norm.xml @@ -0,0 +1,23 @@ + + + + + 12345678 + Water + 10 + 00 + + + + Actual value + l + 1 + + + + Actual value + reserved but historic + 135 + + + diff --git a/test/test-frames/manual_frame3.norm.xml b/test/test-frames/manual_frame3.norm.xml new file mode 100644 index 00000000..0b29cb81 --- /dev/null +++ b/test/test-frames/manual_frame3.norm.xml @@ -0,0 +1,43 @@ + + + + + 12345678 + PAD + 1 + + Water + 85 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 12.565000 + + + + Maximum value + 5 + 0 + 0 + m^3/h + Volume flow + 0.113000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 218370.000000 + + + diff --git a/test/test-frames/manual_frame7.norm.xml b/test/test-frames/manual_frame7.norm.xml new file mode 100644 index 00000000..28c78ac5 --- /dev/null +++ b/test/test-frames/manual_frame7.norm.xml @@ -0,0 +1,23 @@ + + + + + 12345678 + PAD + 1 + + Water + 19 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 1020304.000000 + + + diff --git a/test/test-frames/metrona_pollutherm.norm.xml b/test/test-frames/metrona_pollutherm.norm.xml new file mode 100644 index 00000000..b3f74934 --- /dev/null +++ b/test/test-frames/metrona_pollutherm.norm.xml @@ -0,0 +1,95 @@ + + + + + 44950146 + SPX + 52 + Sensus PolluTherm + Heat: Outlet + 84 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 44950146.000000 + + + + Instantaneous value + 0 + + Customer location + 44950146.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/metrona_ultraheat_xs.norm.xml b/test/test-frames/metrona_ultraheat_xs.norm.xml new file mode 100644 index 00000000..82423fe9 --- /dev/null +++ b/test/test-frames/metrona_ultraheat_xs.norm.xml @@ -0,0 +1,379 @@ + + + + + 1810054 + LUG + 2 + Landis & Gyr Ultraheat 2WR5 + Heat: Outlet + 15 + 10 + 0000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 1 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 0 + + Fabrication No + 65110054.000000 + + + + Instantaneous value + 0 + 1 + 0 + s + Averaging Duration + 3600.000000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 31600.000000 + + + + Maximum value + 1 + 1 + 0 + W + Power + 31600.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 8.820000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 44.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 40.000000 + + + + Instantaneous value + 0 + s + On time + 252241200.000000 + + + + Value during error state + 0 + s + On time + 185792400.000000 + + + + Value during error state + 1 + s + On time + 172141200.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-01-01 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 4 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 2 + 1 + 0 + °C + Flow temperature + 36.000000 + + + + Maximum value + 2 + 1 + 0 + °C + Return temperature + 40.000000 + + + + Maximum value + 2 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 2 + 1 + 0 + W + Power + 0.000000 + + + + Value during error state + 2 + 0 + 0 + s + On time + 185274000.000000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-06-07T00:38:00Z + + + + Manufacturer specific + 0 + + + 03 02 00 00 23 + + + diff --git a/test/test-frames/minol_minocal_c2.norm.xml b/test/test-frames/minol_minocal_c2.norm.xml new file mode 100644 index 00000000..bb7cafb7 --- /dev/null +++ b/test/test-frames/minol_minocal_c2.norm.xml @@ -0,0 +1,335 @@ + + + + + 31425084 + ZRM + 129 + Minol Minocal C2 + Heat: Outlet + 36 + 27 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date & time) + 2013-01-01T00:00:00Z + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 10 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.073000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 0.043000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + W + Power + 2000.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + °C + Flow temperature + 20.090000 + + + + Instantaneous value + 0 + °C + Return temperature + 19.270000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T11:53:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 33 + 0 + 0 + - + Time point (date) + 2011-12-01 + + + + Instantaneous value + 33 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 34 + 0 + 0 + - + Time point (date) + 2011-11-01 + + + + Instantaneous value + 34 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 35 + 0 + 0 + - + Time point (date) + 2011-10-01 + + + + Instantaneous value + 35 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 36 + 0 + 0 + - + Time point (date) + 2011-09-01 + + + + Instantaneous value + 36 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 37 + 0 + 0 + - + Time point (date) + 2011-08-01 + + + + Instantaneous value + 37 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 38 + 0 + 0 + - + Time point (date) + 2011-07-01 + + + + Instantaneous value + 38 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 39 + 0 + 0 + - + Time point (date) + 2011-06-01 + + + + Instantaneous value + 39 + 0 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.001000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/minol_minocal_wr3.norm.xml b/test/test-frames/minol_minocal_wr3.norm.xml new file mode 100644 index 00000000..19ddead9 --- /dev/null +++ b/test/test-frames/minol_minocal_wr3.norm.xml @@ -0,0 +1,285 @@ + + + + + 31802759 + ZRM + 130 + Minol Minocal WR3 + Heat: Outlet + 43 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.010000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 9 + 0 + 0 + - + Time point (date & time) + 2012-01-01T00:00:00Z + + + + Maximum value + 2 + 0 + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2012-01-13T11:30:00Z + + + + Maximum value + 1 + m^3/h + Volume flow + 0.010000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-03-24T07:30:00Z + + + + Instantaneous value + 0 + 0 + 1 + + (Enhanced) Identification + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + + Device type + 7.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 9 + 0 + 0 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + 0 + 2 + + (Enhanced) Identification + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + 0 + 2 + + Device type + 7.000000 + + + + Instantaneous value + 10 + 0 + 0 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + + Error flags + 4.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T12:01:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 32 + 0 + 1 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 32 + 0 + 2 + m^3 + Volume + 0.001000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/nzr_dhz_5_63.norm.xml b/test/test-frames/nzr_dhz_5_63.norm.xml new file mode 100644 index 00000000..46dfb585 --- /dev/null +++ b/test/test-frames/nzr_dhz_5_63.norm.xml @@ -0,0 +1,71 @@ + + + + + 30100608 + NZR + 1 + NZR DHZ 5/63 + Electricity + 1 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 1274.000000 + + + + Instantaneous value + 0 + Wh + Energy + 1274.000000 + + + + Instantaneous value + 0 + V + Voltage + 237.200000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 30100608.000000 + + + + Manufacturer specific + 0 + + + 0E + + + diff --git a/test/test-frames/oms_frame1.norm.xml b/test/test-frames/oms_frame1.norm.xml new file mode 100644 index 00000000..1dfd8649 --- /dev/null +++ b/test/test-frames/oms_frame1.norm.xml @@ -0,0 +1,39 @@ + + + + + 12345678 + ELS + 51 + + Gas + 42 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 28504.270000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2008-05-31T23:50:00Z + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/oms_frame2.norm.xml b/test/test-frames/oms_frame2.norm.xml new file mode 100644 index 00000000..480c8920 --- /dev/null +++ b/test/test-frames/oms_frame2.norm.xml @@ -0,0 +1,55 @@ + + + + + 92752244 + HYD + 41 + + Water + 31 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 2850.427000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.127000 + + + + Instantaneous value + 1 + m^3 + Volume + 1445.419000 + + + + Instantaneous value + 1 + - + Time point (date) + 2007-12-31 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/oms_frame3.norm.xml b/test/test-frames/oms_frame3.norm.xml new file mode 100644 index 00000000..f144e0ee --- /dev/null +++ b/test/test-frames/oms_frame3.norm.xml @@ -0,0 +1,87 @@ + + + + + 12345678 + HYD + 42 + + Heat: Outlet + 38 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 2850427000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 703.476000 + + + + Instantaneous value + 1 + Wh + Energy + 1445419000.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2007-12-31 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.127000 + + + + Instantaneous value + 0 + W + Power + 329.700000 + + + + Instantaneous value + 0 + °C + Flow temperature + 44.300000 + + + + Instantaneous value + 0 + °C + Return temperature + 25.100000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/ram_modularis.norm.xml b/test/test-frames/ram_modularis.norm.xml new file mode 100644 index 00000000..3f6b3f9c --- /dev/null +++ b/test/test-frames/ram_modularis.norm.xml @@ -0,0 +1,311 @@ + + + + + 25776 + RAM + 3 + Rossweiner ETK/ETW Modularis + Water + 139 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 10.116000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2013-10-18T21:40:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2013-09-28 + + + + Instantaneous value + 1 + m^3 + Volume + 8.393000 + + + + Instantaneous value + 1 + - + Time point (date) + 2014-09-28 + + + + Instantaneous value + 0 + + Fabrication No + 25776.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date) + 2013-09-30 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 8.527000 + + + + Instantaneous value + 3 + 0 + 0 + - + Time point (date) + 2012-10-31 + + + + Instantaneous value + 3 + 0 + 0 + m^3 + Volume + 99999.995000 + + + + Instantaneous value + 4 + 0 + 0 + - + Time point (date) + 2012-11-30 + + + + Instantaneous value + 4 + 0 + 0 + m^3 + Volume + 99999.993000 + + + + Instantaneous value + 5 + 0 + 0 + - + Time point (date) + 2012-12-31 + + + + Instantaneous value + 5 + 0 + 0 + m^3 + Volume + 0.782000 + + + + Instantaneous value + 6 + 0 + 0 + - + Time point (date) + 2013-01-31 + + + + Instantaneous value + 6 + 0 + 0 + m^3 + Volume + 1.929000 + + + + Instantaneous value + 7 + 0 + 0 + - + Time point (date) + 2013-02-28 + + + + Instantaneous value + 7 + 0 + 0 + m^3 + Volume + 3.092000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date) + 2013-03-31 + + + + Instantaneous value + 8 + 0 + 0 + m^3 + Volume + 4.661000 + + + + Instantaneous value + 9 + 0 + 0 + - + Time point (date) + 2013-04-30 + + + + Instantaneous value + 9 + 0 + 0 + m^3 + Volume + 4.767000 + + + + Instantaneous value + 10 + 0 + 0 + - + Time point (date) + 2013-05-31 + + + + Instantaneous value + 10 + 0 + 0 + m^3 + Volume + 5.124000 + + + + Instantaneous value + 11 + 0 + 0 + - + Time point (date) + 2013-06-30 + + + + Instantaneous value + 11 + 0 + 0 + m^3 + Volume + 5.176000 + + + + Instantaneous value + 12 + 0 + 0 + - + Time point (date) + 2013-07-31 + + + + Instantaneous value + 12 + 0 + 0 + m^3 + Volume + 5.246000 + + + + Instantaneous value + 13 + 0 + 0 + - + Time point (date) + 2013-08-31 + + + + Instantaneous value + 13 + 0 + 0 + m^3 + Volume + 5.668000 + + + + Manufacturer specific + 0 + + + 01 00 00 + + + diff --git a/test/test-frames/rel_padpuls2.norm.xml b/test/test-frames/rel_padpuls2.norm.xml new file mode 100644 index 00000000..14f88c8c --- /dev/null +++ b/test/test-frames/rel_padpuls2.norm.xml @@ -0,0 +1,63 @@ + + + + + 4 + REL + 18 + Relay PadPuls M4 + Other + 1 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2001-09-20T13:16:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2000-12-31 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2001-12-31 + + + + Manufacturer specific + 0 + + + 43 01 01 00 + + + diff --git a/test/test-frames/rel_padpuls3.norm.xml b/test/test-frames/rel_padpuls3.norm.xml new file mode 100644 index 00000000..b6dafa74 --- /dev/null +++ b/test/test-frames/rel_padpuls3.norm.xml @@ -0,0 +1,63 @@ + + + + + 1030101 + REL + 64 + Relay PadPuls M2 + Heat Cost Allocator + 30 + 00 + 0000 + + + + Instantaneous value + 0 + Units for H.C.A. + H.C.A. + 1987.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2000-12-31T10:41:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2000-12-31 + + + + Instantaneous value + 1 + Units for H.C.A. + H.C.A. + 1302.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2001-12-31 + + + + Manufacturer specific + 0 + + + C0 01 01 0C + + + diff --git a/test/test-frames/sen_pollusonic_2.norm.xml b/test/test-frames/sen_pollusonic_2.norm.xml new file mode 100644 index 00000000..1605e327 --- /dev/null +++ b/test/test-frames/sen_pollusonic_2.norm.xml @@ -0,0 +1,23 @@ + + + + + 90919293 + Heat + 16 + 00 + + + + Actual value + kWh + 6531 + + + + Actual value + l + 69 + + + diff --git a/test/test-frames/sen_pollutherm.norm.xml b/test/test-frames/sen_pollutherm.norm.xml new file mode 100644 index 00000000..56b08c30 --- /dev/null +++ b/test/test-frames/sen_pollutherm.norm.xml @@ -0,0 +1,90 @@ + + + + + 21050076 + SPX + 49 + Sensus PolluTherm + Heat: Outlet + 81 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 8640000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 7998.920000 + + + + + + + Instantaneous value + 0 + W + Power + 54580.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 75.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 59.400000 + + + + Instantaneous value + 0 + K + Temperature difference + 16.076000 + + + + Instantaneous value + 0 + + Fabrication No + 21050076.000000 + + + + Instantaneous value + 0 + + Customer location + 21050076.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/siemens_water.norm.xml b/test/test-frames/siemens_water.norm.xml new file mode 100644 index 00000000..895a7a5d --- /dev/null +++ b/test/test-frames/siemens_water.norm.xml @@ -0,0 +1,95 @@ + + + + + 8021382 + LSE + 153 + Siemens WFH21 + Warm water (30-90°C) + 235 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.101000 + + + + Instantaneous value + 0 + s + On time + 75427200.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-09-14T08:56:00Z + + + + Value during error state + 0 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 0 + + Fabrication No + 8021382.000000 + + + + Instantaneous value + 0 + + Device type + 2173253517322.000000 + + + + Instantaneous value + 0 + + Parameter set identification + WFH21 + + + + Instantaneous value + 0 + + Firmware version + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Manufacturer specific + 0 + + + 37 FD 17 00 00 00 00 00 00 00 00 02 7A 0D 00 02 78 0D 00 + + + diff --git a/test/test-frames/siemens_wfh21.norm.xml b/test/test-frames/siemens_wfh21.norm.xml new file mode 100644 index 00000000..afd7f9fc --- /dev/null +++ b/test/test-frames/siemens_wfh21.norm.xml @@ -0,0 +1,103 @@ + + + + + 8006491 + LSE + 153 + Siemens WFH21 + Warm water (30-90°C) + 218 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + s + On time + 158709600.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-12-01T10:36:00Z + + + + Value during error state + 0 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 0 + + Fabrication No + 8006491.000000 + + + + Instantaneous value + 0 + + Device type + 2173253517322.000000 + + + + Instantaneous value + 0 + + Parameter set identification + WFH21 + + + + Instantaneous value + 0 + + Firmware version + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2010-12-31 + + + + Manufacturer specific + 0 + + + 37 FD 17 00 00 00 00 00 00 00 00 02 7A 25 00 02 78 25 00 + + + diff --git a/test/test-frames/sontex_supercal_531_telegram1.norm.xml b/test/test-frames/sontex_supercal_531_telegram1.norm.xml new file mode 100644 index 00000000..be48c61d --- /dev/null +++ b/test/test-frames/sontex_supercal_531_telegram1.norm.xml @@ -0,0 +1,111 @@ + + + + + 8420624 + SON + 13 + Sontex Supercal 531 + Heat: Outlet + 44 + 30 + 0000 + + + + Instantaneous value + 0 + J + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 1 + 0 + 0 + J + Energy + 0.000000 + + + + Instantaneous value + 1 + 0 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 2 + m^3 + Volume + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/svm_f22_telegram1.norm.xml b/test/test-frames/svm_f22_telegram1.norm.xml new file mode 100644 index 00000000..48b84043 --- /dev/null +++ b/test/test-frames/svm_f22_telegram1.norm.xml @@ -0,0 +1,133 @@ + + + + + 1006089 + SVM + 9 + Elster F4 / Kamstrup SVM F22 + Heat: Inlet + 148 + 70 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 28014000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 640.581000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 640.581000 + + + + Instantaneous value + 0 + °C + Flow temperature + 243.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 243.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + s + On time + 22932000.000000 + + + + Instantaneous value + 0 + s + Operating time + 22906800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2021-02-08T21:12:00Z + + + + Instantaneous value + 0 + 0 + 1 + Units for H.C.A. + H.C.A. + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Units for H.C.A. + H.C.A. + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/tch_telegramm1.norm.xml b/test/test-frames/tch_telegramm1.norm.xml new file mode 100644 index 00000000..bdaaa224 --- /dev/null +++ b/test/test-frames/tch_telegramm1.norm.xml @@ -0,0 +1,95 @@ + + + + + 21519982 + TCH + 38 + Techem m-bus S + Heat: Outlet + 133 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2000-09-29T13:50:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-05-29 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 23.400000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.400000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.064000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/wmbus-converted.norm.xml b/test/test-frames/wmbus-converted.norm.xml new file mode 100644 index 00000000..f7a01342 --- /dev/null +++ b/test/test-frames/wmbus-converted.norm.xml @@ -0,0 +1,23 @@ + + + + + 17677731 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5000.000000 + + + From 56134f441ffd6bb995c4a3c4390e65f910fa9256 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 14:10:25 +0200 Subject: [PATCH 185/238] Fix VIF descriptions (cherry picked from commit 908334af0b42b8d8160c8cc369bdcbf56de788db) --- mbus/mbus-protocol-aux.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 2bb52d88..903dcfbc 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -204,10 +204,10 @@ mbus_variable_vif vif_table[] = { { 0x73, 86400.0, "s", "Averaging Duration" }, /* days */ /* E111 01nn Actuality Duration s */ - { 0x74, 1.0, "s", "Averaging Duration" }, /* seconds */ - { 0x75, 60.0, "s", "Averaging Duration" }, /* minutes */ - { 0x76, 3600.0, "s", "Averaging Duration" }, /* hours */ - { 0x77, 86400.0, "s", "Averaging Duration" }, /* days */ + { 0x74, 1.0, "s", "Actuality Duration" }, /* seconds */ + { 0x75, 60.0, "s", "Actuality Duration" }, /* minutes */ + { 0x76, 3600.0, "s", "Actuality Duration" }, /* hours */ + { 0x77, 86400.0, "s", "Actuality Duration" }, /* days */ /* Fabrication No */ { 0x78, 1.0, "", "Fabrication No" }, @@ -250,7 +250,7 @@ mbus_variable_vif vif_table[] = { { 0x108, 1.0e0, "", "Access Number (transmission count)" }, /* E000 1001 Medium (as in fixed header) */ - { 0x109, 1.0e0, "", "Device type" }, + { 0x109, 1.0e0, "", "Medium" }, /* E000 1010 Manufacturer (as in fixed header) */ { 0x10A, 1.0e0, "", "Manufacturer" }, @@ -259,7 +259,7 @@ mbus_variable_vif vif_table[] = { { 0x10B, 1.0e0, "", "Parameter set identification" }, /* E000 1100 Model / Version */ - { 0x10C, 1.0e0, "", "Device type" }, + { 0x10C, 1.0e0, "", "Model / Version" }, /* E000 1101 Hardware version # */ { 0x10D, 1.0e0, "", "Hardware version" }, @@ -359,9 +359,9 @@ mbus_variable_vif vif_table[] = { { 0x130, 1.0e0, "Reserved", "Reserved" }, /* ???? */ /* E011 00nn Duration of tariff (nn=01 ..11: min to days) */ - { 0x131, 60.0, "s", "Storage interval" }, /* minute(s) */ - { 0x132, 3600.0, "s", "Storage interval" }, /* hour(s) */ - { 0x133, 86400.0, "s", "Storage interval" }, /* day(s) */ + { 0x131, 60.0, "s", "Duration of tariff" }, /* minute(s) */ + { 0x132, 3600.0, "s", "Duration of tariff" }, /* hour(s) */ + { 0x133, 86400.0, "s", "Duration of tariff" }, /* day(s) */ /* E011 01nn Period of tariff [sec(s) to day(s)] */ { 0x134, 1.0, "s", "Period of tariff" }, /* seconds */ From a8a76433aa3a2b968da290352cff9c4029504113 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 14:13:27 +0200 Subject: [PATCH 186/238] Update normalized XML files This updates the affected XML files after the recent fixes to the VIF description. (cherry picked from commit 6c1e2026d681e346d1830353b16a4924eab4e246) --- test/test-frames/landis+gyr_ultraheat_t230.norm.xml | 2 +- test/test-frames/metrona_ultraheat_xs.norm.xml | 2 +- test/test-frames/minol_minocal_wr3.norm.xml | 4 ++-- test/test-frames/siemens_water.norm.xml | 2 +- test/test-frames/siemens_wfh21.norm.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml index d30f1cd5..70309869 100644 --- a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml +++ b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml @@ -16,7 +16,7 @@ Instantaneous value 0 s - Averaging Duration + Actuality Duration 4.000000 diff --git a/test/test-frames/metrona_ultraheat_xs.norm.xml b/test/test-frames/metrona_ultraheat_xs.norm.xml index 82423fe9..55779d2c 100644 --- a/test/test-frames/metrona_ultraheat_xs.norm.xml +++ b/test/test-frames/metrona_ultraheat_xs.norm.xml @@ -16,7 +16,7 @@ Instantaneous value 0 s - Averaging Duration + Actuality Duration 4.000000 diff --git a/test/test-frames/minol_minocal_wr3.norm.xml b/test/test-frames/minol_minocal_wr3.norm.xml index 19ddead9..6db54925 100644 --- a/test/test-frames/minol_minocal_wr3.norm.xml +++ b/test/test-frames/minol_minocal_wr3.norm.xml @@ -132,7 +132,7 @@ 0 1 - Device type + Medium 7.000000 @@ -182,7 +182,7 @@ 0 2 - Device type + Medium 7.000000 diff --git a/test/test-frames/siemens_water.norm.xml b/test/test-frames/siemens_water.norm.xml index 895a7a5d..a49f1d3a 100644 --- a/test/test-frames/siemens_water.norm.xml +++ b/test/test-frames/siemens_water.norm.xml @@ -56,7 +56,7 @@ Instantaneous value 0 - Device type + Model / Version 2173253517322.000000 diff --git a/test/test-frames/siemens_wfh21.norm.xml b/test/test-frames/siemens_wfh21.norm.xml index afd7f9fc..cac68af0 100644 --- a/test/test-frames/siemens_wfh21.norm.xml +++ b/test/test-frames/siemens_wfh21.norm.xml @@ -56,7 +56,7 @@ Instantaneous value 0 - Device type + Model / Version 2173253517322.000000 From 519c92541665a4c4c9990f6641b5347e40e1d9a5 Mon Sep 17 00:00:00 2001 From: Anders Wennmo Date: Thu, 4 Jun 2020 12:35:58 +0200 Subject: [PATCH 187/238] Implement all of VIF extensions for 0xFD (#166) (cherry picked from commit 5b26e62f55df46ff8b423d3b33a0fb020a2f639b) --- mbus/mbus-protocol.c | 453 ++++++++++++++---- .../EMU_EMU-Professional-375-M-Bus.xml | 2 +- test/test-frames/LGB_G350.xml | 2 +- 3 files changed, 363 insertions(+), 94 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index c8d5f030..6ae54711 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2443,6 +2443,356 @@ mbus_data_error_lookup(int error) return buff; } +static const char * +mbus_unit_duration_nn(int nn) +{ + switch (nn) + { + case 0: + return "second(s)"; + case 1: + return "minute(s)"; + case 2: + return "hour(s)"; + case 3: + return "day(s)"; + } + return "error: out-of-range"; +} + +static const char * +mbus_unit_duration_pp(int pp) +{ + switch (pp) + { + case 0: + return "hour(s)"; + + case 1: + return "day(s)"; + + case 2: + return "month(s)"; + + case 3: + return "year(s)"; + } + return "error: out-of-range"; +} + +static const char * +mbus_vib_unit_lookup_fb(mbus_value_information_block *vib) +{ + static char buff[256]; + snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0xFB,0x%.2X", vib->vife[0]); + return buff; +} + +static const char * +mbus_vib_unit_lookup_fd(mbus_value_information_block *vib) +{ + static char buff[256]; + int n; + + // ignore the extension bit in this selection + const unsigned char masked_vife0 = vib->vife[0] & MBUS_DIB_VIF_WITHOUT_EXTENSION; + + if ((masked_vife0 & 0x7C) == 0x00) + { + // VIFE = E000 00nn Credit of 10nn-3 of the nominal local legal currency units + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Credit of %s of the nominal local legal currency units", mbus_unit_prefix(n - 3)); + } + else if ((masked_vife0 & 0x7C) == 0x04) + { + // VIFE = E000 01nn Debit of 10nn-3 of the nominal local legal currency units + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Debit of %s of the nominal local legal currency units", mbus_unit_prefix(n - 3)); + } + else if (masked_vife0 == 0x08) + { + // E000 1000 + snprintf(buff, sizeof(buff), "Access Number (transmission count)"); + } + else if (masked_vife0 == 0x09) + { + // E000 1001 + snprintf(buff, sizeof(buff), "Medium (as in fixed header)"); + } + else if (masked_vife0 == 0x0A) + { + // E000 1010 + snprintf(buff, sizeof(buff), "Manufacturer (as in fixed header)"); + } + else if (masked_vife0 == 0x0B) + { + // E000 1010 + snprintf(buff, sizeof(buff), "Parameter set identification"); + } + else if (masked_vife0 == 0x0C) + { + // E000 1100 + snprintf(buff, sizeof(buff), "Model / Version"); + } + else if (masked_vife0 == 0x0D) + { + // E000 1100 + snprintf(buff, sizeof(buff), "Hardware version"); + } + else if (masked_vife0 == 0x0E) + { + // E000 1101 + snprintf(buff, sizeof(buff), "Firmware version"); + } + else if (masked_vife0 == 0x0F) + { + // E000 1101 + snprintf(buff, sizeof(buff), "Software version"); + } + else if (masked_vife0 == 0x10) + { + // VIFE = E001 0000 Customer location + snprintf(buff, sizeof(buff), "Customer location"); + } + else if (masked_vife0 == 0x11) + { + // VIFE = E001 0001 Customer + snprintf(buff, sizeof(buff), "Customer"); + } + else if (masked_vife0 == 0x12) + { + // VIFE = E001 0010 Access Code User + snprintf(buff, sizeof(buff), "Access Code User"); + } + else if (masked_vife0 == 0x13) + { + // VIFE = E001 0011 Access Code Operator + snprintf(buff, sizeof(buff), "Access Code Operator"); + } + else if (masked_vife0 == 0x14) + { + // VIFE = E001 0100 Access Code System Operator + snprintf(buff, sizeof(buff), "Access Code System Operator"); + } + else if (masked_vife0 == 0x15) + { + // VIFE = E001 0101 Access Code Developer + snprintf(buff, sizeof(buff), "Access Code Developer"); + } + else if (masked_vife0 == 0x16) + { + // VIFE = E001 0110 Password + snprintf(buff, sizeof(buff), "Password"); + } + else if (masked_vife0 == 0x17) + { + // VIFE = E001 0111 Error flags + snprintf(buff, sizeof(buff), "Error flags"); + } + else if (masked_vife0 == 0x18) + { + // VIFE = E001 1000 Error mask + snprintf(buff, sizeof(buff), "Error mask"); + } + else if (masked_vife0 == 0x19) + { + // VIFE = E001 1001 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x1A) + { + // VIFE = E001 1010 Digital output (binary) + snprintf(buff, sizeof(buff), "Digital output (binary)"); + } + else if (masked_vife0 == 0x1B) + { + // VIFE = E001 1011 Digital input (binary) + snprintf(buff, sizeof(buff), "Digital input (binary)"); + } + else if (masked_vife0 == 0x1C) + { + // VIFE = E001 1100 Baudrate [Baud] + snprintf(buff, sizeof(buff), "Baudrate"); + } + else if (masked_vife0 == 0x1D) + { + // VIFE = E001 1101 response delay time [bittimes] + snprintf(buff, sizeof(buff), "response delay time"); + } + else if (masked_vife0 == 0x1E) + { + // VIFE = E001 1110 Retry + snprintf(buff, sizeof(buff), "Retry"); + } + else if (masked_vife0 == 0x1F) + { + // VIFE = E001 1111 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x20) + { + // VIFE = E010 0000 First storage # for cyclic storage + snprintf(buff, sizeof(buff), "First storage # for cyclic storage"); + } + else if (masked_vife0 == 0x21) + { + // VIFE = E010 0001 Last storage # for cyclic storage + snprintf(buff, sizeof(buff), "Last storage # for cyclic storage"); + } + else if (masked_vife0 == 0x22) + { + // VIFE = E010 0010 Size of storage block + snprintf(buff, sizeof(buff), "Size of storage block"); + } + else if (masked_vife0 == 0x23) + { + // VIFE = E010 0011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x24) + { + // VIFE = E010 01nn Storage interval [sec(s)..day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Storage interval %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x28) + { + // VIFE = E010 1000 Storage interval month(s) + snprintf(buff, sizeof(buff), "Storage interval month(s)"); + } + else if (masked_vife0 == 0x29) + { + // VIFE = E010 1001 Storage interval year(s) + snprintf(buff, sizeof(buff), "Storage interval year(s)"); + } + else if (masked_vife0 == 0x2A) + { + // VIFE = E010 1010 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x2B) + { + // VIFE = E010 1011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x2C) + { + // VIFE = E010 11nn Duration since last readout [sec(s)..day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration since last readout %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x30) + { + // VIFE = E011 0000 Start (date/time) of tariff + snprintf(buff, sizeof(buff), "Start (date/time) of tariff"); + } + else if ((masked_vife0 & 0x7C) == 0x30) + { + // VIFE = E011 00nn Duration of tariff (nn=01 ..11: min to days) + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration of tariff %s", mbus_unit_duration_nn(n)); + } + else if ((masked_vife0 & 0x7C) == 0x34) + { + // VIFE = E011 01nn Period of tariff [sec(s) to day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Period of tariff %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x38) + { + // VIFE = E011 1000 Period of tariff months(s) + snprintf(buff, sizeof(buff), "Period of tariff months(s)"); + } + else if (masked_vife0 == 0x39) + { + // VIFE = E011 1001 Period of tariff year(s) + snprintf(buff, sizeof(buff), "Period of tariff year(s)"); + } + else if (masked_vife0 == 0x3A) + { + // VIFE = E011 1010 dimensionless / no VIF + snprintf(buff, sizeof(buff), "dimensionless / no VIF"); + } + else if (masked_vife0 == 0x3B) + { + // VIFE = E011 1011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x3C) + { + // VIFE = E011 11xx Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x70) == 0x40) + { + // VIFE = E100 nnnn 10^(nnnn-9) V + n = (masked_vife0 & 0x0F); + snprintf(buff, sizeof(buff), "%s V", mbus_unit_prefix(n - 9)); + } + else if ((masked_vife0 & 0x70) == 0x50) + { + // VIFE = E101 nnnn 10nnnn-12 A + n = (masked_vife0 & 0x0F); + snprintf(buff, sizeof(buff), "%s A", mbus_unit_prefix(n - 12)); + } + else if (masked_vife0 == 0x60) { + // VIFE = E110 0000 Reset counter + snprintf(buff, sizeof(buff), "Reset counter"); + } + else if (masked_vife0 == 0x61) { + // VIFE = E110 0001 Cumulation counter + snprintf(buff, sizeof(buff), "Cumulation counter"); + } + else if (masked_vife0 == 0x62) { + // VIFE = E110 0010 Control signal + snprintf(buff, sizeof(buff), "Control signal"); + } + else if (masked_vife0 == 0x63) { + // VIFE = E110 0011 Day of week + snprintf(buff, sizeof(buff), "Day of week"); + } + else if (masked_vife0 == 0x64) { + // VIFE = E110 0100 Week number + snprintf(buff, sizeof(buff), "Week number"); + } + else if (masked_vife0 == 0x65) { + // VIFE = E110 0101 Time point of day change + snprintf(buff, sizeof(buff), "Time point of day change"); + } + else if (masked_vife0 == 0x66) { + // VIFE = E110 0110 State of parameter activation + snprintf(buff, sizeof(buff), "State of parameter activation"); + } + else if (masked_vife0 == 0x67) { + // VIFE = E110 0111 Special supplier information + snprintf(buff, sizeof(buff), "Special supplier information"); + } + else if ((masked_vife0 & 0x7C) == 0x68) { + // VIFE = E110 10pp Duration since last cumulation [hour(s)..years(s)]Ž + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration since last cumulation %s", mbus_unit_duration_pp(n)); + } + else if ((masked_vife0 & 0x7C) == 0x6C) { + // VIFE = E110 11pp Operating time battery [hour(s)..years(s)]Ž + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Operating time battery %s", mbus_unit_duration_pp(n)); + } + else if (masked_vife0 == 0x70) { + // VIFE = E111 0000 Date and time of battery change + snprintf(buff, sizeof(buff), "Date and time of battery change"); + } + else if ((masked_vife0 & 0x70) == 0x70) + { + // VIFE = E111 nnn Reserved + snprintf(buff, sizeof(buff), "Reserved VIF extension"); + } + else + { + snprintf(buff, sizeof(buff), "Unrecognized VIF 0xFD extension: 0x%.2x", masked_vife0); + } + + return buff; +} //------------------------------------------------------------------------------ /// Lookup the unit from the VIB (VIF or VIFE) @@ -2466,104 +2816,23 @@ mbus_vib_unit_lookup(mbus_value_information_block *vib) if (vib == NULL) return ""; - if (vib->vif == 0xFD || vib->vif == 0xFB) // first type of VIF extention: see table 8.4.4 + if (vib->vif == 0xFB) // first type of VIF extention: see table 8.4.4 { if (vib->nvife == 0) { - snprintf(buff, sizeof(buff), "Missing VIF extension"); - } - else if (vib->vife[0] == 0x08 || vib->vife[0] == 0x88) - { - // E000 1000 - snprintf(buff, sizeof(buff), "Access Number (transmission count)"); - } - else if (vib->vife[0] == 0x09|| vib->vife[0] == 0x89) - { - // E000 1001 - snprintf(buff, sizeof(buff), "Medium (as in fixed header)"); - } - else if (vib->vife[0] == 0x0A || vib->vife[0] == 0x8A) - { - // E000 1010 - snprintf(buff, sizeof(buff), "Manufacturer (as in fixed header)"); - } - else if (vib->vife[0] == 0x0B || vib->vife[0] == 0x8B) - { - // E000 1010 - snprintf(buff, sizeof(buff), "Parameter set identification"); + return "Missing VIF extension"; } - else if (vib->vife[0] == 0x0C || vib->vife[0] == 0x8C) - { - // E000 1100 - snprintf(buff, sizeof(buff), "Model / Version"); - } - else if (vib->vife[0] == 0x0D || vib->vife[0] == 0x8D) - { - // E000 1100 - snprintf(buff, sizeof(buff), "Hardware version"); - } - else if (vib->vife[0] == 0x0E || vib->vife[0] == 0x8E) - { - // E000 1101 - snprintf(buff, sizeof(buff), "Firmware version"); - } - else if (vib->vife[0] == 0x0F || vib->vife[0] == 0x8F) - { - // E000 1101 - snprintf(buff, sizeof(buff), "Software version"); - } - else if (vib->vife[0] == 0x16) - { - // VIFE = E001 0110 Password - snprintf(buff, sizeof(buff), "Password"); - } - else if (vib->vife[0] == 0x17 || vib->vife[0] == 0x97) - { - // VIFE = E001 0111 Error flags - snprintf(buff, sizeof(buff), "Error flags"); - } - else if (vib->vife[0] == 0x10) - { - // VIFE = E001 0000 Customer location - snprintf(buff, sizeof(buff), "Customer location"); - } - else if (vib->vife[0] == 0x11) - { - // VIFE = E001 0001 Customer - snprintf(buff, sizeof(buff), "Customer"); - } - else if (vib->vife[0] == 0x1A) - { - // VIFE = E001 1010 Digital output (binary) - snprintf(buff, sizeof(buff), "Digital output (binary)"); - } - else if (vib->vife[0] == 0x1B) - { - // VIFE = E001 1011 Digital input (binary) - snprintf(buff, sizeof(buff), "Digital input (binary)"); - } - else if ((vib->vife[0] & 0x70) == 0x40) - { - // VIFE = E100 nnnn 10^(nnnn-9) V - n = (vib->vife[0] & 0x0F); - snprintf(buff, sizeof(buff), "%s V", mbus_unit_prefix(n-9)); - } - else if ((vib->vife[0] & 0x70) == 0x50) - { - // VIFE = E101 nnnn 10nnnn-12 A - n = (vib->vife[0] & 0x0F); - snprintf(buff, sizeof(buff), "%s A", mbus_unit_prefix(n-12)); - } - else if ((vib->vife[0] & 0xF0) == 0x70) - { - // VIFE = E111 nnn Reserved - snprintf(buff, sizeof(buff), "Reserved VIF extension"); - } - else + + return mbus_vib_unit_lookup_fb(vib); + } + else if (vib->vif == 0xFD) // first type of VIF extention: see table 8.4.4 + { + if (vib->nvife == 0) { - snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0x%.2x", vib->vife[0]); + return "Missing VIF extension"; } - return buff; + + return mbus_vib_unit_lookup_fd(vib); } else if (vib->vif == 0x7C) { diff --git a/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml b/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml index 8b34fc2f..363ee2b4 100644 --- a/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml +++ b/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml @@ -241,7 +241,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x60 + Reset counter 56 diff --git a/test/test-frames/LGB_G350.xml b/test/test-frames/LGB_G350.xml index d75231c6..45ef288d 100644 --- a/test/test-frames/LGB_G350.xml +++ b/test/test-frames/LGB_G350.xml @@ -52,7 +52,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x67 + Special supplier information 15 From 5fa8509bf2308e0aadbc1bc760b9c6a0e686b490 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Tue, 7 Jul 2020 14:44:35 +0200 Subject: [PATCH 188/238] Implement all of VIF extensions for 0xFB (#166) (cherry picked from commit 67ea2d39005132fcaffccd4c8d31e98adf83d61f) --- mbus/mbus-protocol.c | 245 ++++++++++++++++++++- test/test-frames/engelmann_sensostar2c.xml | 18 +- 2 files changed, 253 insertions(+), 10 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 6ae54711..912a94be 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2484,7 +2484,250 @@ static const char * mbus_vib_unit_lookup_fb(mbus_value_information_block *vib) { static char buff[256]; - snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0xFB,0x%.2X", vib->vife[0]); + int n; + const char * prefix = ""; + switch (vib->vife[0] & MBUS_DIB_VIF_WITHOUT_EXTENSION) + { + case 0x0: + case 0x0 + 1: + // E000 000n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Energy (%sMWh)", prefix); + break; + case 0x2: + case 0x2 + 1: + // E000 001n + case 0x4: + case 0x4 + 1: + case 0x4 + 2: + case 0x4 + 3: + // E000 01nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x8: + case 0x8 + 1: + // E000 100n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Energy (%sGJ)", prefix); + break; + case 0xA: + case 0xA + 1: + case 0xC: + case 0xC + 1: + case 0xC + 2: + case 0xC + 3: + // E000 101n + // E000 11nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x10: + case 0x10 + 1: + // E001 000n + n = 0x01 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Volume (%sm3)", mbus_unit_prefix(n+2)); + break; + case 0x12: + case 0x12 + 1: + case 0x14: + case 0x14 + 1: + case 0x14 + 2: + case 0x14 + 3: + // E001 001n + // E001 01nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x18: + case 0x18 + 1: + // E001 100n + n = 0x01 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Mass (%st)", mbus_unit_prefix(n+2)); + break; + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + // E001 1010 to E010 0000, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x21: + // E010 0001 + snprintf(buff, sizeof(buff), "Volume (0.1 feet^3)"); + break; + case 0x22: + case 0x23: + // E010 0010 + // E010 0011 + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Volume (%samerican gallon)", prefix); + break; + + case 0x24: + // E010 0100 + snprintf(buff, sizeof(buff), "Volume flow (0.001 american gallon/min)"); + break; + case 0x25: + // E010 0101 + snprintf(buff, sizeof(buff), "Volume flow (american gallon/min)"); + break; + case 0x26: + // E010 0110 + snprintf(buff, sizeof(buff), "Volume flow (american gallon/h)"); + break; + case 0x27: + // E010 0111, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x28: + case 0x28 + 1: + // E010 100n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Power (%sMW)", prefix); + break; + case 0x2A: + case 0x2A + 1: + case 0x2C: + case 0x2C + 1: + case 0x2C + 2: + case 0x2C + 3: + // E010 101n, Reserved + // E010 11nn, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x30: + case 0x30 + 1: + // E011 000n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Power (%sGJ/h)", prefix); + break; + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + // E011 0010 to E101 0111 + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x58: + case 0x58 + 1: + case 0x58 + 2: + case 0x58 + 3: + // E101 10nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Flow Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x5C: + case 0x5C + 1: + case 0x5C + 2: + case 0x5C + 3: + // E101 11nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Return Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x60: + case 0x60 + 1: + case 0x60 + 2: + case 0x60 + 3: + // E110 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Temperature Difference (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x64: + case 0x64 + 1: + case 0x64 + 2: + case 0x64 + 3: + // E110 01nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "External Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + // E110 1nnn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x70: + case 0x70 + 1: + case 0x70 + 2: + case 0x70 + 3: + // E111 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Cold / Warm Temperature Limit (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x74: + case 0x74 + 1: + case 0x74 + 2: + case 0x74 + 3: + // E111 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Cold / Warm Temperature Limit (%s degree C)", mbus_unit_prefix(n -3)); + break; + case 0x78: + case 0x78 + 1: + case 0x78 + 2: + case 0x78 + 3: + case 0x78 + 4: + case 0x78 + 5: + case 0x78 + 6: + case 0x78 + 7: + // E111 1nnn + n = 0x07 & vib->vife[0]; + snprintf(buff, sizeof(buff), "cumul. count max power (%s W)", mbus_unit_prefix(n - 3)); + break; + default: + snprintf(buff, sizeof(buff), "Unrecognized VIF 0xFB extension: 0x%.2x", vib->vife[0]); + break; + } return buff; } diff --git a/test/test-frames/engelmann_sensostar2c.xml b/test/test-frames/engelmann_sensostar2c.xml index c8476339..b33e52e8 100644 --- a/test/test-frames/engelmann_sensostar2c.xml +++ b/test/test-frames/engelmann_sensostar2c.xml @@ -36,7 +36,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 8 @@ -45,7 +45,7 @@ 0 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -54,7 +54,7 @@ 0 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -131,7 +131,7 @@ Instantaneous value 1 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 8 @@ -140,7 +140,7 @@ 1 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -149,7 +149,7 @@ 1 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -176,7 +176,7 @@ 2 0 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 5 @@ -185,7 +185,7 @@ 2 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -194,7 +194,7 @@ 2 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 From 4c61098d5e050fe43d7ff174e7cbc06ee1ca5c33 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 11:44:17 +0200 Subject: [PATCH 189/238] Improve product strings for Aquametro and Sensus (cherry picked from commit 8d781ad2404b9bc7b239904fce0af49856fe0dc7) --- mbus/mbus-protocol.c | 28 +++++++++++++++-------- test/test-frames/example_data_01.norm.xml | 2 +- test/test-frames/example_data_01.xml | 2 +- test/test-frames/example_data_02.norm.xml | 2 +- test/test-frames/example_data_02.xml | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 912a94be..07b1a095 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -960,14 +960,21 @@ mbus_data_product_name(mbus_data_variable_header *header) } else if (manufacturer == mbus_manufacturer_id("AMT")) { - switch (header->version) + if (header->version >= 0xC0) { - case 0x80: - strcpy(buff,"Aquametro CALEC MB"); - break; - case 0xC0: - strcpy(buff,"Aquametro CALEC ST"); - break; + strcpy(buff,"Aquametro CALEC ST"); + } + else if (header->version >= 0x80) + { + strcpy(buff,"Aquametro CALEC MB"); + } + else if (header->version >= 0x40) + { + strcpy(buff,"Aquametro SAPHIR"); + } + else + { + strcpy(buff,"Aquametro AMTRON"); } } else if (manufacturer == mbus_manufacturer_id("BEC")) @@ -1271,15 +1278,16 @@ mbus_data_product_name(mbus_data_variable_header *header) { switch (header->version) { + case 0x08: + case 0x19: + strcpy(buff,"Sensus PolluCom E"); + break; case 0x0B: strcpy(buff,"Sensus PolluTherm"); break; case 0x0E: strcpy(buff,"Sensus PolluStat E"); break; - case 0x19: - strcpy(buff,"Sensus PolluCom E"); - break; } } else if (manufacturer == mbus_manufacturer_id("SON")) diff --git a/test/test-frames/example_data_01.norm.xml b/test/test-frames/example_data_01.norm.xml index 54ba0bb1..587ce57e 100644 --- a/test/test-frames/example_data_01.norm.xml +++ b/test/test-frames/example_data_01.norm.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 158 00 diff --git a/test/test-frames/example_data_01.xml b/test/test-frames/example_data_01.xml index dbfede82..a344e785 100644 --- a/test/test-frames/example_data_01.xml +++ b/test/test-frames/example_data_01.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 158 00 diff --git a/test/test-frames/example_data_02.norm.xml b/test/test-frames/example_data_02.norm.xml index d135aae2..87022161 100644 --- a/test/test-frames/example_data_02.norm.xml +++ b/test/test-frames/example_data_02.norm.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 161 00 diff --git a/test/test-frames/example_data_02.xml b/test/test-frames/example_data_02.xml index ad6236fc..fda38dfc 100644 --- a/test/test-frames/example_data_02.xml +++ b/test/test-frames/example_data_02.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 161 00 From 8a0fc2c612a00f7914d3619a01c3c3da02335428 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 11:47:54 +0200 Subject: [PATCH 190/238] Add more test frames Aquametro CALEC MB (Heat) Eastron SDM630 (Electricity) Sensus PolluCom E (Heat) Tecson (Oil) (cherry picked from commit fe2b4ec024047fb8cca9dc43c02f83a47fba115f) --- test/test-frames/amt_calec_mb.hex | 1 + test/test-frames/amt_calec_mb.norm.xml | 71 ++++++++ test/test-frames/amt_calec_mb.xml | 64 ++++++++ test/test-frames/eastron_sdm630.hex | 1 + test/test-frames/eastron_sdm630.norm.xml | 199 +++++++++++++++++++++++ test/test-frames/eastron_sdm630.xml | 176 ++++++++++++++++++++ test/test-frames/sen_pollucom_e.hex | 1 + test/test-frames/sen_pollucom_e.norm.xml | 95 +++++++++++ test/test-frames/sen_pollucom_e.xml | 83 ++++++++++ test/test-frames/tecson.hex | 1 + test/test-frames/tecson.norm.xml | 41 +++++ test/test-frames/tecson.xml | 38 +++++ 12 files changed, 771 insertions(+) create mode 100644 test/test-frames/amt_calec_mb.hex create mode 100644 test/test-frames/amt_calec_mb.norm.xml create mode 100644 test/test-frames/amt_calec_mb.xml create mode 100644 test/test-frames/eastron_sdm630.hex create mode 100644 test/test-frames/eastron_sdm630.norm.xml create mode 100644 test/test-frames/eastron_sdm630.xml create mode 100644 test/test-frames/sen_pollucom_e.hex create mode 100644 test/test-frames/sen_pollucom_e.norm.xml create mode 100644 test/test-frames/sen_pollucom_e.xml create mode 100644 test/test-frames/tecson.hex create mode 100644 test/test-frames/tecson.norm.xml create mode 100644 test/test-frames/tecson.xml diff --git a/test/test-frames/amt_calec_mb.hex b/test/test-frames/amt_calec_mb.hex new file mode 100644 index 00000000..942b40d0 --- /dev/null +++ b/test/test-frames/amt_calec_mb.hex @@ -0,0 +1 @@ +68 38 38 68 08 C8 72 09 31 54 03 B4 05 B0 04 C9 10 FF FF 03 22 9A 00 00 05 2E A0 C8 51 46 05 3E B4 E3 D7 42 05 5B 90 D3 07 43 05 5F 0E AA E7 41 05 63 9C BC D5 42 04 6D 10 09 05 C5 77 16 diff --git a/test/test-frames/amt_calec_mb.norm.xml b/test/test-frames/amt_calec_mb.norm.xml new file mode 100644 index 00000000..4eef3de4 --- /dev/null +++ b/test/test-frames/amt_calec_mb.norm.xml @@ -0,0 +1,71 @@ + + + + + 3543109 + AMT + 176 + Aquametro CALEC MB + Heat: Outlet + 201 + 10 + FFFF + + + + Instantaneous value + 0 + s + On time + 554400.000000 + + + + Instantaneous value + 0 + W + Power + 13426156.250000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 107.944733 + + + + Instantaneous value + 0 + °C + Flow temperature + 135.826416 + + + + Instantaneous value + 0 + °C + Return temperature + 28.958035 + + + + Instantaneous value + 0 + K + Temperature difference + 106.868378 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2096-05-05T09:16:00Z + + + diff --git a/test/test-frames/amt_calec_mb.xml b/test/test-frames/amt_calec_mb.xml new file mode 100644 index 00000000..6e4ab730 --- /dev/null +++ b/test/test-frames/amt_calec_mb.xml @@ -0,0 +1,64 @@ + + + + + 3543109 + AMT + 176 + Aquametro CALEC MB + Heat: Outlet + 201 + 10 + FFFF + + + + Instantaneous value + 0 + On time (hours) + 154 + + + + Instantaneous value + 0 + Power (kW) + 13426.156250 + + + + Instantaneous value + 0 + Volume flow ( m^3/h) + 107.944733 + + + + Instantaneous value + 0 + Flow temperature (deg C) + 135.826416 + + + + Instantaneous value + 0 + Return temperature (deg C) + 28.958035 + + + + Instantaneous value + 0 + Temperature Difference ( deg C) + 106.868378 + + + + Instantaneous value + 0 + Time Point (time & date) + 2096-05-05T09:16:00 + + + diff --git a/test/test-frames/eastron_sdm630.hex b/test/test-frames/eastron_sdm630.hex new file mode 100644 index 00000000..5666f2e1 --- /dev/null +++ b/test/test-frames/eastron_sdm630.hex @@ -0,0 +1 @@ +68 90 90 68 08 0A 72 78 65 34 21 24 40 01 02 55 00 00 00 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0A FD 3A 00 05 0A FD 3A 05 00 0A FD 3A 05 00 0A FD 3A 05 00 0A FD 3A 50 00 4D 16 diff --git a/test/test-frames/eastron_sdm630.norm.xml b/test/test-frames/eastron_sdm630.norm.xml new file mode 100644 index 00000000..f3fbbeb1 --- /dev/null +++ b/test/test-frames/eastron_sdm630.norm.xml @@ -0,0 +1,199 @@ + + + + + 21346578 + PAD + 1 + + Electricity + 85 + 00 + 0000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 500.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 50.000000 + + + diff --git a/test/test-frames/eastron_sdm630.xml b/test/test-frames/eastron_sdm630.xml new file mode 100644 index 00000000..2de43526 --- /dev/null +++ b/test/test-frames/eastron_sdm630.xml @@ -0,0 +1,176 @@ + + + + + 21346578 + PAD + 1 + + Electricity + 85 + 00 + 0000 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 500 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 50 + + + diff --git a/test/test-frames/sen_pollucom_e.hex b/test/test-frames/sen_pollucom_e.hex new file mode 100644 index 00000000..76f0a877 --- /dev/null +++ b/test/test-frames/sen_pollucom_e.hex @@ -0,0 +1 @@ +68 42 42 68 08 00 72 45 00 94 63 AE 4C 08 04 F9 00 00 00 0C 06 19 90 01 00 0C 13 19 11 62 01 0C 3B 00 00 00 00 0C 2B 00 00 00 00 02 5A 67 01 02 5E E9 00 03 60 46 31 00 0C 78 45 00 94 63 0C FD 10 45 00 94 63 1F B6 16 diff --git a/test/test-frames/sen_pollucom_e.norm.xml b/test/test-frames/sen_pollucom_e.norm.xml new file mode 100644 index 00000000..1c79a730 --- /dev/null +++ b/test/test-frames/sen_pollucom_e.norm.xml @@ -0,0 +1,95 @@ + + + + + 63940045 + SEN + 8 + Sensus PolluCom E + Heat: Outlet + 249 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 19019000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 1621.119000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 35.900000 + + + + Instantaneous value + 0 + °C + Return temperature + 23.300000 + + + + Instantaneous value + 0 + K + Temperature difference + 12.614000 + + + + Instantaneous value + 0 + + Fabrication No + 63940045.000000 + + + + Instantaneous value + 0 + + Customer location + 63940045.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/sen_pollucom_e.xml b/test/test-frames/sen_pollucom_e.xml new file mode 100644 index 00000000..1c3653bb --- /dev/null +++ b/test/test-frames/sen_pollucom_e.xml @@ -0,0 +1,83 @@ + + + + + 63940045 + SEN + 8 + Sensus PolluCom E + Heat: Outlet + 249 + 00 + 0000 + + + + Instantaneous value + 0 + Energy (kWh) + 19019 + + + + Instantaneous value + 0 + Volume (m m^3) + 1621119 + + + + Instantaneous value + 0 + Volume flow (m m^3/h) + 0 + + + + Instantaneous value + 0 + Power (W) + 0 + + + + Instantaneous value + 0 + Flow temperature (1e-1 deg C) + 359 + + + + Instantaneous value + 0 + Return temperature (1e-1 deg C) + 233 + + + + Instantaneous value + 0 + Temperature Difference (m deg C) + 12614 + + + + Instantaneous value + 0 + Fabrication number + 63940045 + + + + Instantaneous value + 0 + Customer location + 63940045 + + + + More records follow + + + + diff --git a/test/test-frames/tecson.hex b/test/test-frames/tecson.hex new file mode 100644 index 00000000..2f082269 --- /dev/null +++ b/test/test-frames/tecson.hex @@ -0,0 +1 @@ +68 1B 1B 68 08 00 72 12 34 56 78 A3 50 10 01 01 00 00 00 01 67 09 0A 14 60 45 92 10 14 88 13 18 16 diff --git a/test/test-frames/tecson.norm.xml b/test/test-frames/tecson.norm.xml new file mode 100644 index 00000000..3d04e662 --- /dev/null +++ b/test/test-frames/tecson.norm.xml @@ -0,0 +1,41 @@ + + + + + 78563412 + TEC + 16 + + Oil + 1 + 00 + 0000 + + + + Instantaneous value + 0 + °C + External temperature + 9.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 45.600000 + + + + Maximum value + 0 + 1 + 0 + m^3 + Volume + 50.000000 + + + diff --git a/test/test-frames/tecson.xml b/test/test-frames/tecson.xml new file mode 100644 index 00000000..201cdfd4 --- /dev/null +++ b/test/test-frames/tecson.xml @@ -0,0 +1,38 @@ + + + + + 78563412 + TEC + 16 + + Oil + 1 + 00 + 0000 + + + + Instantaneous value + 0 + External temperature ( deg C) + 9 + + + + Instantaneous value + 0 + Volume (1e-2 m^3) + 4560 + + + + Maximum value + 0 + 1 + 0 + Volume (1e-2 m^3) + 5000 + + + From 42a8b9aaeaa422c24ea9d16859d304c2739a36c8 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 12:30:22 +0200 Subject: [PATCH 191/238] Remove duplicate rvd235.hex is the same as siemens_rvd235.hex (cherry picked from commit ec4bff91dba7df19cdf8d5ed9eb10b49771e3a60) --- test/unsupported-frames/rvd235.hex | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/unsupported-frames/rvd235.hex diff --git a/test/unsupported-frames/rvd235.hex b/test/unsupported-frames/rvd235.hex deleted file mode 100644 index 113ab5f4..00000000 --- a/test/unsupported-frames/rvd235.hex +++ /dev/null @@ -1 +0,0 @@ -68 96 96 68 08 00 72 04 11 29 00 7A 32 29 20 0C 28 00 00 0C 78 20 71 04 00 06 FD 0C FC 03 6D 00 2D 00 0D FD 0B 06 35 33 32 44 56 52 81 30 FD 7C 01 81 20 FD 7C 00 01 FD 7C 00 0F 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 24 16 From a2eea19dd8729e11391d9b8d88f6b68f5acdfad1 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 12:34:38 +0200 Subject: [PATCH 192/238] Move RVD235 out of unsupported Especially after the recent changes, we can consider Siemens RVD235 as supported. (cherry picked from commit 446cf41a2a17a4cd9bb059329c4120c1fc8f3d3f) --- .../siemens_rvd235.hex | 0 test/test-frames/siemens_rvd235.norm.xml | 75 +++++++++++++++++++ test/test-frames/siemens_rvd235.xml | 66 ++++++++++++++++ 3 files changed, 141 insertions(+) rename test/{unsupported-frames => test-frames}/siemens_rvd235.hex (100%) create mode 100644 test/test-frames/siemens_rvd235.norm.xml create mode 100644 test/test-frames/siemens_rvd235.xml diff --git a/test/unsupported-frames/siemens_rvd235.hex b/test/test-frames/siemens_rvd235.hex similarity index 100% rename from test/unsupported-frames/siemens_rvd235.hex rename to test/test-frames/siemens_rvd235.hex diff --git a/test/test-frames/siemens_rvd235.norm.xml b/test/test-frames/siemens_rvd235.norm.xml new file mode 100644 index 00000000..c9105b8d --- /dev/null +++ b/test/test-frames/siemens_rvd235.norm.xml @@ -0,0 +1,75 @@ + + + + + 291104 + LSZ + 41 + + Breaker: Electricity + 12 + 28 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 47120.000000 + + + + Instantaneous value + 0 + + Model / Version + 193280672764.000000 + + + + Instantaneous value + 0 + + Parameter set identification + RVD235 + + + + Instantaneous value + 0 + 3 + 0 + Reserved + Reserved + 1.000000 + + + + Instantaneous value + 0 + 2 + 0 + Reserved + Reserved + 0.000000 + + + + Instantaneous value + 0 + Reserved + Reserved + 0.000000 + + + + Manufacturer specific + 0 + + + 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 + + + diff --git a/test/test-frames/siemens_rvd235.xml b/test/test-frames/siemens_rvd235.xml new file mode 100644 index 00000000..3b570d37 --- /dev/null +++ b/test/test-frames/siemens_rvd235.xml @@ -0,0 +1,66 @@ + + + + + 291104 + LSZ + 41 + + Breaker: Electricity + 12 + 28 + 0000 + + + + Instantaneous value + 0 + Fabrication number + 47120 + + + + Instantaneous value + 0 + Model / Version + 193280672764 + + + + Instantaneous value + 0 + Parameter set identification + RVD235 + + + + Instantaneous value + 0 + 3 + 0 + Reserved VIF extension + 1 + + + + Instantaneous value + 0 + 2 + 0 + Reserved VIF extension + 0 + + + + Instantaneous value + 0 + Reserved VIF extension + 0 + + + + Manufacturer specific + 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 + + + From acbc207df8690e4c869c39886bcf45ff098762cb Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Tue, 7 Jul 2020 15:40:23 +0200 Subject: [PATCH 193/238] Move invalid_length*.hex to test/unsupported-frames (#165) (cherry picked from commit 2d09cfc41dd47aef1fa113d22743190bc692e713) --- test/{test-frames => unsupported-frames}/invalid_length.hex | 0 test/{test-frames => unsupported-frames}/invalid_length2.hex | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test-frames => unsupported-frames}/invalid_length.hex (100%) rename test/{test-frames => unsupported-frames}/invalid_length2.hex (100%) diff --git a/test/test-frames/invalid_length.hex b/test/unsupported-frames/invalid_length.hex similarity index 100% rename from test/test-frames/invalid_length.hex rename to test/unsupported-frames/invalid_length.hex diff --git a/test/test-frames/invalid_length2.hex b/test/unsupported-frames/invalid_length2.hex similarity index 100% rename from test/test-frames/invalid_length2.hex rename to test/unsupported-frames/invalid_length2.hex From ac290352d3153ba024920f9a650800a2da58cac5 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 12:36:45 +0200 Subject: [PATCH 194/238] Enforce tests execute ok (#165) (cherry picked from commit 69019312c9f38f5670a03d1753c42bf35a10e98b) --- .github/workflows/ccpp.yml | 6 +++++- .travis.yml | 2 ++ test/generate-xml.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 1478bc32..53147de9 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -12,7 +12,11 @@ jobs: run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. - name: generate test frames - run: ./test/generate-xml.sh test/test-frames + run: | + ./test/generate-xml.sh test/test-frames + echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" + ./test/generate-xml.sh test/error-frames || true + ./test/generate-xml.sh test/unsupported-frames || true - name: install and run gcovr run: sudo pip install gcovr && gcovr build/. diff --git a/.travis.yml b/.travis.yml index 6da105e2..c0c475fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,5 @@ os: script: - ./build.sh - ./test/generate-xml.sh test/test-frames + - ./test/generate-xml.sh test/error-frames || true + - ./test/generate-xml.sh test/unsupported-frames || true diff --git a/test/generate-xml.sh b/test/generate-xml.sh index b9662d93..b504fad0 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -12,6 +12,12 @@ # #------------------------------------------------------------------------------ +NUMBER_OF_PARSING_ERRORS=0 +FAILING_TESTS=failing_tests.txt +NEW_TESTS=new_tests.txt +touch $FAILING_TESTS +touch $NEW_TESTS + # Check commandline parameter if [ $# -ne 1 ]; then echo "usage: $0 path_to_directory_with_xml_files" @@ -64,6 +70,7 @@ generate_xml() { # Check parsing result if [ $result -ne 0 ]; then + NUMBER_OF_PARSING_ERRORS=$((NUMBER_OF_PARSING_ERRORS + 1)) echo "Unable to generate XML for $hexfile" rm "$directory/$filename$mode.xml.new" return 1 @@ -81,14 +88,17 @@ generate_xml() { ;; 1) # different -> print diff + echo "== $directory/$filename$mode failed" cat "$directory/$filename$mode.dif" && rm "$directory/$filename$mode.dif" echo "" + echo "$filename$mode" >> $FAILING_TESTS ;; *) # no old -> rename XML echo "Create $filename$mode.xml" mv "$directory/$filename$mode.xml.new" "$directory/$filename$mode.xml" rm "$directory/$filename$mode.dif" + echo "$filename$mode" >> $NEW_TESTS ;; esac @@ -105,3 +115,27 @@ for hexfile in "$directory"/*.hex; do generate_xml "$directory" "$hexfile" "normalized" done +# Check the size of the file $FAILING_TESTS. Make sure to indicate failure. +if [ -s $FAILING_TESTS ]; then + echo "** There were errors in the following file(s):" + cat $FAILING_TESTS + exit 1 +else + rm $FAILING_TESTS +fi +if [ -s $NEW_TESTS ]; then + echo "** There were new test in the following file(s):" + cat $NEW_TESTS +else + rm $NEW_TESTS +fi + +# Check that there was no files that failed to parse +if [ $NUMBER_OF_PARSING_ERRORS -ne 0 ]; then + echo "** There were $NUMBER_OF_PARSING_ERRORS files that did not parse, expected 0 files." + echo + exit $NUMBER_OF_PARSING_ERRORS +fi +DIRECTORY_BASENAME="$(basename "$directory")" +echo "** Tests executed successfully in \"$DIRECTORY_BASENAME\"." +echo From cd57e31c8e6bad3883bf81e4cd4c09d4c7a72131 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 12:53:50 +0200 Subject: [PATCH 195/238] Fix bug, test script should accept both 1 and 2 arguments (#165) Usefull when placing the output in another directory. (cherry picked from commit e89f929f6c7d97d084ec1fc7e37137d5d730bb03) --- test/generate-xml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index b504fad0..f6c79ff7 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -19,7 +19,7 @@ touch $FAILING_TESTS touch $NEW_TESTS # Check commandline parameter -if [ $# -ne 1 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then echo "usage: $0 path_to_directory_with_xml_files" echo "or" echo "usage: $0 path_to_directory_with_xml_files path_to_mbus_parse_hex_with_filename" From 111da47b51de13060dcd3301ae33a88ee41752f7 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 13:05:31 +0200 Subject: [PATCH 196/238] Rewrite ccpp.yml to use multi-line command (#165) For enhanced readability, split the commands over several lines. (cherry picked from commit 3897ac72da994f2819a97a6fac37f2bbce75405e) --- .github/workflows/ccpp.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 53147de9..df0398ab 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -9,7 +9,12 @@ jobs: steps: - uses: actions/checkout@v2 - name: build examples and tests - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. + run: | + rm -rf build || true + mkdir -p build + cd build + cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j + cd .. - name: generate test frames run: | @@ -27,7 +32,14 @@ jobs: steps: - uses: actions/checkout@v2 - name: build debian package - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_PACKAGE_DEB=ON && cpack .. && sudo dpkg -i *.deb && ls /usr/lib + run: | + rm -rf build || true + mkdir -p build + cd build + cmake .. -DLIBMBUS_PACKAGE_DEB=ON + cpack .. + sudo dpkg -i *.deb + ls /usr/lib doc: runs-on: ubuntu-latest @@ -38,5 +50,9 @@ jobs: run: sudo apt install -y doxygen - name: build doxygen documentation - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_DOCS=ON && cmake --build . --target doc - + run: | + rm -rf build || true + mkdir build + cd build + cmake .. -DLIBMBUS_BUILD_DOCS=ON + cmake --build . --target doc From a55523afe8f85d83334b35c4426833549fc6992b Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Thu, 4 Jun 2020 16:11:52 +0200 Subject: [PATCH 197/238] Add Dockerfile.test to run tests from docker (#165) (cherry picked from commit f498cf1a37ad738a7078e5bbbc4801cc9f011fb7) --- Dockerfile.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile.test diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 00000000..52ee1792 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,18 @@ +# docker build . -f Dockerfile.test -t test_builder + +FROM ubuntu + +RUN apt update -y && apt install -y cmake gcc g++ make +COPY . /tmp +RUN cd /tmp && \ + mkdir build && \ + cd build && \ + cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && \ + cmake --build . -j && \ + cd .. && \ + ./test/generate-xml.sh test/test-frames + +RUN cd /tmp && \ + echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" && \ + ./test/generate-xml.sh test/error-frames || true ; \ + ./test/generate-xml.sh test/unsupported-frames || true From 95f543cc5f1c86967cab1515cc2da38c1de56e00 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 19 Jul 2020 12:53:59 +0200 Subject: [PATCH 198/238] build: temporary revert to autotools (#174) As long as cmake doesn't generate suitable deb packages, we need to switch back :( (cherry picked from commit 107d44b7e9a12df61365fe86a978788e753819f9) --- .github/workflows/ccpp.yml | 58 -------- CMakeLists.txt | 296 ------------------------------------- Dockerfile.deb | 14 -- Dockerfile.rpm | 14 -- Dockerfile.test | 18 --- Makefile-static | 25 ++++ Makefile.am | 20 +++ README.md | 32 +--- bin/CMakeLists.txt | 19 --- bin/Makefile-static | 24 +++ bin/Makefile.am | 102 +++++++++++++ build-deb.sh | 25 ++++ build.sh | 37 +++-- cmake-format.yaml | 15 -- cmake/Config.cmake.in | 4 - configure.ac | 44 ++++++ Doxyfile.in => doxygen.cfg | 9 +- libmbus.pc.in | 12 +- libmbus.spec | 87 +++++++++++ mbus/Makefile.am | 20 +++ mbus/config.h.in | 56 ------- test/CMakeLists.txt | 5 - test/Makefile.am | 25 ++++ 23 files changed, 399 insertions(+), 562 deletions(-) delete mode 100644 .github/workflows/ccpp.yml delete mode 100644 CMakeLists.txt delete mode 100644 Dockerfile.deb delete mode 100644 Dockerfile.rpm delete mode 100644 Dockerfile.test create mode 100644 Makefile-static create mode 100644 Makefile.am delete mode 100644 bin/CMakeLists.txt create mode 100644 bin/Makefile-static create mode 100644 bin/Makefile.am create mode 100755 build-deb.sh delete mode 100644 cmake-format.yaml delete mode 100644 cmake/Config.cmake.in create mode 100644 configure.ac rename Doxyfile.in => doxygen.cfg (99%) create mode 100644 libmbus.spec create mode 100644 mbus/Makefile.am delete mode 100644 mbus/config.h.in delete mode 100644 test/CMakeLists.txt create mode 100644 test/Makefile.am diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml deleted file mode 100644 index df0398ab..00000000 --- a/.github/workflows/ccpp.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: CMake - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build examples and tests - run: | - rm -rf build || true - mkdir -p build - cd build - cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j - cd .. - - - name: generate test frames - run: | - ./test/generate-xml.sh test/test-frames - echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" - ./test/generate-xml.sh test/error-frames || true - ./test/generate-xml.sh test/unsupported-frames || true - - - name: install and run gcovr - run: sudo pip install gcovr && gcovr build/. - - debian: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build debian package - run: | - rm -rf build || true - mkdir -p build - cd build - cmake .. -DLIBMBUS_PACKAGE_DEB=ON - cpack .. - sudo dpkg -i *.deb - ls /usr/lib - - doc: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build doxygen documentation - run: sudo apt install -y doxygen - - - name: build doxygen documentation - run: | - rm -rf build || true - mkdir build - cd build - cmake .. -DLIBMBUS_BUILD_DOCS=ON - cmake --build . --target doc diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c47a94c3..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,296 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project( - libmbus - LANGUAGES CXX C - VERSION "0.9.0") - -if(CMAKE_BUILD_TYPE STREQUAL "") - message(STATUS "CMAKE_BUILD_TYPE empty setting to Debug") - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# ############################################################################## -# default options -> changed with e.g. cd build && cmake .. -# -DLIBMBUS_BUILD_TESTS=ON -# ############################################################################## - -option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) -option(LIBMBUS_BUILD_TESTS "build tests" OFF) -option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" OFF) -option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) -option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) -option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) -option(LIBMBUS_BUILD_DOCS "build documentation" OFF) -option(BUILD_SHARED_LIBS "build shared lib" ON) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 11) - -# Append our module directory to CMake -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_BINARY_DIR}") - -# Set the output of the libraries and executables. -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - -# ############################################################################## -# static analysis -# ############################################################################## - -if(LIBMBUS_RUN_CLANG_TIDY) - find_program( - CLANG_TIDY_EXE - NAMES "clang-tidy" - DOC "/usr/bin/clang-tidy") - if(NOT CLANG_TIDY_EXE) - message(WARNING "clang-tidy not found.") - else() - message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") - endif() -endif(LIBMBUS_RUN_CLANG_TIDY) - -if(LIBMBUS_ENABLE_COVERAGE) - if(NOT CMAKE_BUILD_TYPE MATCHES "(Debug)|(RelWithDebInfo)") - message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") - endif() - - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # using Clang - message(STATUS "Not doing coverage...") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # using GCC - message(STATUS "Building with code coverage...") - set(CMAKE_BUILD_TYPE DEBUG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage ") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") - link_libraries(-lgcov) - endif() -endif() - -include(CheckIncludeFile) - -check_include_file(dlfcn.h HAVE_DLFCN_H) -check_include_file(inttypes.h HAVE_INTTYPES_H) -check_include_file(memory.h HAVE_MEMORY_H) -check_include_file(stdlib.h HAVE_STDINT_H) -check_include_file(stdint.h HAVE_STDLIB_H) -check_include_file(strings.h HAVE_STRINGS_H) -check_include_file(string.h HAVE_STRING_H) -check_include_file(sys/stat.h HAVE_SYS_STAT_H) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(unistd.h HAVE_UNISTD_H) - -# ############################################################################## -# library -# ############################################################################## - -set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - -set(PACKAGE_VERSION "${PROJECT_VERSION}") -set(VERSION "${PROJECT_VERSION}") -configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_DIR}/config.h @ONLY) - -add_library( - ${PROJECT_NAME} - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h") -target_include_directories( - ${PROJECT_NAME} - PUBLIC "$" "$" - "$") -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") - target_link_libraries(${PROJECT_NAME} PRIVATE m) -endif() -if(NOT MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) -endif() - -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") - -if(CLANG_TIDY_EXE) - set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") -endif() - -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - -# ############################################################################## -# examples -# ############################################################################## - -if(LIBMBUS_BUILD_EXAMPLES) - message(STATUS "building examples") - add_subdirectory(bin) -endif() - -# ############################################################################## -# tests -# ############################################################################## - -if(LIBMBUS_BUILD_TESTS) - message(STATUS "building tests") - enable_testing() - add_subdirectory(test) -endif() - -# ############################################################################## -# install -# ############################################################################## - -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) - -set(INSTALL_PKGCONFIG_DIR - "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" - CACHE PATH "Installation directory for pkgconfig (.pc) files") -set(INSTALL_INC_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/mbus" - CACHE PATH "Installation directory for headers") -set(INSTALL_LIB_DIR - "${CMAKE_INSTALL_LIBDIR}" - CACHE PATH "Installation directory for libraries") - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmbus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc @ONLY) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc - DESTINATION "${INSTALL_PKGCONFIG_DIR}" - COMPONENT dev) - -set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) -install( - TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT dev - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lib) -install( - EXPORT ${PROJECT_NAME}Targets - DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" - NAMESPACE ${PROJECT_NAME}:: - COMPONENT dev) - -configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION - "${LIBMBUS_CONFIG_INSTALL_DIR}") -write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY SameMajorVersion) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" - COMPONENT dev) - -install( - DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/mbus/" - DESTINATION "${INSTALL_INC_DIR}" - COMPONENT dev - FILES_MATCHING - PATTERN "*.h") - -# ############################################################################## -# package -# mkdir build ; cd build ; cmake .. -DLIBMBUS_PACKAGE_DEB=ON ; cpack .. -# ############################################################################## - -include(InstallRequiredSystemLibraries) - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open source M-bus (Meter-Bus) library.") -set(CPACK_PACKAGE_DESCRIPTION - "libmbus is an open source library for the M-bus (Meter-Bus) protocol. -The Meter-Bus is a standard for reading out meter data from electricity meters, -heat meters, gas meters, etc. The M-bus standard deals with both the electrical -signals on the M-Bus, and the protocol and data format used in transmissions -on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle -the communication with M-Bus devices. - -For more information see http://www.rscada.se/libmbus") - -set(CPACK_PACKAGE_VENDOR "Raditex Control AB") -set(CPACK_PACKAGE_CONTACT "Stefan Wahren ") -set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/rscada/libmbus/") -set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) -set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") -set(CPACK_DEB_COMPONENT_INSTALL ON) -set(CPACK_DEBIAN_PACKAGE_DEBUG ON) -set(CPACK_PACKAGE_RELEASE 1) - -# create 2 components, libmbus, libmbus-dev -set(CPACK_COMPONENTS_ALL lib dev) -set(CPACK_COMPONENT_LIB_DESCRIPTION "FreeSCADA M-Bus Library. - A free and open-source library for M-Bus (Meter Bus) from the rSCADA project.") -set(CPACK_DEBIAN_LIB_PACKAGE_SECTION libs) - -set(CPACK_COMPONENT_DEVEL_DESCRIPTION - "FreeSCADA M-Bus Library Development files. -A free and open-source library for M-Bus (Meter Bus) from the rSCADA project, -including development files.") -set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION libdevel) - -set(CPACK_COMPONENT_DEVEL_DEPENDS lib) - -set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -set(CPACK_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") - -if(LIBMBUS_PACKAGE_DEB) - set(CPACK_GENERATOR "DEB") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Stefan Wahren ") - set(CPACK_DEBIAN_PACKAGE_SECTION "Development/Languages/C and C++") - set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) - set(CPACK_DEBIAN_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}" - ) -endif() - -if(LIBMBUS_PACKAGE_RPM) - set(CPACK_GENERATOR "RPM") - set(CPACK_RPM_PACKAGE_LICENSE "BSD") -endif() - -include(CPack) - -# ############################################################################## -# doc -# mkdir build ; cd build ; cmake .. -DLIBMBUS_BUILD_DOCS=ON ; cmake --build . --target doc -# ############################################################################## - -if(LIBMBUS_BUILD_DOCS) - message(STATUS "building with documentation") - # Generate targets for documentation - # check if Doxygen is installed - find_package(Doxygen) - - if(Doxygen_FOUND) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - - # note the option ALL which allows to build the docs together with the application - add_custom_target( - doc ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM) - - message(STATUS "Setup up the Doxygen documention build") - - else(Doxygen_FOUND) - message(WARNING "Doxygen need to be installed to generate the doxygen documentation") - endif(Doxygen_FOUND) -endif() diff --git a/Dockerfile.deb b/Dockerfile.deb deleted file mode 100644 index 1db6923d..00000000 --- a/Dockerfile.deb +++ /dev/null @@ -1,14 +0,0 @@ -# docker build . -f Dockerfile.deb -t deb_builder - -FROM ubuntu - -RUN apt update -y && apt install -y cmake gcc g++ make -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_PACKAGE_DEB=ON && \ - cpack .. && \ - ls -al && \ - dpkg -i *.deb - diff --git a/Dockerfile.rpm b/Dockerfile.rpm deleted file mode 100644 index 2f70df96..00000000 --- a/Dockerfile.rpm +++ /dev/null @@ -1,14 +0,0 @@ -# docker build . -f Dockerfile.rpm -t rpm_builder - -FROM fedora - -RUN dnf install -y cmake gcc g++ make rpm-build -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_PACKAGE_RPM=ON && \ - cpack .. && \ - ls -al && \ - rpm -i *.rpm - diff --git a/Dockerfile.test b/Dockerfile.test deleted file mode 100644 index 52ee1792..00000000 --- a/Dockerfile.test +++ /dev/null @@ -1,18 +0,0 @@ -# docker build . -f Dockerfile.test -t test_builder - -FROM ubuntu - -RUN apt update -y && apt install -y cmake gcc g++ make -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && \ - cmake --build . -j && \ - cd .. && \ - ./test/generate-xml.sh test/test-frames - -RUN cd /tmp && \ - echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" && \ - ./test/generate-xml.sh test/error-frames || true ; \ - ./test/generate-xml.sh test/unsupported-frames || true diff --git a/Makefile-static b/Makefile-static new file mode 100644 index 00000000..93da7516 --- /dev/null +++ b/Makefile-static @@ -0,0 +1,25 @@ +# Copyright (c) 2010 +# Robert Johansson +# Raditex AB. +# All rights reserved. + +LIB = libmbus.so + +CFLAGS = -Wall -W -g -fPIC -I. +HEADERS = mbus.h mbus-protocol.h +OBJS = mbus.o mbus-protocol.o + +$(LIB): $(OBJS) + gcc -shared -o $(LIB) $(OBJS) + +all: $(LIB) + +clean: + rm -rf *.o *core core $(LIB) + +test: + (cd test && make) + +install: all + cp $(LIB) /usr/local/freescada/lib + cp $(HEADERS) /usr/local/freescada/include diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..fd519e14 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,20 @@ +# +# +# +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libmbus.pc + + +docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION) +dist_docdir = $(DESTDIR)$(docdir) +doc_DATA = README.md \ + COPYING \ + hardware/MBus_USB.pdf \ + hardware/MBus_USB.txt + +SUBDIRS = mbus bin +ACLOCAL = aclocal -I . +ACLOCAL_AMFLAGS = -Werror -I m4 diff --git a/README.md b/README.md index 133c243d..27d393c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) - -![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) +# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) ![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) libmbus is an open source library for the M-bus (Meter-Bus) protocol. @@ -10,32 +8,4 @@ signals on the M-Bus, and the protocol and data format used in transmissions on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle the communication with M-Bus devices. - -## BUILD - -with cmake - -```bash -rm -rf _build -mkdir _build -cd _build -# configure -# e.g. on linux -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -# e.g. for a target device -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/foo-bar-baz.cmake -# compile -cmake --build . -j -# install - optional -cmake --build . --target install -``` - -## CONSUME - -```cmake -find_package(libmbus) -add_executable(my_app main.cpp) -target_link_libraries(my_app libmbus::libmbus) -``` - For more information see http://www.rscada.se/libmbus diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt deleted file mode 100644 index 73e15002..00000000 --- a/bin/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -function(add_example SRCS) - add_executable(${SRCS} ${CMAKE_CURRENT_LIST_DIR}/${SRCS}.c) - target_link_libraries(${SRCS} PRIVATE libmbus::libmbus) -endfunction() - -add_example(mbus-serial-request-data) -add_example(mbus-serial-request-data-multi-reply) -add_example(mbus-serial-scan) -add_example(mbus-serial-scan-secondary) -add_example(mbus-serial-select-secondary) -add_example(mbus-serial-set-address) -add_example(mbus-serial-switch-baudrate) -add_example(mbus-tcp-application-reset) -add_example(mbus-tcp-raw-send) -add_example(mbus-tcp-request-data) -add_example(mbus-tcp-request-data-multi-reply) -add_example(mbus-tcp-scan) -add_example(mbus-tcp-scan-secondary) -add_example(mbus-tcp-select-secondary) diff --git a/bin/Makefile-static b/bin/Makefile-static new file mode 100644 index 00000000..2b04b493 --- /dev/null +++ b/bin/Makefile-static @@ -0,0 +1,24 @@ +# +# Copyright (C) 2011, Robert Johansson, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +CFLAGS=-Wall -g -I.. +LDFLAGS=-L.. -lm -lmbus + +all: mbus-tcp-scan mbus-tcp-request-data + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +mbus-tcp-scan: mbus-tcp-scan.o mbus-tcp.o + gcc -o $@ $^ $(LDFLAGS) + +mbus-tcp-request-data: mbus-tcp-request-data.o mbus-tcp.o + gcc -o $@ $^ $(LDFLAGS) + +clean: + rm -rf mbus-tcp-request-data mbus-tcp-scan *.o *~ diff --git a/bin/Makefile.am b/bin/Makefile.am new file mode 100644 index 00000000..7c9ce412 --- /dev/null +++ b/bin/Makefile.am @@ -0,0 +1,102 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src + +noinst_HEADERS = +bin_PROGRAMS = mbus-tcp-scan mbus-tcp-request-data mbus-tcp-request-data-multi-reply \ + mbus-tcp-select-secondary mbus-tcp-scan-secondary \ + mbus-serial-scan mbus-serial-request-data mbus-serial-request-data-multi-reply \ + mbus-serial-select-secondary mbus-serial-scan-secondary \ + mbus-serial-switch-baudrate mbus-tcp-raw-send mbus-tcp-application-reset \ + mbus-serial-set-address + +# tcp +mbus_tcp_scan_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_scan_LDADD = -lmbus -lm +mbus_tcp_scan_SOURCES = mbus-tcp-scan.c + +mbus_tcp_request_data_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_request_data_LDADD = -lmbus -lm +mbus_tcp_request_data_SOURCES = mbus-tcp-request-data.c + +mbus_tcp_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_request_data_multi_reply_LDADD = -lmbus -lm +mbus_tcp_request_data_multi_reply_SOURCES = mbus-tcp-request-data-multi-reply.c + +mbus_tcp_select_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_select_secondary_LDADD = -lmbus -lm +mbus_tcp_select_secondary_SOURCES = mbus-tcp-select-secondary.c + +mbus_tcp_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_scan_secondary_LDADD = -lmbus -lm +mbus_tcp_scan_secondary_SOURCES = mbus-tcp-scan-secondary.c + +mbus_tcp_raw_send_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_raw_send_LDADD = -lmbus -lm +mbus_tcp_raw_send_SOURCES = mbus-tcp-raw-send.c + +mbus_tcp_application_reset_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_application_reset_LDADD = -lmbus -lm +mbus_tcp_application_reset_SOURCES = mbus-tcp-application-reset.c + +# serial +mbus_serial_scan_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_scan_LDADD = -lmbus -lm +mbus_serial_scan_SOURCES = mbus-serial-scan.c + +mbus_serial_request_data_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_request_data_LDADD = -lmbus -lm +mbus_serial_request_data_SOURCES = mbus-serial-request-data.c + +mbus_serial_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_request_data_multi_reply_LDADD = -lmbus -lm +mbus_serial_request_data_multi_reply_SOURCES = mbus-serial-request-data-multi-reply.c + +mbus_serial_select_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_select_secondary_LDADD = -lmbus -lm +mbus_serial_select_secondary_SOURCES = mbus-serial-select-secondary.c + +mbus_serial_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_scan_secondary_LDADD = -lmbus -lm +mbus_serial_scan_secondary_SOURCES = mbus-serial-scan-secondary.c + +mbus_serial_switch_baudrate_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_switch_baudrate_LDADD = -lmbus -lm +mbus_serial_switch_baudrate_SOURCES = mbus-serial-switch-baudrate.c + +mbus_serial_set_address_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_set_address_LDADD = -lmbus -lm +mbus_serial_set_address_SOURCES = mbus-serial-set-address.c + +# man pages +dist_man_MANS = libmbus.1 \ + mbus-tcp-scan.1 \ + mbus-tcp-request-data.1 \ + mbus-tcp-request-data-multi-reply.1 \ + mbus-tcp-select-secondary.1 \ + mbus-tcp-scan-secondary.1 \ + mbus-tcp-raw-send.1 \ + mbus-serial-scan.1 \ + mbus-serial-request-data.1 \ + mbus-serial-request-data-multi-reply.1 \ + mbus-serial-select-secondary.1 \ + mbus-serial-scan-secondary.1 \ + mbus-serial-switch-baudrate.1 + +.pod.1: + pod2man --release=$(VERSION) --center=$(PACKAGE) $< \ + >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true + @if grep '\' $@ >/dev/null 2>&1; \ + then \ + echo "$@ has some POD errors!"; false; \ + fi diff --git a/build-deb.sh b/build-deb.sh new file mode 100755 index 00000000..77f3a6be --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2012, Robert Johansson , Raditex Control AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@raditex.nu +# +# ------------------------------------------------------------------------------ + +if [ ! -f Makefile ]; then + # + # regenerate automake files + # + echo "Running autotools..." + + autoheader \ + && aclocal \ + && libtoolize --ltdl --copy --force \ + && automake --add-missing --copy \ + && autoconf +fi + +debuild -i -us -uc -b +#sudo pbuilder build $(NAME)_$(VERSION)-1.dsc diff --git a/build.sh b/build.sh index 04ea869c..34c2799b 100755 --- a/build.sh +++ b/build.sh @@ -1,24 +1,21 @@ #!/bin/sh +# +if [ -f Makefile ]; then + # use existing automake files + echo >> /dev/null +else + # regenerate automake files + echo "Running autotools..." -rm -rf build -mkdir build -cd build -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -cmake --build . + autoheader \ + && aclocal \ + && case \ + $(uname) in Darwin*) glibtoolize --ltdl --copy --force ;; \ + *) libtoolize --ltdl --copy --force ;; esac \ + && automake --add-missing --copy \ + && autoconf \ + && ./configure +fi -# build deb - -# rm -rf build -# mkdir build -# cd build -# cmake .. -DLIBMBUS_PACKAGE_DEB=ON -# cpack .. -# dpkg -i *.deb - -# build doc - -# mkdir build -# cd build -# cmake .. -DLIBMBUS_BUILD_DOCS=ON -# cmake --build . --target doc +make diff --git a/cmake-format.yaml b/cmake-format.yaml deleted file mode 100644 index 60329ed6..00000000 --- a/cmake-format.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# https://github.com/cheshirekow/cmake_format - -# How wide to allow formatted cmake files -line_width: 120 - -# How many spaces to tab for indent -tab_size: 2 - -# Format command names consistently as 'lower' or 'upper' case -command_case: "lower" - -first_comment_is_literal: False - -# enable comment markup parsing and reflow -enable_markup: False diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in deleted file mode 100644 index 9c15f36a..00000000 --- a/cmake/Config.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") -check_required_components("@PROJECT_NAME@") diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..d14d0e2c --- /dev/null +++ b/configure.ac @@ -0,0 +1,44 @@ +dnl ---------------------------------------------------------------------------- +dnl Copyright (C) 2010, Raditex AB +dnl All rights reserved. +dnl +dnl rSCADA +dnl http://www.rSCADA.se +dnl info@rscada.se +dnl +dnl ---------------------------------------------------------------------------- + +LT_CONFIG_LTDL_DIR([libltdl]) + +AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_CONFIG_AUX_DIR([libltdl/config]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) + +AM_PROG_LIBTOOL +# fix for automake 1.11 & 1.12 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + +LDFLAGS="$LDFLAGS -version-info 0:9:0" + +dnl ---------------------- +dnl +AC_PROG_CC + +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([Makefile mbus/Makefile test/Makefile bin/Makefile libmbus.pc]) +AC_OUTPUT + + +echo \ +"---------------------------------------------------------- +Configuration: + + Source location: ${srcdir} + Compile: ${CC} + Compiler flags: ${CFLAGS} + Linker flags: ${LDFLAGS} + Host system type: ${host} + Install path: ${prefix} + + See config.h for further configuration. +----------------------------------------------------------" diff --git a/Doxyfile.in b/doxygen.cfg similarity index 99% rename from Doxyfile.in rename to doxygen.cfg index b8393df7..ea1b569d 100644 --- a/Doxyfile.in +++ b/doxygen.cfg @@ -25,13 +25,13 @@ DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = "@CMAKE_PROJECT_NAME@" +PROJECT_NAME = libmbus # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -581,7 +581,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @CMAKE_CURRENT_LIST_DIR@/mbus +INPUT = mbus # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -1628,6 +1628,3 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES - - -USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_LIST_DIR@/README.md diff --git a/libmbus.pc.in b/libmbus.pc.in index 1baf5a3e..6c1b7d8b 100644 --- a/libmbus.pc.in +++ b/libmbus.pc.in @@ -1,12 +1,12 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@INSTALL_LIB_DIR@ -includedir=@INSTALL_INC_DIR@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ Name: libmbus Description: Open source M-bus (Meter-Bus) library. Requires: -Version: @PROJECT_VERSION@ +Version: @PACKAGE_VERSION@ URL: http://www.rscada.se/libmbus/ Libs: -L${libdir} -lmbus -lm -Cflags: -I${includedir} \ No newline at end of file +Cflags: -I${includedir} diff --git a/libmbus.spec b/libmbus.spec new file mode 100644 index 00000000..06160f75 --- /dev/null +++ b/libmbus.spec @@ -0,0 +1,87 @@ +# +# spec file for package libmbus +# +# Copyright (c) 2010-2013, Raditex Control AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# + +Summary: Open source M-bus (Meter-Bus) library +Name: libmbus +Version: 0.9.0 +Release: 1 +Source: https://github.com/rscada/%{name}/archive/%{version}.tar.gz +URL: https://github.com/rscada/libmbus/ +License: BSD +Vendor: Raditex Control AB +Packager: Stefan Wahren +Group: Development/Languages/C and C++ +BuildRoot: {_tmppath}/%{name}-%{version}-build +AutoReqProv: on + +%description +libmbus: M-bus Library from Raditex Control (http://www.rscada.se) + +libmbus is an open source library for the M-bus (Meter-Bus) protocol. +The Meter-Bus is a standard for reading out meter data from electricity meters, +heat meters, gas meters, etc. The M-bus standard deals with both the electrical +signals on the M-Bus, and the protocol and data format used in transmissions +on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle +the communication with M-Bus devices. + +For more information see http://www.rscada.se/libmbus + +%package devel +License: BSD +Summary: Development libraries and header files for using the M-bus library +Group: Development/Libraries/C and C++ +AutoReqProv: on +Requires: %{name} = %{version} + +%description devel +This package contains all necessary include files and libraries needed +to compile and link applications which use the M-bus (Meter-Bus) library. + +%prep -q +%setup -q +# workaround to get it's build +autoreconf + +%build +./configure --prefix=/usr +make + +%install +rm -Rf "%buildroot" +mkdir "%buildroot" +make install DESTDIR="%buildroot" + +%clean +rm -rf "%buildroot" + +%files +%defattr (-,root,root) +%doc COPYING README.md +%{_bindir}/mbus-serial-* +%{_bindir}/mbus-tcp-* +%{_libdir}/libmbus.so* +%{_mandir}/man1/libmbus.1 +%{_mandir}/man1/mbus-* + +%files devel +%defattr (-,root,root) +%{_includedir}/mbus +%{_libdir}/libmbus.a +%{_libdir}/libmbus.la +%{_libdir}/pkgconfig/libmbus.pc + +%changelog +* Fri Feb 22 2019 Stefan Wahren - 0.9.0-1 +- switch to github repo +- enable man pages + +* Fri Mar 29 2013 Stefan Wahren - 0.8.0-1 +- Initial package based on the last official release diff --git a/mbus/Makefile.am b/mbus/Makefile.am new file mode 100644 index 00000000..b0749871 --- /dev/null +++ b/mbus/Makefile.am @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) + +includedir = $(prefix)/include/mbus +include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h + +lib_LTLIBRARIES = libmbus.la +libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c + diff --git a/mbus/config.h.in b/mbus/config.h.in deleted file mode 100644 index 9b818f65..00000000 --- a/mbus/config.h.in +++ /dev/null @@ -1,56 +0,0 @@ -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H "@HAVE_MEMORY_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H "@HAVE_STDINT_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H "@HAVE_STDLIB_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H "@HAVE_STRINGS_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H "@HAVE_STRING_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H "@HAVE_SYS_STAT_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H "@HAVE_SYS_TYPES_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H "@HAVE_UNISTD_H@" - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "@PROJECT_NAME@" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "info@rscada.se" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "@PROJECT_NAME@" - -/* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@PROJECT_NAME@" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "http://www.rscada.se/libmbus/" - -/* Define to the version of this package. */ -#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" - -/* Version number of package */ -#cmakedefine VERSION "@PACKAGE_VERSION@" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 0303d236..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(mbus_parse ${CMAKE_CURRENT_LIST_DIR}/mbus_parse.c) -target_link_libraries(mbus_parse PRIVATE libmbus::libmbus) - -add_executable(mbus_parse_hex ${CMAKE_CURRENT_LIST_DIR}/mbus_parse_hex.c) -target_link_libraries(mbus_parse_hex PRIVATE libmbus::libmbus) diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 00000000..c373fa48 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/mbus + +noinst_HEADERS = +noinst_PROGRAMS = mbus_parse mbus_parse_hex + +mbus_parse_LDFLAGS = -L$(top_builddir)/mbus +mbus_parse_LDADD = -lmbus -lm +mbus_parse_SOURCES = mbus_parse.c + +mbus_parse_hex_LDFLAGS = -L$(top_builddir)/mbus +mbus_parse_hex_LDADD = -lmbus -lm +mbus_parse_hex_SOURCES = mbus_parse_hex.c + From 646d3c21a0952aa7fe060bacdab390701b3d1b21 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 19 Jul 2020 12:24:27 +0200 Subject: [PATCH 199/238] changelog: Add release 0.9.0 (cherry picked from commit e1f4dbdd52fe8a67e0665a0f3f5368ede1c59d83) --- debian/changelog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5dce9087..8c177b90 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +libmbus (0.9.0) xenial; urgency=medium + + * New official release + - major improvement to frame decoding + - new binaries: mbus-tcp-raw-send, mbus-tcp-application-reset, + mbus-serial-set-address + - simple echo cancellation + - replace CUnit test with test/generate-xml.sh + * debian/control: new package libmbus1-dbg + + -- Stefan Wahren Fri, 22 Feb 2019 19:08:04 +0100 + libmbus (0.8.0) precise; urgency=low * New official release. Includes support for multi-telegram communication. From 37225059e29cef4c7c92e1cdd6b929816f62f644 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 12:06:39 +0200 Subject: [PATCH 200/238] Also generate normalized XML In order to increase the test coverage also generate the normalized version of XML output. --- test/generate-xml.sh | 52 ++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index 6a3231ff..b9662d93 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -37,51 +37,71 @@ if [ $# -eq 2 ]; then fi # Check if mbus_parse_hex exists -if [ ! -x $mbus_parse_hex ]; then +if [ ! -x "$mbus_parse_hex" ]; then echo "mbus_parse_hex not found" echo "path to mbus_parse_hex: $mbus_parse_hex" exit 3 fi -for hexfile in "$directory"/*.hex; do - if [ ! -f "$hexfile" ]; then - continue - fi +generate_xml() { + directory="$1" + hexfile="$2" + mode="$3" - filename=`basename $hexfile .hex` + filename=$(basename "$hexfile" .hex) + + if [ "$mode" = "normalized" ]; then + options="-n" + mode=".norm" + else + options="" + mode="" + fi # Parse hex file and write XML in file - $mbus_parse_hex "$hexfile" > "$directory/$filename.xml.new" + "$mbus_parse_hex" $options "$hexfile" > "$directory/$filename$mode.xml.new" result=$? # Check parsing result if [ $result -ne 0 ]; then echo "Unable to generate XML for $hexfile" - rm "$directory/$filename.xml.new" - continue + rm "$directory/$filename$mode.xml.new" + return 1 fi # Compare old XML with new XML and write in file - diff -u "$directory/$filename.xml" "$directory/$filename.xml.new" 2> /dev/null > "$directory/$filename.dif" + diff -u "$directory/$filename$mode.xml" "$directory/$filename$mode.xml.new" 2> /dev/null > "$directory/$filename$mode.dif" result=$? case "$result" in 0) # XML equal -> remove new - rm "$directory/$filename.xml.new" - rm "$directory/$filename.dif" + rm "$directory/$filename$mode.xml.new" + rm "$directory/$filename$mode.dif" ;; 1) # different -> print diff - cat "$directory/$filename.dif" && rm "$directory/$filename.dif" + cat "$directory/$filename$mode.dif" && rm "$directory/$filename$mode.dif" echo "" ;; *) # no old -> rename XML - echo "Create $filename.xml" - mv "$directory/$filename.xml.new" "$directory/$filename.xml" - rm "$directory/$filename.dif" + echo "Create $filename$mode.xml" + mv "$directory/$filename$mode.xml.new" "$directory/$filename$mode.xml" + rm "$directory/$filename$mode.dif" ;; esac + + return $result +} + +for hexfile in "$directory"/*.hex; do + if [ ! -f "$hexfile" ]; then + continue + fi + + generate_xml "$directory" "$hexfile" "default" + + generate_xml "$directory" "$hexfile" "normalized" done From 581a8d187827b7308708d3f2838a34d3afdb8c81 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 12:55:05 +0200 Subject: [PATCH 201/238] Add normalized XML files of test frames --- test/test-frames/ACW_Itron-BM-plus-m.norm.xml | 87 ++++ .../ACW_Itron-CYBLE-M-Bus-14.norm.xml | 79 ++++ test/test-frames/EDC.norm.xml | 231 +++++++++++ .../EFE_Engelmann-Elster-SensoStar-2.norm.xml | 229 +++++++++++ .../EFE_Engelmann-WaterStar.norm.xml | 113 ++++++ test/test-frames/ELS_Elster-F96-Plus.norm.xml | 151 +++++++ test/test-frames/ELV-Elvaco-CMa10.norm.xml | 121 ++++++ .../EMU_EMU-Professional-375-M-Bus.norm.xml | 287 +++++++++++++ test/test-frames/Elster-F2.norm.xml | 133 ++++++ .../FIN-Finder-7E.23.8.230.0020.norm.xml | 69 ++++ test/test-frames/GWF-MTKcoder.norm.xml | 31 ++ test/test-frames/LGB_G350.norm.xml | 65 +++ test/test-frames/REL-Relay-Padpuls2.norm.xml | 63 +++ .../SBC_Saia-Burgess-ALE3.norm.xml | 191 +++++++++ test/test-frames/SEN_Pollustat.norm.xml | 143 +++++++ .../SEN_Sensus-PolluStat-E.norm.xml | 95 +++++ .../SEN_Sensus-PolluTherm.norm.xml | 87 ++++ .../SLB_CF-Compact-Integral-MK-MaXX.norm.xml | 139 +++++++ test/test-frames/THI_cma10.norm.xml | 121 ++++++ .../test-frames/ZRM_Minol-Minocal-C2.norm.xml | 335 ++++++++++++++++ test/test-frames/abb_delta.norm.xml | 153 +++++++ test/test-frames/abb_f95.norm.xml | 131 ++++++ test/test-frames/allmess_cf50.norm.xml | 95 +++++ test/test-frames/berg_dz_plus.norm.xml | 169 ++++++++ test/test-frames/electricity-meter-1.norm.xml | 191 +++++++++ test/test-frames/electricity-meter-2.norm.xml | 191 +++++++++ test/test-frames/els_falcon.norm.xml | 87 ++++ test/test-frames/els_tmpa_telegramm1.norm.xml | 63 +++ test/test-frames/elv_temp_humid.norm.xml | 121 ++++++ test/test-frames/emh_diz.norm.xml | 43 ++ .../engelmann_sensostar2c.norm.xml | 225 +++++++++++ test/test-frames/example_data_01.norm.xml | 63 +++ test/test-frames/example_data_02.norm.xml | 63 +++ test/test-frames/filler.norm.xml | 23 ++ test/test-frames/frame1.norm.xml | 23 ++ test/test-frames/frame2.norm.xml | 43 ++ test/test-frames/gmc_emmod206.norm.xml | 215 ++++++++++ test/test-frames/itron_bm_+m.norm.xml | 87 ++++ test/test-frames/itron_cf_51.norm.xml | 147 +++++++ test/test-frames/itron_cf_55.norm.xml | 119 ++++++ test/test-frames/itron_cf_echo_2.norm.xml | 119 ++++++ ...itron_cyble_m-bus_v1.4_cold_water.norm.xml | 79 ++++ .../itron_cyble_m-bus_v1.4_gas.norm.xml | 79 ++++ .../itron_cyble_m-bus_v1.4_water.norm.xml | 79 ++++ .../itron_integral_mk_maxx.norm.xml | 139 +++++++ test/test-frames/kamstrup_382_005.norm.xml | 75 ++++ .../kamstrup_multical_601.norm.xml | 259 ++++++++++++ .../landis+gyr_ultraheat_t230.norm.xml | 327 +++++++++++++++ test/test-frames/manual_frame2.norm.xml | 23 ++ test/test-frames/manual_frame3.norm.xml | 43 ++ test/test-frames/manual_frame7.norm.xml | 23 ++ test/test-frames/metrona_pollutherm.norm.xml | 95 +++++ .../test-frames/metrona_ultraheat_xs.norm.xml | 379 ++++++++++++++++++ test/test-frames/minol_minocal_c2.norm.xml | 335 ++++++++++++++++ test/test-frames/minol_minocal_wr3.norm.xml | 285 +++++++++++++ test/test-frames/nzr_dhz_5_63.norm.xml | 71 ++++ test/test-frames/oms_frame1.norm.xml | 39 ++ test/test-frames/oms_frame2.norm.xml | 55 +++ test/test-frames/oms_frame3.norm.xml | 87 ++++ test/test-frames/ram_modularis.norm.xml | 311 ++++++++++++++ test/test-frames/rel_padpuls2.norm.xml | 63 +++ test/test-frames/rel_padpuls3.norm.xml | 63 +++ test/test-frames/sen_pollusonic_2.norm.xml | 23 ++ test/test-frames/sen_pollutherm.norm.xml | 90 +++++ test/test-frames/siemens_water.norm.xml | 95 +++++ test/test-frames/siemens_wfh21.norm.xml | 103 +++++ .../sontex_supercal_531_telegram1.norm.xml | 111 +++++ test/test-frames/svm_f22_telegram1.norm.xml | 133 ++++++ test/test-frames/tch_telegramm1.norm.xml | 95 +++++ test/test-frames/wmbus-converted.norm.xml | 23 ++ 70 files changed, 8723 insertions(+) create mode 100644 test/test-frames/ACW_Itron-BM-plus-m.norm.xml create mode 100644 test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml create mode 100644 test/test-frames/EDC.norm.xml create mode 100644 test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml create mode 100644 test/test-frames/EFE_Engelmann-WaterStar.norm.xml create mode 100644 test/test-frames/ELS_Elster-F96-Plus.norm.xml create mode 100644 test/test-frames/ELV-Elvaco-CMa10.norm.xml create mode 100644 test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml create mode 100644 test/test-frames/Elster-F2.norm.xml create mode 100644 test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml create mode 100644 test/test-frames/GWF-MTKcoder.norm.xml create mode 100644 test/test-frames/LGB_G350.norm.xml create mode 100644 test/test-frames/REL-Relay-Padpuls2.norm.xml create mode 100644 test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml create mode 100644 test/test-frames/SEN_Pollustat.norm.xml create mode 100644 test/test-frames/SEN_Sensus-PolluStat-E.norm.xml create mode 100644 test/test-frames/SEN_Sensus-PolluTherm.norm.xml create mode 100644 test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml create mode 100644 test/test-frames/THI_cma10.norm.xml create mode 100644 test/test-frames/ZRM_Minol-Minocal-C2.norm.xml create mode 100644 test/test-frames/abb_delta.norm.xml create mode 100644 test/test-frames/abb_f95.norm.xml create mode 100644 test/test-frames/allmess_cf50.norm.xml create mode 100644 test/test-frames/berg_dz_plus.norm.xml create mode 100644 test/test-frames/electricity-meter-1.norm.xml create mode 100644 test/test-frames/electricity-meter-2.norm.xml create mode 100644 test/test-frames/els_falcon.norm.xml create mode 100644 test/test-frames/els_tmpa_telegramm1.norm.xml create mode 100644 test/test-frames/elv_temp_humid.norm.xml create mode 100644 test/test-frames/emh_diz.norm.xml create mode 100644 test/test-frames/engelmann_sensostar2c.norm.xml create mode 100644 test/test-frames/example_data_01.norm.xml create mode 100644 test/test-frames/example_data_02.norm.xml create mode 100644 test/test-frames/filler.norm.xml create mode 100644 test/test-frames/frame1.norm.xml create mode 100644 test/test-frames/frame2.norm.xml create mode 100644 test/test-frames/gmc_emmod206.norm.xml create mode 100644 test/test-frames/itron_bm_+m.norm.xml create mode 100644 test/test-frames/itron_cf_51.norm.xml create mode 100644 test/test-frames/itron_cf_55.norm.xml create mode 100644 test/test-frames/itron_cf_echo_2.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml create mode 100644 test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml create mode 100644 test/test-frames/itron_integral_mk_maxx.norm.xml create mode 100644 test/test-frames/kamstrup_382_005.norm.xml create mode 100644 test/test-frames/kamstrup_multical_601.norm.xml create mode 100644 test/test-frames/landis+gyr_ultraheat_t230.norm.xml create mode 100644 test/test-frames/manual_frame2.norm.xml create mode 100644 test/test-frames/manual_frame3.norm.xml create mode 100644 test/test-frames/manual_frame7.norm.xml create mode 100644 test/test-frames/metrona_pollutherm.norm.xml create mode 100644 test/test-frames/metrona_ultraheat_xs.norm.xml create mode 100644 test/test-frames/minol_minocal_c2.norm.xml create mode 100644 test/test-frames/minol_minocal_wr3.norm.xml create mode 100644 test/test-frames/nzr_dhz_5_63.norm.xml create mode 100644 test/test-frames/oms_frame1.norm.xml create mode 100644 test/test-frames/oms_frame2.norm.xml create mode 100644 test/test-frames/oms_frame3.norm.xml create mode 100644 test/test-frames/ram_modularis.norm.xml create mode 100644 test/test-frames/rel_padpuls2.norm.xml create mode 100644 test/test-frames/rel_padpuls3.norm.xml create mode 100644 test/test-frames/sen_pollusonic_2.norm.xml create mode 100644 test/test-frames/sen_pollutherm.norm.xml create mode 100644 test/test-frames/siemens_water.norm.xml create mode 100644 test/test-frames/siemens_wfh21.norm.xml create mode 100644 test/test-frames/sontex_supercal_531_telegram1.norm.xml create mode 100644 test/test-frames/svm_f22_telegram1.norm.xml create mode 100644 test/test-frames/tch_telegramm1.norm.xml create mode 100644 test/test-frames/wmbus-converted.norm.xml diff --git a/test/test-frames/ACW_Itron-BM-plus-m.norm.xml b/test/test-frames/ACW_Itron-BM-plus-m.norm.xml new file mode 100644 index 00000000..fead0d15 --- /dev/null +++ b/test/test-frames/ACW_Itron-BM-plus-m.norm.xml @@ -0,0 +1,87 @@ + + + + + 11490378 + ACW + 14 + Itron BM +m + Cold water + 10 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11490378.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 54.321000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T11:11:00Z + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + + Firmware version + 2.000000 + + + + Instantaneous value + 0 + + Software version + 6.000000 + + + + Manufacturer specific + 0 + + + 00 01 75 13 + + + diff --git a/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml b/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml new file mode 100644 index 00000000..943c741d --- /dev/null +++ b/test/test-frames/ACW_Itron-CYBLE-M-Bus-14.norm.xml @@ -0,0 +1,79 @@ + + + + + 9011523 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Water + 37 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 9011523.000000 + + + + Instantaneous value + 0 + - + cust. ID + 09LA076755 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T14:26:00Z + + + + Instantaneous value + 0 + - + bat. time + 2516.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.031000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.031000 + + + + Manufacturer specific + 0 + + + 00 01 1F + + + diff --git a/test/test-frames/EDC.norm.xml b/test/test-frames/EDC.norm.xml new file mode 100644 index 00000000..c43be60c --- /dev/null +++ b/test/test-frames/EDC.norm.xml @@ -0,0 +1,231 @@ + + + + + 11120895 + EDC + 2 + + Heat: Outlet + 23 + 00 + 0000 + + + + Instantaneous value + 0 + 0 + 0 + Wh + Energy + 35000.000000 + + + + Instantaneous value + 0 + 0 + 0 + Wh + Energy + 465000.000000 + + + + Instantaneous value + 0 + 0 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 0 + °C + Flow temperature + 21.536703 + + + + Instantaneous value + 0 + 0 + 0 + °C + Return temperature + 21.605042 + + + + Instantaneous value + 0 + 0 + 1 + °C + Flow temperature + 92.000000 + + + + Instantaneous value + 0 + 0 + 1 + °C + Return temperature + 92.000000 + + + + Instantaneous value + 0 + 0 + 0 + m^3/h + Volume flow + 0.000707 + + + + Instantaneous value + 0 + 0 + 1 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 0 + 0 + m^3/h + Volume flow + 0.357622 + + + + Maximum value + 0 + 0 + 1 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + 0 + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Maximum value + 0 + 0 + 0 + W + Power + 18511.912109 + + + + Maximum value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-07-10T15:25:00Z + + + + Instantaneous value + 0 + 0 + 0 + - + C + 3571.000000 + + + + Instantaneous value + 0 + 0 + 1 + - + C + 413.000000 + + + + Instantaneous value + 0 + 0 + 0 + - + c + 1.000000 + + + + Instantaneous value + 0 + 0 + 1 + - + c + 1.000000 + + + + Manufacturer specific + 0 + + + + + + diff --git a/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml b/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml new file mode 100644 index 00000000..95229632 --- /dev/null +++ b/test/test-frames/EFE_Engelmann-Elster-SensoStar-2.norm.xml @@ -0,0 +1,229 @@ + + + + + 24083345 + EFE + 0 + Engelmann / Elster SensoStar 2 + Heat: Outlet + 102 + 27 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 24083345.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-12T14:23:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-12-31 + + + + Instantaneous value + 0 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + m^3/h + Volume flow + 0.025000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + W + Power + 11.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 22.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 21.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.090000 + + + + Instantaneous value + 0 + s + On time + 45273600.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000011 + + + diff --git a/test/test-frames/EFE_Engelmann-WaterStar.norm.xml b/test/test-frames/EFE_Engelmann-WaterStar.norm.xml new file mode 100644 index 00000000..c0e11e42 --- /dev/null +++ b/test/test-frames/EFE_Engelmann-WaterStar.norm.xml @@ -0,0 +1,113 @@ + + + + + 4990254 + EFE + 0 + Engelmann WaterStar + Warm water (30-90°C) + 12 + 27 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 4990254.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T12:10:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 0.332000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.331000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 0.332000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-12-31 + + + + Instantaneous value + 0 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + m^3/h + Volume flow + 2.070000 + + + + Instantaneous value + 0 + s + On time + 102902400.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000008 + + + diff --git a/test/test-frames/ELS_Elster-F96-Plus.norm.xml b/test/test-frames/ELS_Elster-F96-Plus.norm.xml new file mode 100644 index 00000000..e2407b37 --- /dev/null +++ b/test/test-frames/ELS_Elster-F96-Plus.norm.xml @@ -0,0 +1,151 @@ + + + + + 44493951 + ELS + 47 + Elster F96 Plus + Heat: Outlet + 161 + 70 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 13131113.000000 + + + + Value during error state + 0 + m^3/h + Volume flow + 131.113000 + + + + Instantaneous value + 0 + °C + Flow temperature + 22.700000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.100000 + + + + Instantaneous value + 0 + s + Operating time + 63072000.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T13:09:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2013-05-31 + + + diff --git a/test/test-frames/ELV-Elvaco-CMa10.norm.xml b/test/test-frames/ELV-Elvaco-CMa10.norm.xml new file mode 100644 index 00000000..13a95962 --- /dev/null +++ b/test/test-frames/ELV-Elvaco-CMa10.norm.xml @@ -0,0 +1,121 @@ + + + + + 24011561 + ELV + 22 + Elvaco CMa10 + Other + 63 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 2.000000 + + + + Instantaneous value + 0 + - + %RH + 54.100000 + + + + Minimum value + 0 + - + %RH + 33.640000 + + + + Maximum value + 0 + - + %RH + 73.630000 + + + + Instantaneous value + 0 + °C + External temperature + 20.940000 + + + + Minimum value + 0 + °C + External temperature + 13.720000 + + + + Maximum value + 0 + °C + External temperature + 29.780000 + + + + Instantaneous value + 0 + s + Averaging Duration + 86400.000000 + + + + Instantaneous value + 1 + °C + External temperature + 20.920000 + + + + Instantaneous value + 2 + 0 + 0 + °C + External temperature + 20.790000 + + + + Instantaneous value + 0 + + Fabrication No + 24011561.000000 + + + + Instantaneous value + 0 + + Software version + 262144.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml b/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml new file mode 100644 index 00000000..e1d3388b --- /dev/null +++ b/test/test-frames/EMU_EMU-Professional-375-M-Bus.norm.xml @@ -0,0 +1,287 @@ + + + + + 32629 + EMU + 16 + EMU Professional 3/75 M-Bus + Electricity + 2 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 32629.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 1364.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 7854.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + W + Power + -2.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + W + Power + -2.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 14.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + W + Power + 14.000000 + + + + Instantaneous value + 0 + V + Voltage + 225.700000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Minimum value + 0 + V + Voltage + 187.400000 + + + + Minimum value + 0 + V + Voltage + 0.000000 + + + + Minimum value + 0 + V + Voltage + 0.000000 + + + + Maximum value + 0 + V + Voltage + 241.000000 + + + + Maximum value + 0 + V + Voltage + 0.000000 + + + + Maximum value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + -0.066000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + A + Current + -0.066000 + + + + Instantaneous value + 0 + + Manufacturer specific + 13.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 500.000000 + + + + Instantaneous value + 0 + + Reset counter + 56.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/Elster-F2.norm.xml b/test/test-frames/Elster-F2.norm.xml new file mode 100644 index 00000000..c8fdec54 --- /dev/null +++ b/test/test-frames/Elster-F2.norm.xml @@ -0,0 +1,133 @@ + + + + + 802657 + SVM + 8 + Elster F2 / Deltamess F2 + Heat: Outlet + 70 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5272000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 1204.270000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 917.690000 + + + + Instantaneous value + 0 + °C + Flow temperature + 28.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 34.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + s + On time + 149014800.000000 + + + + Instantaneous value + 0 + s + Operating time + 149014800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2013-06-29T12:12:00Z + + + + Instantaneous value + 0 + 0 + 1 + Units for H.C.A. + H.C.A. + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Units for H.C.A. + H.C.A. + 0.000000 + + + + More records follow + 0 + + + C4 09 01 01 12 00 01 01 01 07 57 26 80 00 CD 4E 08 04 07 A3 FF 03 57 26 80 00 04 04 0D 02 FF 0F 05 3C FF 62 E7 62 96 0A 89 0A 02 00 15 40 17 01 00 00 63 42 + + + diff --git a/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml b/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml new file mode 100644 index 00000000..118a1f5c --- /dev/null +++ b/test/test-frames/FIN-Finder-7E.23.8.230.0020.norm.xml @@ -0,0 +1,69 @@ + + + + + 23006207 + FIN + 35 + + Electricity + 146 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 1728680.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 1728680.000000 + + + + Instantaneous value + 0 + V + Voltage + 230.000000 + + + + Instantaneous value + 0 + A + Current + 0.600000 + + + + Instantaneous value + 0 + W + Power + 90.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -30.000000 + + + diff --git a/test/test-frames/GWF-MTKcoder.norm.xml b/test/test-frames/GWF-MTKcoder.norm.xml new file mode 100644 index 00000000..6cadee12 --- /dev/null +++ b/test/test-frames/GWF-MTKcoder.norm.xml @@ -0,0 +1,31 @@ + + + + + 182007 + GWF + 53 + + Water + 76 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 182007.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 269.000000 + + + diff --git a/test/test-frames/LGB_G350.norm.xml b/test/test-frames/LGB_G350.norm.xml new file mode 100644 index 00000000..acc91446 --- /dev/null +++ b/test/test-frames/LGB_G350.norm.xml @@ -0,0 +1,65 @@ + + + + + 12082058 + LGB + 64 + + Gas + 64 + 00 + 0000 + + + + Instantaneous value + 1 + m^3 + Volume + 10834.092000 + + + + Instantaneous value + 1 + - + Time point (date & time) + 2016-07-22T08:00:00Z + + + + Instantaneous value + 0 + + Fabrication No + G0017591208205814 + + + + Instantaneous value + 0 + 0 + 1 + + Digital Output + 1.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Special supplier information + 15.000000 + + + diff --git a/test/test-frames/REL-Relay-Padpuls2.norm.xml b/test/test-frames/REL-Relay-Padpuls2.norm.xml new file mode 100644 index 00000000..b5b14405 --- /dev/null +++ b/test/test-frames/REL-Relay-Padpuls2.norm.xml @@ -0,0 +1,63 @@ + + + + + 11216301 + REL + 65 + + Gas + 177 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 28760.810000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 1900-01-00T00:00:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2014-12-31 + + + + Instantaneous value + 1 + m^3 + Volume + 25973.820000 + + + + Instantaneous value + 1 + - + Time point (date) + 2015-12-31 + + + + Manufacturer specific + 0 + + + C0 01 01 0C + + + diff --git a/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml b/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml new file mode 100644 index 00000000..cc646d79 --- /dev/null +++ b/test/test-frames/SBC_Saia-Burgess-ALE3.norm.xml @@ -0,0 +1,191 @@ + + + + + 19000055 + SBC + 22 + Saia-Burgess ALE3 + Electricity + 191 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 2930.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 2930.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 60.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 60.000000 + + + + Instantaneous value + 0 + V + Voltage + 223.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 0.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + diff --git a/test/test-frames/SEN_Pollustat.norm.xml b/test/test-frames/SEN_Pollustat.norm.xml new file mode 100644 index 00000000..a69a6eec --- /dev/null +++ b/test/test-frames/SEN_Pollustat.norm.xml @@ -0,0 +1,143 @@ + + + + + 11788 + SEN + 6 + + Heat / Cooling load meter + 62 + 00 + 0000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2015-04-07T14:59:00Z + + + + Value during error state + 0 + - + Time point (date & time) + 2000-01-01T00:00:00Z + + + + Value during error state + 0 + + Error flags + 67108864.000000 + + + + Instantaneous value + 0 + s + On time + 15803026.000000 + + + + Instantaneous value + 0 + s + Operating time + 15145636.000000 + + + + Instantaneous value + 0 + Wh + Energy + 39831000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 6162.878000 + + + + Instantaneous value + 0 + W + Power + -170.721784 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 3.230039 + + + + Instantaneous value + 0 + °C + Flow temperature + 31.147324 + + + + Instantaneous value + 0 + °C + Return temperature + 31.193100 + + + + Instantaneous value + 0 + K + Temperature difference + -0.045776 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 11582321.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 756.000000 + + + + Instantaneous value + 0 + + Fabrication No + 11788.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + -19184.000000 + + + diff --git a/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml b/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml new file mode 100644 index 00000000..e0ac268c --- /dev/null +++ b/test/test-frames/SEN_Sensus-PolluStat-E.norm.xml @@ -0,0 +1,95 @@ + + + + + 21265095 + SEN + 14 + Sensus PolluStat E + Heat: Outlet + 181 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.100000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.200000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 21265095.000000 + + + + Instantaneous value + 0 + + Customer location + 21265095.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/SEN_Sensus-PolluTherm.norm.xml b/test/test-frames/SEN_Sensus-PolluTherm.norm.xml new file mode 100644 index 00000000..c46e40da --- /dev/null +++ b/test/test-frames/SEN_Sensus-PolluTherm.norm.xml @@ -0,0 +1,87 @@ + + + + + 24351689 + SEN + 11 + Sensus PolluTherm + Heat: Outlet + 84 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 0.000000 + + + + Value during error state + 0 + °C + Return temperature + 0.000000 + + + + Value during error state + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 24351689.000000 + + + + Instantaneous value + 0 + + Customer location + 24351689.000000 + + + diff --git a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml new file mode 100644 index 00000000..a5e4a4a8 --- /dev/null +++ b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.norm.xml @@ -0,0 +1,139 @@ + + + + + 11817314 + SLB + 6 + CF Compact / Integral MK MaXX + Heat: Outlet + 3 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11817314.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.020000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 21.800000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.000000 + + + + Instantaneous value + 0 + K + Temperature difference + -0.180000 + + + + Value during error state + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + s + Operating time + 101606400.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T14:02:00Z + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 3.210000 + + + + Instantaneous value + 0 + + Firmware version + 3.000000 + + + + Instantaneous value + 0 + + Software version + 18.000000 + + + + Manufacturer specific + 0 + + + 00 16 + + + diff --git a/test/test-frames/THI_cma10.norm.xml b/test/test-frames/THI_cma10.norm.xml new file mode 100644 index 00000000..86e149a6 --- /dev/null +++ b/test/test-frames/THI_cma10.norm.xml @@ -0,0 +1,121 @@ + + + + + 2 + ELV + 21 + Elvaco CMa10 + Other + 13 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 2.000000 + + + + Instantaneous value + 0 + - + %RH + 46.600000 + + + + Minimum value + 0 + - + %RH + 37.820000 + + + + Maximum value + 0 + - + %RH + 51.220000 + + + + Instantaneous value + 0 + °C + External temperature + 22.620000 + + + + Minimum value + 0 + °C + External temperature + 22.500000 + + + + Maximum value + 0 + °C + External temperature + 23.260000 + + + + Instantaneous value + 0 + s + Averaging Duration + 0.000000 + + + + Value during error state + 1 + °C + External temperature + 0.000000 + + + + Value during error state + 2 + 0 + 0 + °C + External temperature + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 2.000000 + + + + Instantaneous value + 0 + + Software version + 772.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml b/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml new file mode 100644 index 00000000..7ac242fe --- /dev/null +++ b/test/test-frames/ZRM_Minol-Minocal-C2.norm.xml @@ -0,0 +1,335 @@ + + + + + 31425084 + ZRM + 129 + Minol Minocal C2 + Heat: Outlet + 115 + 27 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date & time) + 2015-01-01T00:00:00Z + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 10 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.074000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 0.043000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + W + Power + 2000.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + °C + Flow temperature + 20.710000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.380000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2014-03-13T12:45:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2014-03-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 33 + 0 + 0 + - + Time point (date) + 2014-02-01 + + + + Instantaneous value + 33 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 34 + 0 + 0 + - + Time point (date) + 2014-01-01 + + + + Instantaneous value + 34 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 35 + 0 + 0 + - + Time point (date) + 2013-12-01 + + + + Instantaneous value + 35 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 36 + 0 + 0 + - + Time point (date) + 2013-11-01 + + + + Instantaneous value + 36 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 37 + 0 + 0 + - + Time point (date) + 2013-10-01 + + + + Instantaneous value + 37 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 38 + 0 + 0 + - + Time point (date) + 2013-09-01 + + + + Instantaneous value + 38 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 39 + 0 + 0 + - + Time point (date) + 2013-08-01 + + + + Instantaneous value + 39 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2014-03-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/abb_delta.norm.xml b/test/test-frames/abb_delta.norm.xml new file mode 100644 index 00000000..6b82deb6 --- /dev/null +++ b/test/test-frames/abb_delta.norm.xml @@ -0,0 +1,153 @@ + + + + + 78563412 + ABB + 2 + ABB Delta-Meter + Electricity + 69 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 1000000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/abb_f95.norm.xml b/test/test-frames/abb_f95.norm.xml new file mode 100644 index 00000000..52f18667 --- /dev/null +++ b/test/test-frames/abb_f95.norm.xml @@ -0,0 +1,131 @@ + + + + + 26718590 + HYD + 40 + ABB F95 Typ US770 + Heat: Outlet + 115 + 50 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.074200 + + + + Value during error state + 0 + W + Power + 1311041.300000 + + + + Value during error state + 0 + m^3/h + Volume flow + 11.041300 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.400000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.400000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T16:34:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date & time) + 2011-04-30T23:59:00Z + + + + Instantaneous value + 1 + - + Time point (date & time) + 2012-04-30T23:59:00Z + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date & time) + 2011-12-31T23:59:00Z + + + + Instantaneous value + 0 + s + Operating time + 311590800.000000 + + + diff --git a/test/test-frames/allmess_cf50.norm.xml b/test/test-frames/allmess_cf50.norm.xml new file mode 100644 index 00000000..2195924e --- /dev/null +++ b/test/test-frames/allmess_cf50.norm.xml @@ -0,0 +1,95 @@ + + + + + 2205100 + SLB + 2 + Allmess Megacontrol CF-50 + Heat: Outlet + 0 + 88 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.300000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 128.800000 + + + + Instantaneous value + 0 + °C + Return temperature + 51.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 77.230000 + + + + Instantaneous value + 0 + - + Time point (date) + 2012-01-12 + + + + Instantaneous value + 0 + s + Operating time + 292291200.000000 + + + + Manufacturer specific + 0 + + + 60 00 + + + diff --git a/test/test-frames/berg_dz_plus.norm.xml b/test/test-frames/berg_dz_plus.norm.xml new file mode 100644 index 00000000..b4def167 --- /dev/null +++ b/test/test-frames/berg_dz_plus.norm.xml @@ -0,0 +1,169 @@ + + + + + 0 + ABB + 2 + ABB Delta-Meter + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 2 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + More records follow + 0 + + + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + diff --git a/test/test-frames/electricity-meter-1.norm.xml b/test/test-frames/electricity-meter-1.norm.xml new file mode 100644 index 00000000..49b42973 --- /dev/null +++ b/test/test-frames/electricity-meter-1.norm.xml @@ -0,0 +1,191 @@ + + + + + 500023E + SBC + 18 + + Electricity + 19 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 12520.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 12520.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 17744330.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 17744330.000000 + + + + Instantaneous value + 0 + V + Voltage + 237.000000 + + + + Instantaneous value + 0 + A + Current + 3.200000 + + + + Instantaneous value + 0 + W + Power + 790.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -180.000000 + + + + Instantaneous value + 0 + V + Voltage + 231.000000 + + + + Instantaneous value + 0 + A + Current + 3.500000 + + + + Instantaneous value + 0 + W + Power + 810.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -150.000000 + + + + Instantaneous value + 0 + V + Voltage + 228.000000 + + + + Instantaneous value + 0 + A + Current + 6.900000 + + + + Instantaneous value + 0 + W + Power + 1600.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -320.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 3200.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -650.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 4.000000 + + + diff --git a/test/test-frames/electricity-meter-2.norm.xml b/test/test-frames/electricity-meter-2.norm.xml new file mode 100644 index 00000000..c8d95e23 --- /dev/null +++ b/test/test-frames/electricity-meter-2.norm.xml @@ -0,0 +1,191 @@ + + + + + 50002E5 + @@@ + 18 + + Electricity + 37 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 2540.000000 + + + + Instantaneous value + 2 + 1 + 0 + Wh + Energy + 2540.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 4441280.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 4441280.000000 + + + + Instantaneous value + 0 + V + Voltage + 233.000000 + + + + Instantaneous value + 0 + A + Current + 0.100000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 234.000000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + V + Voltage + 235.000000 + + + + Instantaneous value + 0 + A + Current + 0.100000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Manufacturer specific + 4.000000 + + + diff --git a/test/test-frames/els_falcon.norm.xml b/test/test-frames/els_falcon.norm.xml new file mode 100644 index 00000000..c0f2ff4d --- /dev/null +++ b/test/test-frames/els_falcon.norm.xml @@ -0,0 +1,87 @@ + + + + + 70112345 + ELS + 10 + Elster Falcon + Water + 2 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 1234.567000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2007-02-06T13:58:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2007-01-01 + + + + Instantaneous value + 1 + m^3 + Volume + 456.951000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Maximum value + 0 + m^3/h + Volume flow + 5.945000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 6.137000 + + + + Manufacturer specific + 0 + + + 0E 42 20 01 01 01 00 05 08 5E 01 20 3D 12 08 3D 12 08 00 + + + diff --git a/test/test-frames/els_tmpa_telegramm1.norm.xml b/test/test-frames/els_tmpa_telegramm1.norm.xml new file mode 100644 index 00000000..16a06819 --- /dev/null +++ b/test/test-frames/els_tmpa_telegramm1.norm.xml @@ -0,0 +1,63 @@ + + + + + 70112345 + ELS + 2 + Elster TMP-A + Water + 2 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 1234.567000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2007-02-06T13:58:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2007-01-01 + + + + Instantaneous value + 1 + m^3 + Volume + 456.951000 + + + + Instantaneous value + 1 + - + Time point (date) + 2008-01-01 + + + + Manufacturer specific + 0 + + + 00 + + + diff --git a/test/test-frames/elv_temp_humid.norm.xml b/test/test-frames/elv_temp_humid.norm.xml new file mode 100644 index 00000000..369720a5 --- /dev/null +++ b/test/test-frames/elv_temp_humid.norm.xml @@ -0,0 +1,121 @@ + + + + + 54000834 + ELV + 50 + Elvaco CMa11 + Other + 242 + 00 + 0000 + + + + Instantaneous value + 0 + + Digital Input + 0.000000 + + + + Instantaneous value + 0 + - + %RH + 45.640000 + + + + Minimum value + 0 + - + %RH + 45.520000 + + + + Maximum value + 0 + - + %RH + 58.120000 + + + + Instantaneous value + 0 + °C + External temperature + 22.560000 + + + + Minimum value + 0 + °C + External temperature + 21.600000 + + + + Maximum value + 0 + °C + External temperature + 23.390000 + + + + Instantaneous value + 0 + s + Averaging Duration + 86400.000000 + + + + Instantaneous value + 1 + °C + External temperature + 22.760000 + + + + Instantaneous value + 2 + 0 + 0 + °C + External temperature + 22.690000 + + + + Instantaneous value + 0 + + Fabrication No + 54000834.000000 + + + + Instantaneous value + 0 + + Software version + 262144.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/emh_diz.norm.xml b/test/test-frames/emh_diz.norm.xml new file mode 100644 index 00000000..7a9a6fc9 --- /dev/null +++ b/test/test-frames/emh_diz.norm.xml @@ -0,0 +1,43 @@ + + + + + 623702 + EMH + 0 + EMH DIZ + Electricity + 7 + 00 + 0000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 4090.000000 + + + + Instantaneous value + 1 + 0 + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/engelmann_sensostar2c.norm.xml b/test/test-frames/engelmann_sensostar2c.norm.xml new file mode 100644 index 00000000..97331437 --- /dev/null +++ b/test/test-frames/engelmann_sensostar2c.norm.xml @@ -0,0 +1,225 @@ + + + + + 10380010 + EFE + 1 + Engelmann SensoStar 2C + Heat: Outlet + 30 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10380010.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-06-06T20:50:00Z + + + + Instantaneous value + 0 + m^3 + Volume + 12.900000 + + + + Instantaneous value + 0 + Wh + Energy + 800000.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 95.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 43.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 52.580000 + + + + Instantaneous value + 0 + s + Operating time + 43718400.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.100000 + + + + Instantaneous value + 1 + - + Time point (date) + 2011-12-31 + + + + Instantaneous value + 1 + m^3 + Volume + 12.900000 + + + + Instantaneous value + 1 + Wh + Energy + 800000.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date) + 2010-12-31 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 8.400000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 500000.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 3 + 0 + Wh + Energy + 0.000000 + + + diff --git a/test/test-frames/example_data_01.norm.xml b/test/test-frames/example_data_01.norm.xml new file mode 100644 index 00000000..54ba0bb1 --- /dev/null +++ b/test/test-frames/example_data_01.norm.xml @@ -0,0 +1,63 @@ + + + + + 3575845 + AMT + 52 + + Heat: Outlet + 158 + 00 + B627 + + + + Instantaneous value + 0 + Wh + Energy + 1389817000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 504647.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 41.737434 + + + + Instantaneous value + 0 + °C + Return temperature + 35.463650 + + + diff --git a/test/test-frames/example_data_02.norm.xml b/test/test-frames/example_data_02.norm.xml new file mode 100644 index 00000000..d135aae2 --- /dev/null +++ b/test/test-frames/example_data_02.norm.xml @@ -0,0 +1,63 @@ + + + + + 3575845 + AMT + 52 + + Heat: Outlet + 161 + 00 + B627 + + + + Instantaneous value + 0 + Wh + Energy + 1389817000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 504647.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 41.211052 + + + + Instantaneous value + 0 + °C + Return temperature + 35.385593 + + + diff --git a/test/test-frames/filler.norm.xml b/test/test-frames/filler.norm.xml new file mode 100644 index 00000000..f7a01342 --- /dev/null +++ b/test/test-frames/filler.norm.xml @@ -0,0 +1,23 @@ + + + + + 17677731 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5000.000000 + + + diff --git a/test/test-frames/frame1.norm.xml b/test/test-frames/frame1.norm.xml new file mode 100644 index 00000000..92877062 --- /dev/null +++ b/test/test-frames/frame1.norm.xml @@ -0,0 +1,23 @@ + + + + + 10060958 + LSE + 22 + + Bus/System + 123 + 00 + 0000 + + + + Manufacturer specific + 0 + + + 5F 42 01 11 FF FF FF FF 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + + + diff --git a/test/test-frames/frame2.norm.xml b/test/test-frames/frame2.norm.xml new file mode 100644 index 00000000..0b29cb81 --- /dev/null +++ b/test/test-frames/frame2.norm.xml @@ -0,0 +1,43 @@ + + + + + 12345678 + PAD + 1 + + Water + 85 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 12.565000 + + + + Maximum value + 5 + 0 + 0 + m^3/h + Volume flow + 0.113000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 218370.000000 + + + diff --git a/test/test-frames/gmc_emmod206.norm.xml b/test/test-frames/gmc_emmod206.norm.xml new file mode 100644 index 00000000..da2ec220 --- /dev/null +++ b/test/test-frames/gmc_emmod206.norm.xml @@ -0,0 +1,215 @@ + + + + + 12345678 + GMC + 230 + GMC-I A230 EMMOD 206 + Electricity + 2 + 00 + 0000 + + + + Instantaneous value + 0 + 0 + 1 + V + Voltage + 86.400000 + + + + Instantaneous value + 0 + 0 + 2 + V + Voltage + 95.900000 + + + + Instantaneous value + 0 + 0 + 3 + V + Voltage + 105.600000 + + + + Instantaneous value + 0 + 0 + 1 + A + Current + 0.957000 + + + + Instantaneous value + 0 + 0 + 2 + A + Current + 1.055000 + + + + Instantaneous value + 0 + 0 + 3 + A + Current + 1.150000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + 224.000000 + + + + Instantaneous value + 0 + 0 + 1 + W + Power + -202.000000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 103880.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 150000.000000 + + + + Instantaneous value + 0 + 1 + 1 + Wh + Energy + 201590.000000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 250000.000000 + + + + Instantaneous value + 0 + 1 + 2 + Wh + Energy + 300910.000000 + + + + Instantaneous value + 0 + 2 + 2 + Wh + Energy + 350000.000000 + + + + Instantaneous value + 0 + 1 + 3 + Wh + Energy + 402370.000000 + + + + Instantaneous value + 0 + 2 + 3 + Wh + Energy + 450000.000000 + + + + Instantaneous value + 2 + 0 + 1 + W + Power + 224.000000 + + + + Instantaneous value + 4 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 6 + 0 + 1 + W + Power + 0.000000 + + + + Instantaneous value + 8 + 0 + 1 + W + Power + 202.000000 + + + diff --git a/test/test-frames/itron_bm_+m.norm.xml b/test/test-frames/itron_bm_+m.norm.xml new file mode 100644 index 00000000..cfe33275 --- /dev/null +++ b/test/test-frames/itron_bm_+m.norm.xml @@ -0,0 +1,87 @@ + + + + + 11490378 + ACW + 14 + Itron BM +m + Cold water + 41 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11490378.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 54.321000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:29:00Z + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + + Firmware version + 2.000000 + + + + Instantaneous value + 0 + + Software version + 6.000000 + + + + Manufacturer specific + 0 + + + 00 00 8F 13 + + + diff --git a/test/test-frames/itron_cf_51.norm.xml b/test/test-frames/itron_cf_51.norm.xml new file mode 100644 index 00000000..88f69345 --- /dev/null +++ b/test/test-frames/itron_cf_51.norm.xml @@ -0,0 +1,147 @@ + + + + + 11155185 + ACW + 10 + Itron CF 51 + Heat / Cooling load meter + 27 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11155185.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 999.900000 + + + + Value during error state + 0 + °C + Return temperature + 999.900000 + + + + Value during error state + 0 + K + Temperature difference + 9999.990000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:24:00Z + + + + Instantaneous value + 0 + s + Operating time + 8985600.000000 + + + + Instantaneous value + 0 + + Firmware version + 11.000000 + + + + Instantaneous value + 0 + + Software version + 26.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 321.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Manufacturer specific + 0 + + + 03 20 + + + diff --git a/test/test-frames/itron_cf_55.norm.xml b/test/test-frames/itron_cf_55.norm.xml new file mode 100644 index 00000000..f035c35d --- /dev/null +++ b/test/test-frames/itron_cf_55.norm.xml @@ -0,0 +1,119 @@ + + + + + 11127667 + ACW + 11 + Itron CF 55 + Heat: Inlet + 11 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11127667.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Value during error state + 0 + °C + Flow temperature + 999.900000 + + + + Value during error state + 0 + °C + Return temperature + 999.900000 + + + + Value during error state + 0 + K + Temperature difference + 9999.990000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T11:47:00Z + + + + Instantaneous value + 0 + s + Operating time + 21772800.000000 + + + + Instantaneous value + 0 + + Firmware version + 10.000000 + + + + Instantaneous value + 0 + + Software version + 21.000000 + + + + Manufacturer specific + 0 + + + 03 20 + + + diff --git a/test/test-frames/itron_cf_echo_2.norm.xml b/test/test-frames/itron_cf_echo_2.norm.xml new file mode 100644 index 00000000..d8ec6093 --- /dev/null +++ b/test/test-frames/itron_cf_echo_2.norm.xml @@ -0,0 +1,119 @@ + + + + + 11100091 + ACW + 9 + Itron CF Echo 2 + Heat: Outlet + 81 + 10 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11100091.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Value during error state + 0 + W + Power + 99999900.000000 + + + + Value during error state + 0 + m^3/h + Volume flow + 999.999000 + + + + Instantaneous value + 0 + °C + Flow temperature + 20.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 20.600000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.090000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:29:00Z + + + + Instantaneous value + 0 + s + Operating time + 33264000.000000 + + + + Instantaneous value + 0 + + Firmware version + 19.000000 + + + + Instantaneous value + 0 + + Software version + 45.000000 + + + + Manufacturer specific + 0 + + + 20 00 + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml new file mode 100644 index 00000000..da7eb622 --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_cold_water.norm.xml @@ -0,0 +1,79 @@ + + + + + 10020380 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Cold water + 161 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10020380.000000 + + + + Instantaneous value + 0 + - + cust. ID + + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-10-25T15:39:00Z + + + + Instantaneous value + 0 + - + bat. time + 4050.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 453.500000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 453.500000 + + + + Manufacturer specific + 0 + + + 00 04 1F + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml new file mode 100644 index 00000000..a325227b --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_gas.norm.xml @@ -0,0 +1,79 @@ + + + + + 10020387 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Gas + 154 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 10020387.000000 + + + + Instantaneous value + 0 + - + cust. ID + + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-10-25T15:43:00Z + + + + Instantaneous value + 0 + - + bat. time + 4050.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.260000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.250000 + + + + Manufacturer specific + 0 + + + 00 02 1F + + + diff --git a/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml b/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml new file mode 100644 index 00000000..4e120cdc --- /dev/null +++ b/test/test-frames/itron_cyble_m-bus_v1.4_water.norm.xml @@ -0,0 +1,79 @@ + + + + + 12000071 + ACW + 20 + Itron CYBLE M-Bus 1.4 + Water + 10 + 30 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 12000071.000000 + + + + Instantaneous value + 0 + - + cust. ID + TEST CYBLE + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T13:43:00Z + + + + Instantaneous value + 0 + - + bat. time + 4338.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 123.490000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.200000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Manufacturer specific + 0 + + + 10 01 1F + + + diff --git a/test/test-frames/itron_integral_mk_maxx.norm.xml b/test/test-frames/itron_integral_mk_maxx.norm.xml new file mode 100644 index 00000000..bfc94867 --- /dev/null +++ b/test/test-frames/itron_integral_mk_maxx.norm.xml @@ -0,0 +1,139 @@ + + + + + 11817314 + SLB + 6 + CF Compact / Integral MK MaXX + Heat: Outlet + 93 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 11817314.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.020000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 21.200000 + + + + Instantaneous value + 0 + °C + Return temperature + 21.100000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.070000 + + + + Value during error state + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + s + Operating time + 34300800.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-24T14:17:00Z + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 1.230000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 3.210000 + + + + Instantaneous value + 0 + + Firmware version + 3.000000 + + + + Instantaneous value + 0 + + Software version + 18.000000 + + + + Manufacturer specific + 0 + + + 00 16 + + + diff --git a/test/test-frames/kamstrup_382_005.norm.xml b/test/test-frames/kamstrup_382_005.norm.xml new file mode 100644 index 00000000..d3246e19 --- /dev/null +++ b/test/test-frames/kamstrup_382_005.norm.xml @@ -0,0 +1,75 @@ + + + + + 14839120 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 4 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + s + On time + 32400.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + 1 + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 0.000000 + + + + Manufacturer specific + 0 + + + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 10 + + + diff --git a/test/test-frames/kamstrup_multical_601.norm.xml b/test/test-frames/kamstrup_multical_601.norm.xml new file mode 100644 index 00000000..769a90b4 --- /dev/null +++ b/test/test-frames/kamstrup_multical_601.norm.xml @@ -0,0 +1,259 @@ + + + + + 6855817 + KAM + 8 + Kamstrup Multical 601 + Heat: Outlet + 4 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 6855817.000000 + + + + Instantaneous value + 0 + Wh + Energy + 37351000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 561.080000 + + + + Instantaneous value + 0 + s + On time + 3546000.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 101.690000 + + + + Instantaneous value + 0 + °C + Return temperature + 46.160000 + + + + Instantaneous value + 0 + K + Temperature difference + 55.530000 + + + + Instantaneous value + 0 + W + Power + 34700.000000 + + + + Maximum value + 0 + W + Power + 44800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.543000 + + + + Maximum value + 0 + m^3/h + Volume flow + 0.628000 + + + + Instantaneous value + 0 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + 0 + 3 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-01-05T15:26:00Z + + + + Instantaneous value + 1 + Wh + Energy + 33361000.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 500.980000 + + + + Maximum value + 1 + W + Power + 55000.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 1.027000 + + + + Instantaneous value + 1 + 1 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 2 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 3 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2010-12-31 + + + + Manufacturer specific + 0 + + + 00 00 00 00 E7 E4 00 00 63 66 00 00 00 00 00 00 00 00 00 00 00 00 00 00 5B C9 A5 02 34 53 00 00 E0 B2 03 00 89 9C 68 00 00 00 00 00 01 00 01 07 07 09 01 03 00 00 00 00 00 + + + diff --git a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml new file mode 100644 index 00000000..d30f1cd5 --- /dev/null +++ b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml @@ -0,0 +1,327 @@ + + + + + 66660205 + LUG + 7 + Landis & Gyr Ultraheat T230 + Heat: Outlet + 1 + 10 + 0000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + s + Averaging Duration + 8.000000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 19.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 19.700000 + + + + Instantaneous value + 0 + K + Temperature difference + -0.200000 + + + + Instantaneous value + 0 + + Fabrication No + 66660205.000000 + + + + Instantaneous value + 0 + 1 + 0 + s + Averaging Duration + 420.000000 + + + + Value during error state + 0 + s + On time + 13568400.000000 + + + + Instantaneous value + 0 + s + On time + 13568400.000000 + + + + Instantaneous value + 0 + s + Operating time + 0.000000 + + + + Instantaneous value + 0 + 5 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 30.700000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 50.700000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 41065374.600000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 40953732.300000 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Value during error state + 1 + s + On time + 12488400.000000 + + + + Instantaneous value + 1 + s + Operating time + 0.000000 + + + + Instantaneous value + 1 + 5 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 1 + 1 + 0 + W + Power + 0.000000 + + + + Maximum value + 1 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + 1 + 0 + °C + Flow temperature + 30.700000 + + + + Maximum value + 1 + 1 + 0 + °C + Return temperature + 50.700000 + + + + Instantaneous value + 510 + 0 + 0 + - + Time point (date & time) + 2127-01-01T00:00:00Z + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T12:04:00Z + + + + Manufacturer specific + 0 + + + 09 07 00 66 01 + + + diff --git a/test/test-frames/manual_frame2.norm.xml b/test/test-frames/manual_frame2.norm.xml new file mode 100644 index 00000000..c6124757 --- /dev/null +++ b/test/test-frames/manual_frame2.norm.xml @@ -0,0 +1,23 @@ + + + + + 12345678 + Water + 10 + 00 + + + + Actual value + l + 1 + + + + Actual value + reserved but historic + 135 + + + diff --git a/test/test-frames/manual_frame3.norm.xml b/test/test-frames/manual_frame3.norm.xml new file mode 100644 index 00000000..0b29cb81 --- /dev/null +++ b/test/test-frames/manual_frame3.norm.xml @@ -0,0 +1,43 @@ + + + + + 12345678 + PAD + 1 + + Water + 85 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 12.565000 + + + + Maximum value + 5 + 0 + 0 + m^3/h + Volume flow + 0.113000 + + + + Instantaneous value + 0 + 2 + 1 + Wh + Energy + 218370.000000 + + + diff --git a/test/test-frames/manual_frame7.norm.xml b/test/test-frames/manual_frame7.norm.xml new file mode 100644 index 00000000..28c78ac5 --- /dev/null +++ b/test/test-frames/manual_frame7.norm.xml @@ -0,0 +1,23 @@ + + + + + 12345678 + PAD + 1 + + Water + 19 + 00 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 1020304.000000 + + + diff --git a/test/test-frames/metrona_pollutherm.norm.xml b/test/test-frames/metrona_pollutherm.norm.xml new file mode 100644 index 00000000..b3f74934 --- /dev/null +++ b/test/test-frames/metrona_pollutherm.norm.xml @@ -0,0 +1,95 @@ + + + + + 44950146 + SPX + 52 + Sensus PolluTherm + Heat: Outlet + 84 + 10 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 44950146.000000 + + + + Instantaneous value + 0 + + Customer location + 44950146.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/metrona_ultraheat_xs.norm.xml b/test/test-frames/metrona_ultraheat_xs.norm.xml new file mode 100644 index 00000000..82423fe9 --- /dev/null +++ b/test/test-frames/metrona_ultraheat_xs.norm.xml @@ -0,0 +1,379 @@ + + + + + 1810054 + LUG + 2 + Landis & Gyr Ultraheat 2WR5 + Heat: Outlet + 15 + 10 + 0000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + s + Averaging Duration + 4.000000 + + + + Instantaneous value + 0 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 1 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 0 + + Fabrication No + 65110054.000000 + + + + Instantaneous value + 0 + 1 + 0 + s + Averaging Duration + 3600.000000 + + + + Maximum value + 0 + 1 + 0 + W + Power + 31600.000000 + + + + Maximum value + 1 + 1 + 0 + W + Power + 31600.000000 + + + + Maximum value + 0 + 1 + 0 + m^3/h + Volume flow + 8.820000 + + + + Maximum value + 0 + 1 + 0 + °C + Flow temperature + 44.000000 + + + + Maximum value + 0 + 1 + 0 + °C + Return temperature + 40.000000 + + + + Instantaneous value + 0 + s + On time + 252241200.000000 + + + + Value during error state + 0 + s + On time + 185792400.000000 + + + + Value during error state + 1 + s + On time + 172141200.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-01-01 + + + + Instantaneous value + 0 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + 4 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 2 + 1 + 0 + °C + Flow temperature + 36.000000 + + + + Maximum value + 2 + 1 + 0 + °C + Return temperature + 40.000000 + + + + Maximum value + 2 + 1 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 2 + 1 + 0 + W + Power + 0.000000 + + + + Value during error state + 2 + 0 + 0 + s + On time + 185274000.000000 + + + + Instantaneous value + 2 + 0 + 0 + Wh + Energy + 19969000.000000 + + + + Instantaneous value + 2 + 2 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 3 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 4 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 26492.180000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-06-07T00:38:00Z + + + + Manufacturer specific + 0 + + + 03 02 00 00 23 + + + diff --git a/test/test-frames/minol_minocal_c2.norm.xml b/test/test-frames/minol_minocal_c2.norm.xml new file mode 100644 index 00000000..bb7cafb7 --- /dev/null +++ b/test/test-frames/minol_minocal_c2.norm.xml @@ -0,0 +1,335 @@ + + + + + 31425084 + ZRM + 129 + Minol Minocal C2 + Heat: Outlet + 36 + 27 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date & time) + 2013-01-01T00:00:00Z + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 10 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.073000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 1 + m^3/h + Volume flow + 0.043000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + W + Power + 2000.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2011-09-01T08:30:00Z + + + + Instantaneous value + 0 + °C + Flow temperature + 20.090000 + + + + Instantaneous value + 0 + °C + Return temperature + 19.270000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T11:53:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 33 + 0 + 0 + - + Time point (date) + 2011-12-01 + + + + Instantaneous value + 33 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 34 + 0 + 0 + - + Time point (date) + 2011-11-01 + + + + Instantaneous value + 34 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 35 + 0 + 0 + - + Time point (date) + 2011-10-01 + + + + Instantaneous value + 35 + 0 + 0 + Wh + Energy + 3000.000000 + + + + Instantaneous value + 36 + 0 + 0 + - + Time point (date) + 2011-09-01 + + + + Instantaneous value + 36 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 37 + 0 + 0 + - + Time point (date) + 2011-08-01 + + + + Instantaneous value + 37 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 38 + 0 + 0 + - + Time point (date) + 2011-07-01 + + + + Instantaneous value + 38 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 39 + 0 + 0 + - + Time point (date) + 2011-06-01 + + + + Instantaneous value + 39 + 0 + 0 + Wh + Energy + 0.000000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.001000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/minol_minocal_wr3.norm.xml b/test/test-frames/minol_minocal_wr3.norm.xml new file mode 100644 index 00000000..19ddead9 --- /dev/null +++ b/test/test-frames/minol_minocal_wr3.norm.xml @@ -0,0 +1,285 @@ + + + + + 31802759 + ZRM + 130 + Minol Minocal WR3 + Heat: Outlet + 43 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.010000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 8 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 9 + 0 + 0 + - + Time point (date & time) + 2012-01-01T00:00:00Z + + + + Maximum value + 2 + 0 + 0 + W + Power + 0.000000 + + + + Maximum value + 2 + 0 + 0 + - + Time point (date & time) + 2012-01-13T11:30:00Z + + + + Maximum value + 1 + m^3/h + Volume flow + 0.010000 + + + + Maximum value + 1 + - + Time point (date & time) + 2011-03-24T07:30:00Z + + + + Instantaneous value + 0 + 0 + 1 + + (Enhanced) Identification + 0.000000 + + + + Instantaneous value + 0 + 0 + 1 + + Device type + 7.000000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 9 + 0 + 0 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + 0 + 2 + + (Enhanced) Identification + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + 0 + 2 + + Device type + 7.000000 + + + + Instantaneous value + 10 + 0 + 0 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 0 + + Error flags + 4.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2012-01-13T12:01:00Z + + + + Instantaneous value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Instantaneous value + 32 + 0 + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 32 + 0 + 1 + m^3 + Volume + 0.001000 + + + + Instantaneous value + 32 + 0 + 2 + m^3 + Volume + 0.001000 + + + + Maximum value + 32 + 0 + 0 + - + Time point (date) + 2012-01-01 + + + + Maximum value + 32 + 0 + 0 + m^3/h + Volume flow + 0.000000 + + + + Maximum value + 32 + 0 + 0 + W + Power + 0.000000 + + + diff --git a/test/test-frames/nzr_dhz_5_63.norm.xml b/test/test-frames/nzr_dhz_5_63.norm.xml new file mode 100644 index 00000000..46dfb585 --- /dev/null +++ b/test/test-frames/nzr_dhz_5_63.norm.xml @@ -0,0 +1,71 @@ + + + + + 30100608 + NZR + 1 + NZR DHZ 5/63 + Electricity + 1 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 1274.000000 + + + + Instantaneous value + 0 + Wh + Energy + 1274.000000 + + + + Instantaneous value + 0 + V + Voltage + 237.200000 + + + + Instantaneous value + 0 + A + Current + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + + Fabrication No + 30100608.000000 + + + + Manufacturer specific + 0 + + + 0E + + + diff --git a/test/test-frames/oms_frame1.norm.xml b/test/test-frames/oms_frame1.norm.xml new file mode 100644 index 00000000..1dfd8649 --- /dev/null +++ b/test/test-frames/oms_frame1.norm.xml @@ -0,0 +1,39 @@ + + + + + 12345678 + ELS + 51 + + Gas + 42 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 28504.270000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2008-05-31T23:50:00Z + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/oms_frame2.norm.xml b/test/test-frames/oms_frame2.norm.xml new file mode 100644 index 00000000..480c8920 --- /dev/null +++ b/test/test-frames/oms_frame2.norm.xml @@ -0,0 +1,55 @@ + + + + + 92752244 + HYD + 41 + + Water + 31 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 2850.427000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.127000 + + + + Instantaneous value + 1 + m^3 + Volume + 1445.419000 + + + + Instantaneous value + 1 + - + Time point (date) + 2007-12-31 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/oms_frame3.norm.xml b/test/test-frames/oms_frame3.norm.xml new file mode 100644 index 00000000..f144e0ee --- /dev/null +++ b/test/test-frames/oms_frame3.norm.xml @@ -0,0 +1,87 @@ + + + + + 12345678 + HYD + 42 + + Heat: Outlet + 38 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 2850427000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 703.476000 + + + + Instantaneous value + 1 + Wh + Energy + 1445419000.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2007-12-31 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.127000 + + + + Instantaneous value + 0 + W + Power + 329.700000 + + + + Instantaneous value + 0 + °C + Flow temperature + 44.300000 + + + + Instantaneous value + 0 + °C + Return temperature + 25.100000 + + + + Instantaneous value + 0 + + Error flags + 0.000000 + + + diff --git a/test/test-frames/ram_modularis.norm.xml b/test/test-frames/ram_modularis.norm.xml new file mode 100644 index 00000000..3f6b3f9c --- /dev/null +++ b/test/test-frames/ram_modularis.norm.xml @@ -0,0 +1,311 @@ + + + + + 25776 + RAM + 3 + Rossweiner ETK/ETW Modularis + Water + 139 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 10.116000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2013-10-18T21:40:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2013-09-28 + + + + Instantaneous value + 1 + m^3 + Volume + 8.393000 + + + + Instantaneous value + 1 + - + Time point (date) + 2014-09-28 + + + + Instantaneous value + 0 + + Fabrication No + 25776.000000 + + + + Instantaneous value + 2 + 0 + 0 + - + Time point (date) + 2013-09-30 + + + + Instantaneous value + 2 + 0 + 0 + m^3 + Volume + 8.527000 + + + + Instantaneous value + 3 + 0 + 0 + - + Time point (date) + 2012-10-31 + + + + Instantaneous value + 3 + 0 + 0 + m^3 + Volume + 99999.995000 + + + + Instantaneous value + 4 + 0 + 0 + - + Time point (date) + 2012-11-30 + + + + Instantaneous value + 4 + 0 + 0 + m^3 + Volume + 99999.993000 + + + + Instantaneous value + 5 + 0 + 0 + - + Time point (date) + 2012-12-31 + + + + Instantaneous value + 5 + 0 + 0 + m^3 + Volume + 0.782000 + + + + Instantaneous value + 6 + 0 + 0 + - + Time point (date) + 2013-01-31 + + + + Instantaneous value + 6 + 0 + 0 + m^3 + Volume + 1.929000 + + + + Instantaneous value + 7 + 0 + 0 + - + Time point (date) + 2013-02-28 + + + + Instantaneous value + 7 + 0 + 0 + m^3 + Volume + 3.092000 + + + + Instantaneous value + 8 + 0 + 0 + - + Time point (date) + 2013-03-31 + + + + Instantaneous value + 8 + 0 + 0 + m^3 + Volume + 4.661000 + + + + Instantaneous value + 9 + 0 + 0 + - + Time point (date) + 2013-04-30 + + + + Instantaneous value + 9 + 0 + 0 + m^3 + Volume + 4.767000 + + + + Instantaneous value + 10 + 0 + 0 + - + Time point (date) + 2013-05-31 + + + + Instantaneous value + 10 + 0 + 0 + m^3 + Volume + 5.124000 + + + + Instantaneous value + 11 + 0 + 0 + - + Time point (date) + 2013-06-30 + + + + Instantaneous value + 11 + 0 + 0 + m^3 + Volume + 5.176000 + + + + Instantaneous value + 12 + 0 + 0 + - + Time point (date) + 2013-07-31 + + + + Instantaneous value + 12 + 0 + 0 + m^3 + Volume + 5.246000 + + + + Instantaneous value + 13 + 0 + 0 + - + Time point (date) + 2013-08-31 + + + + Instantaneous value + 13 + 0 + 0 + m^3 + Volume + 5.668000 + + + + Manufacturer specific + 0 + + + 01 00 00 + + + diff --git a/test/test-frames/rel_padpuls2.norm.xml b/test/test-frames/rel_padpuls2.norm.xml new file mode 100644 index 00000000..14f88c8c --- /dev/null +++ b/test/test-frames/rel_padpuls2.norm.xml @@ -0,0 +1,63 @@ + + + + + 4 + REL + 18 + Relay PadPuls M4 + Other + 1 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2001-09-20T13:16:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2000-12-31 + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2001-12-31 + + + + Manufacturer specific + 0 + + + 43 01 01 00 + + + diff --git a/test/test-frames/rel_padpuls3.norm.xml b/test/test-frames/rel_padpuls3.norm.xml new file mode 100644 index 00000000..b6dafa74 --- /dev/null +++ b/test/test-frames/rel_padpuls3.norm.xml @@ -0,0 +1,63 @@ + + + + + 1030101 + REL + 64 + Relay PadPuls M2 + Heat Cost Allocator + 30 + 00 + 0000 + + + + Instantaneous value + 0 + Units for H.C.A. + H.C.A. + 1987.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2000-12-31T10:41:00Z + + + + Instantaneous value + 1 + - + Time point (date) + 2000-12-31 + + + + Instantaneous value + 1 + Units for H.C.A. + H.C.A. + 1302.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2001-12-31 + + + + Manufacturer specific + 0 + + + C0 01 01 0C + + + diff --git a/test/test-frames/sen_pollusonic_2.norm.xml b/test/test-frames/sen_pollusonic_2.norm.xml new file mode 100644 index 00000000..1605e327 --- /dev/null +++ b/test/test-frames/sen_pollusonic_2.norm.xml @@ -0,0 +1,23 @@ + + + + + 90919293 + Heat + 16 + 00 + + + + Actual value + kWh + 6531 + + + + Actual value + l + 69 + + + diff --git a/test/test-frames/sen_pollutherm.norm.xml b/test/test-frames/sen_pollutherm.norm.xml new file mode 100644 index 00000000..56b08c30 --- /dev/null +++ b/test/test-frames/sen_pollutherm.norm.xml @@ -0,0 +1,90 @@ + + + + + 21050076 + SPX + 49 + Sensus PolluTherm + Heat: Outlet + 81 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 8640000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 7998.920000 + + + + + + + Instantaneous value + 0 + W + Power + 54580.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 75.500000 + + + + Instantaneous value + 0 + °C + Return temperature + 59.400000 + + + + Instantaneous value + 0 + K + Temperature difference + 16.076000 + + + + Instantaneous value + 0 + + Fabrication No + 21050076.000000 + + + + Instantaneous value + 0 + + Customer location + 21050076.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/siemens_water.norm.xml b/test/test-frames/siemens_water.norm.xml new file mode 100644 index 00000000..895a7a5d --- /dev/null +++ b/test/test-frames/siemens_water.norm.xml @@ -0,0 +1,95 @@ + + + + + 8021382 + LSE + 153 + Siemens WFH21 + Warm water (30-90°C) + 235 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.101000 + + + + Instantaneous value + 0 + s + On time + 75427200.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-09-14T08:56:00Z + + + + Value during error state + 0 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 0 + + Fabrication No + 8021382.000000 + + + + Instantaneous value + 0 + + Device type + 2173253517322.000000 + + + + Instantaneous value + 0 + + Parameter set identification + WFH21 + + + + Instantaneous value + 0 + + Firmware version + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Manufacturer specific + 0 + + + 37 FD 17 00 00 00 00 00 00 00 00 02 7A 0D 00 02 78 0D 00 + + + diff --git a/test/test-frames/siemens_wfh21.norm.xml b/test/test-frames/siemens_wfh21.norm.xml new file mode 100644 index 00000000..afd7f9fc --- /dev/null +++ b/test/test-frames/siemens_wfh21.norm.xml @@ -0,0 +1,103 @@ + + + + + 8006491 + LSE + 153 + Siemens WFH21 + Warm water (30-90°C) + 218 + 00 + 0000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + s + On time + 158709600.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2011-12-01T10:36:00Z + + + + Value during error state + 0 + - + Time point (date) + 2000-00-00 + + + + Instantaneous value + 0 + + Fabrication No + 8006491.000000 + + + + Instantaneous value + 0 + + Device type + 2173253517322.000000 + + + + Instantaneous value + 0 + + Parameter set identification + WFH21 + + + + Instantaneous value + 0 + + Firmware version + 0.000000 + + + + Instantaneous value + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2010-12-31 + + + + Manufacturer specific + 0 + + + 37 FD 17 00 00 00 00 00 00 00 00 02 7A 25 00 02 78 25 00 + + + diff --git a/test/test-frames/sontex_supercal_531_telegram1.norm.xml b/test/test-frames/sontex_supercal_531_telegram1.norm.xml new file mode 100644 index 00000000..be48c61d --- /dev/null +++ b/test/test-frames/sontex_supercal_531_telegram1.norm.xml @@ -0,0 +1,111 @@ + + + + + 8420624 + SON + 13 + Sontex Supercal 531 + Heat: Outlet + 44 + 30 + 0000 + + + + Instantaneous value + 0 + J + Energy + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 0.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 0.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 1 + 0 + 0 + J + Energy + 0.000000 + + + + Instantaneous value + 1 + 0 + 0 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 1 + m^3 + Volume + 0.000000 + + + + Instantaneous value + 1 + 0 + 2 + m^3 + Volume + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/svm_f22_telegram1.norm.xml b/test/test-frames/svm_f22_telegram1.norm.xml new file mode 100644 index 00000000..48b84043 --- /dev/null +++ b/test/test-frames/svm_f22_telegram1.norm.xml @@ -0,0 +1,133 @@ + + + + + 1006089 + SVM + 9 + Elster F4 / Kamstrup SVM F22 + Heat: Inlet + 148 + 70 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 28014000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 640.581000 + + + + Instantaneous value + 0 + 0 + 1 + m^3 + Volume + 640.581000 + + + + Instantaneous value + 0 + °C + Flow temperature + 243.000000 + + + + Instantaneous value + 0 + °C + Return temperature + 243.000000 + + + + Instantaneous value + 0 + K + Temperature difference + 0.000000 + + + + Instantaneous value + 0 + s + On time + 22932000.000000 + + + + Instantaneous value + 0 + s + Operating time + 22906800.000000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2021-02-08T21:12:00Z + + + + Instantaneous value + 0 + 0 + 1 + Units for H.C.A. + H.C.A. + 0.000000 + + + + Instantaneous value + 0 + 0 + 2 + Units for H.C.A. + H.C.A. + 0.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/tch_telegramm1.norm.xml b/test/test-frames/tch_telegramm1.norm.xml new file mode 100644 index 00000000..bdaaa224 --- /dev/null +++ b/test/test-frames/tch_telegramm1.norm.xml @@ -0,0 +1,95 @@ + + + + + 21519982 + TCH + 38 + Techem m-bus S + Heat: Outlet + 133 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 0.000000 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2000-09-29T13:50:00Z + + + + Instantaneous value + 1 + Wh + Energy + 0.000000 + + + + Instantaneous value + 1 + - + Time point (date) + 2000-05-29 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 23.400000 + + + + Instantaneous value + 0 + °C + Return temperature + 22.400000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 0.064000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/wmbus-converted.norm.xml b/test/test-frames/wmbus-converted.norm.xml new file mode 100644 index 00000000..f7a01342 --- /dev/null +++ b/test/test-frames/wmbus-converted.norm.xml @@ -0,0 +1,23 @@ + + + + + 17677731 + KAM + 1 + Kamstrup 382 (6850-005) + Electricity + 0 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 5000.000000 + + + From a7fb39fa23b8d5fe82ae42ee2d37701980ab2e9d Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 14:10:25 +0200 Subject: [PATCH 202/238] Fix VIF descriptions --- mbus/mbus-protocol-aux.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index c932f7e1..8479d063 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -201,10 +201,10 @@ mbus_variable_vif vif_table[] = { { 0x73, 86400.0, "s", "Averaging Duration" }, /* days */ /* E111 01nn Actuality Duration s */ - { 0x74, 1.0, "s", "Averaging Duration" }, /* seconds */ - { 0x75, 60.0, "s", "Averaging Duration" }, /* minutes */ - { 0x76, 3600.0, "s", "Averaging Duration" }, /* hours */ - { 0x77, 86400.0, "s", "Averaging Duration" }, /* days */ + { 0x74, 1.0, "s", "Actuality Duration" }, /* seconds */ + { 0x75, 60.0, "s", "Actuality Duration" }, /* minutes */ + { 0x76, 3600.0, "s", "Actuality Duration" }, /* hours */ + { 0x77, 86400.0, "s", "Actuality Duration" }, /* days */ /* Fabrication No */ { 0x78, 1.0, "", "Fabrication No" }, @@ -247,7 +247,7 @@ mbus_variable_vif vif_table[] = { { 0x108, 1.0e0, "", "Access Number (transmission count)" }, /* E000 1001 Medium (as in fixed header) */ - { 0x109, 1.0e0, "", "Device type" }, + { 0x109, 1.0e0, "", "Medium" }, /* E000 1010 Manufacturer (as in fixed header) */ { 0x10A, 1.0e0, "", "Manufacturer" }, @@ -256,7 +256,7 @@ mbus_variable_vif vif_table[] = { { 0x10B, 1.0e0, "", "Parameter set identification" }, /* E000 1100 Model / Version */ - { 0x10C, 1.0e0, "", "Device type" }, + { 0x10C, 1.0e0, "", "Model / Version" }, /* E000 1101 Hardware version # */ { 0x10D, 1.0e0, "", "Hardware version" }, @@ -356,9 +356,9 @@ mbus_variable_vif vif_table[] = { { 0x130, 1.0e0, "Reserved", "Reserved" }, /* ???? */ /* E011 00nn Duration of tariff (nn=01 ..11: min to days) */ - { 0x131, 60.0, "s", "Storage interval" }, /* minute(s) */ - { 0x132, 3600.0, "s", "Storage interval" }, /* hour(s) */ - { 0x133, 86400.0, "s", "Storage interval" }, /* day(s) */ + { 0x131, 60.0, "s", "Duration of tariff" }, /* minute(s) */ + { 0x132, 3600.0, "s", "Duration of tariff" }, /* hour(s) */ + { 0x133, 86400.0, "s", "Duration of tariff" }, /* day(s) */ /* E011 01nn Period of tariff [sec(s) to day(s)] */ { 0x134, 1.0, "s", "Period of tariff" }, /* seconds */ From d0406df92a238741c2d6842ef8d7ea47370ab593 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 6 Jul 2020 14:13:27 +0200 Subject: [PATCH 203/238] Update normalized XML files This updates the affected XML files after the recent fixes to the VIF description. --- test/test-frames/landis+gyr_ultraheat_t230.norm.xml | 2 +- test/test-frames/metrona_ultraheat_xs.norm.xml | 2 +- test/test-frames/minol_minocal_wr3.norm.xml | 4 ++-- test/test-frames/siemens_water.norm.xml | 2 +- test/test-frames/siemens_wfh21.norm.xml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml index d30f1cd5..70309869 100644 --- a/test/test-frames/landis+gyr_ultraheat_t230.norm.xml +++ b/test/test-frames/landis+gyr_ultraheat_t230.norm.xml @@ -16,7 +16,7 @@ Instantaneous value 0 s - Averaging Duration + Actuality Duration 4.000000 diff --git a/test/test-frames/metrona_ultraheat_xs.norm.xml b/test/test-frames/metrona_ultraheat_xs.norm.xml index 82423fe9..55779d2c 100644 --- a/test/test-frames/metrona_ultraheat_xs.norm.xml +++ b/test/test-frames/metrona_ultraheat_xs.norm.xml @@ -16,7 +16,7 @@ Instantaneous value 0 s - Averaging Duration + Actuality Duration 4.000000 diff --git a/test/test-frames/minol_minocal_wr3.norm.xml b/test/test-frames/minol_minocal_wr3.norm.xml index 19ddead9..6db54925 100644 --- a/test/test-frames/minol_minocal_wr3.norm.xml +++ b/test/test-frames/minol_minocal_wr3.norm.xml @@ -132,7 +132,7 @@ 0 1 - Device type + Medium 7.000000 @@ -182,7 +182,7 @@ 0 2 - Device type + Medium 7.000000 diff --git a/test/test-frames/siemens_water.norm.xml b/test/test-frames/siemens_water.norm.xml index 895a7a5d..a49f1d3a 100644 --- a/test/test-frames/siemens_water.norm.xml +++ b/test/test-frames/siemens_water.norm.xml @@ -56,7 +56,7 @@ Instantaneous value 0 - Device type + Model / Version 2173253517322.000000 diff --git a/test/test-frames/siemens_wfh21.norm.xml b/test/test-frames/siemens_wfh21.norm.xml index afd7f9fc..cac68af0 100644 --- a/test/test-frames/siemens_wfh21.norm.xml +++ b/test/test-frames/siemens_wfh21.norm.xml @@ -56,7 +56,7 @@ Instantaneous value 0 - Device type + Model / Version 2173253517322.000000 From 8fe42f9ede656f5dfd1c23682e7afb0afe851bc3 Mon Sep 17 00:00:00 2001 From: Anders Wennmo Date: Thu, 4 Jun 2020 12:35:58 +0200 Subject: [PATCH 204/238] Implement all of VIF extensions for 0xFD (#166) --- mbus/mbus-protocol.c | 453 ++++++++++++++---- .../EMU_EMU-Professional-375-M-Bus.xml | 2 +- test/test-frames/LGB_G350.xml | 2 +- 3 files changed, 363 insertions(+), 94 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 311abbba..0d813a20 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2438,6 +2438,356 @@ mbus_data_error_lookup(int error) return buff; } +static const char * +mbus_unit_duration_nn(int nn) +{ + switch (nn) + { + case 0: + return "second(s)"; + case 1: + return "minute(s)"; + case 2: + return "hour(s)"; + case 3: + return "day(s)"; + } + return "error: out-of-range"; +} + +static const char * +mbus_unit_duration_pp(int pp) +{ + switch (pp) + { + case 0: + return "hour(s)"; + + case 1: + return "day(s)"; + + case 2: + return "month(s)"; + + case 3: + return "year(s)"; + } + return "error: out-of-range"; +} + +static const char * +mbus_vib_unit_lookup_fb(mbus_value_information_block *vib) +{ + static char buff[256]; + snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0xFB,0x%.2X", vib->vife[0]); + return buff; +} + +static const char * +mbus_vib_unit_lookup_fd(mbus_value_information_block *vib) +{ + static char buff[256]; + int n; + + // ignore the extension bit in this selection + const unsigned char masked_vife0 = vib->vife[0] & MBUS_DIB_VIF_WITHOUT_EXTENSION; + + if ((masked_vife0 & 0x7C) == 0x00) + { + // VIFE = E000 00nn Credit of 10nn-3 of the nominal local legal currency units + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Credit of %s of the nominal local legal currency units", mbus_unit_prefix(n - 3)); + } + else if ((masked_vife0 & 0x7C) == 0x04) + { + // VIFE = E000 01nn Debit of 10nn-3 of the nominal local legal currency units + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Debit of %s of the nominal local legal currency units", mbus_unit_prefix(n - 3)); + } + else if (masked_vife0 == 0x08) + { + // E000 1000 + snprintf(buff, sizeof(buff), "Access Number (transmission count)"); + } + else if (masked_vife0 == 0x09) + { + // E000 1001 + snprintf(buff, sizeof(buff), "Medium (as in fixed header)"); + } + else if (masked_vife0 == 0x0A) + { + // E000 1010 + snprintf(buff, sizeof(buff), "Manufacturer (as in fixed header)"); + } + else if (masked_vife0 == 0x0B) + { + // E000 1010 + snprintf(buff, sizeof(buff), "Parameter set identification"); + } + else if (masked_vife0 == 0x0C) + { + // E000 1100 + snprintf(buff, sizeof(buff), "Model / Version"); + } + else if (masked_vife0 == 0x0D) + { + // E000 1100 + snprintf(buff, sizeof(buff), "Hardware version"); + } + else if (masked_vife0 == 0x0E) + { + // E000 1101 + snprintf(buff, sizeof(buff), "Firmware version"); + } + else if (masked_vife0 == 0x0F) + { + // E000 1101 + snprintf(buff, sizeof(buff), "Software version"); + } + else if (masked_vife0 == 0x10) + { + // VIFE = E001 0000 Customer location + snprintf(buff, sizeof(buff), "Customer location"); + } + else if (masked_vife0 == 0x11) + { + // VIFE = E001 0001 Customer + snprintf(buff, sizeof(buff), "Customer"); + } + else if (masked_vife0 == 0x12) + { + // VIFE = E001 0010 Access Code User + snprintf(buff, sizeof(buff), "Access Code User"); + } + else if (masked_vife0 == 0x13) + { + // VIFE = E001 0011 Access Code Operator + snprintf(buff, sizeof(buff), "Access Code Operator"); + } + else if (masked_vife0 == 0x14) + { + // VIFE = E001 0100 Access Code System Operator + snprintf(buff, sizeof(buff), "Access Code System Operator"); + } + else if (masked_vife0 == 0x15) + { + // VIFE = E001 0101 Access Code Developer + snprintf(buff, sizeof(buff), "Access Code Developer"); + } + else if (masked_vife0 == 0x16) + { + // VIFE = E001 0110 Password + snprintf(buff, sizeof(buff), "Password"); + } + else if (masked_vife0 == 0x17) + { + // VIFE = E001 0111 Error flags + snprintf(buff, sizeof(buff), "Error flags"); + } + else if (masked_vife0 == 0x18) + { + // VIFE = E001 1000 Error mask + snprintf(buff, sizeof(buff), "Error mask"); + } + else if (masked_vife0 == 0x19) + { + // VIFE = E001 1001 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x1A) + { + // VIFE = E001 1010 Digital output (binary) + snprintf(buff, sizeof(buff), "Digital output (binary)"); + } + else if (masked_vife0 == 0x1B) + { + // VIFE = E001 1011 Digital input (binary) + snprintf(buff, sizeof(buff), "Digital input (binary)"); + } + else if (masked_vife0 == 0x1C) + { + // VIFE = E001 1100 Baudrate [Baud] + snprintf(buff, sizeof(buff), "Baudrate"); + } + else if (masked_vife0 == 0x1D) + { + // VIFE = E001 1101 response delay time [bittimes] + snprintf(buff, sizeof(buff), "response delay time"); + } + else if (masked_vife0 == 0x1E) + { + // VIFE = E001 1110 Retry + snprintf(buff, sizeof(buff), "Retry"); + } + else if (masked_vife0 == 0x1F) + { + // VIFE = E001 1111 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x20) + { + // VIFE = E010 0000 First storage # for cyclic storage + snprintf(buff, sizeof(buff), "First storage # for cyclic storage"); + } + else if (masked_vife0 == 0x21) + { + // VIFE = E010 0001 Last storage # for cyclic storage + snprintf(buff, sizeof(buff), "Last storage # for cyclic storage"); + } + else if (masked_vife0 == 0x22) + { + // VIFE = E010 0010 Size of storage block + snprintf(buff, sizeof(buff), "Size of storage block"); + } + else if (masked_vife0 == 0x23) + { + // VIFE = E010 0011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x24) + { + // VIFE = E010 01nn Storage interval [sec(s)..day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Storage interval %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x28) + { + // VIFE = E010 1000 Storage interval month(s) + snprintf(buff, sizeof(buff), "Storage interval month(s)"); + } + else if (masked_vife0 == 0x29) + { + // VIFE = E010 1001 Storage interval year(s) + snprintf(buff, sizeof(buff), "Storage interval year(s)"); + } + else if (masked_vife0 == 0x2A) + { + // VIFE = E010 1010 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if (masked_vife0 == 0x2B) + { + // VIFE = E010 1011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x2C) + { + // VIFE = E010 11nn Duration since last readout [sec(s)..day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration since last readout %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x30) + { + // VIFE = E011 0000 Start (date/time) of tariff + snprintf(buff, sizeof(buff), "Start (date/time) of tariff"); + } + else if ((masked_vife0 & 0x7C) == 0x30) + { + // VIFE = E011 00nn Duration of tariff (nn=01 ..11: min to days) + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration of tariff %s", mbus_unit_duration_nn(n)); + } + else if ((masked_vife0 & 0x7C) == 0x34) + { + // VIFE = E011 01nn Period of tariff [sec(s) to day(s)] + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Period of tariff %s", mbus_unit_duration_nn(n)); + } + else if (masked_vife0 == 0x38) + { + // VIFE = E011 1000 Period of tariff months(s) + snprintf(buff, sizeof(buff), "Period of tariff months(s)"); + } + else if (masked_vife0 == 0x39) + { + // VIFE = E011 1001 Period of tariff year(s) + snprintf(buff, sizeof(buff), "Period of tariff year(s)"); + } + else if (masked_vife0 == 0x3A) + { + // VIFE = E011 1010 dimensionless / no VIF + snprintf(buff, sizeof(buff), "dimensionless / no VIF"); + } + else if (masked_vife0 == 0x3B) + { + // VIFE = E011 1011 Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x7C) == 0x3C) + { + // VIFE = E011 11xx Reserved + snprintf(buff, sizeof(buff), "Reserved"); + } + else if ((masked_vife0 & 0x70) == 0x40) + { + // VIFE = E100 nnnn 10^(nnnn-9) V + n = (masked_vife0 & 0x0F); + snprintf(buff, sizeof(buff), "%s V", mbus_unit_prefix(n - 9)); + } + else if ((masked_vife0 & 0x70) == 0x50) + { + // VIFE = E101 nnnn 10nnnn-12 A + n = (masked_vife0 & 0x0F); + snprintf(buff, sizeof(buff), "%s A", mbus_unit_prefix(n - 12)); + } + else if (masked_vife0 == 0x60) { + // VIFE = E110 0000 Reset counter + snprintf(buff, sizeof(buff), "Reset counter"); + } + else if (masked_vife0 == 0x61) { + // VIFE = E110 0001 Cumulation counter + snprintf(buff, sizeof(buff), "Cumulation counter"); + } + else if (masked_vife0 == 0x62) { + // VIFE = E110 0010 Control signal + snprintf(buff, sizeof(buff), "Control signal"); + } + else if (masked_vife0 == 0x63) { + // VIFE = E110 0011 Day of week + snprintf(buff, sizeof(buff), "Day of week"); + } + else if (masked_vife0 == 0x64) { + // VIFE = E110 0100 Week number + snprintf(buff, sizeof(buff), "Week number"); + } + else if (masked_vife0 == 0x65) { + // VIFE = E110 0101 Time point of day change + snprintf(buff, sizeof(buff), "Time point of day change"); + } + else if (masked_vife0 == 0x66) { + // VIFE = E110 0110 State of parameter activation + snprintf(buff, sizeof(buff), "State of parameter activation"); + } + else if (masked_vife0 == 0x67) { + // VIFE = E110 0111 Special supplier information + snprintf(buff, sizeof(buff), "Special supplier information"); + } + else if ((masked_vife0 & 0x7C) == 0x68) { + // VIFE = E110 10pp Duration since last cumulation [hour(s)..years(s)]Ž + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Duration since last cumulation %s", mbus_unit_duration_pp(n)); + } + else if ((masked_vife0 & 0x7C) == 0x6C) { + // VIFE = E110 11pp Operating time battery [hour(s)..years(s)]Ž + n = (masked_vife0 & 0x03); + snprintf(buff, sizeof(buff), "Operating time battery %s", mbus_unit_duration_pp(n)); + } + else if (masked_vife0 == 0x70) { + // VIFE = E111 0000 Date and time of battery change + snprintf(buff, sizeof(buff), "Date and time of battery change"); + } + else if ((masked_vife0 & 0x70) == 0x70) + { + // VIFE = E111 nnn Reserved + snprintf(buff, sizeof(buff), "Reserved VIF extension"); + } + else + { + snprintf(buff, sizeof(buff), "Unrecognized VIF 0xFD extension: 0x%.2x", masked_vife0); + } + + return buff; +} //------------------------------------------------------------------------------ /// Lookup the unit from the VIB (VIF or VIFE) @@ -2461,104 +2811,23 @@ mbus_vib_unit_lookup(mbus_value_information_block *vib) if (vib == NULL) return ""; - if (vib->vif == 0xFD || vib->vif == 0xFB) // first type of VIF extention: see table 8.4.4 + if (vib->vif == 0xFB) // first type of VIF extention: see table 8.4.4 { if (vib->nvife == 0) { - snprintf(buff, sizeof(buff), "Missing VIF extension"); - } - else if (vib->vife[0] == 0x08 || vib->vife[0] == 0x88) - { - // E000 1000 - snprintf(buff, sizeof(buff), "Access Number (transmission count)"); - } - else if (vib->vife[0] == 0x09|| vib->vife[0] == 0x89) - { - // E000 1001 - snprintf(buff, sizeof(buff), "Medium (as in fixed header)"); - } - else if (vib->vife[0] == 0x0A || vib->vife[0] == 0x8A) - { - // E000 1010 - snprintf(buff, sizeof(buff), "Manufacturer (as in fixed header)"); - } - else if (vib->vife[0] == 0x0B || vib->vife[0] == 0x8B) - { - // E000 1010 - snprintf(buff, sizeof(buff), "Parameter set identification"); + return "Missing VIF extension"; } - else if (vib->vife[0] == 0x0C || vib->vife[0] == 0x8C) - { - // E000 1100 - snprintf(buff, sizeof(buff), "Model / Version"); - } - else if (vib->vife[0] == 0x0D || vib->vife[0] == 0x8D) - { - // E000 1100 - snprintf(buff, sizeof(buff), "Hardware version"); - } - else if (vib->vife[0] == 0x0E || vib->vife[0] == 0x8E) - { - // E000 1101 - snprintf(buff, sizeof(buff), "Firmware version"); - } - else if (vib->vife[0] == 0x0F || vib->vife[0] == 0x8F) - { - // E000 1101 - snprintf(buff, sizeof(buff), "Software version"); - } - else if (vib->vife[0] == 0x16) - { - // VIFE = E001 0110 Password - snprintf(buff, sizeof(buff), "Password"); - } - else if (vib->vife[0] == 0x17 || vib->vife[0] == 0x97) - { - // VIFE = E001 0111 Error flags - snprintf(buff, sizeof(buff), "Error flags"); - } - else if (vib->vife[0] == 0x10) - { - // VIFE = E001 0000 Customer location - snprintf(buff, sizeof(buff), "Customer location"); - } - else if (vib->vife[0] == 0x11) - { - // VIFE = E001 0001 Customer - snprintf(buff, sizeof(buff), "Customer"); - } - else if (vib->vife[0] == 0x1A) - { - // VIFE = E001 1010 Digital output (binary) - snprintf(buff, sizeof(buff), "Digital output (binary)"); - } - else if (vib->vife[0] == 0x1B) - { - // VIFE = E001 1011 Digital input (binary) - snprintf(buff, sizeof(buff), "Digital input (binary)"); - } - else if ((vib->vife[0] & 0x70) == 0x40) - { - // VIFE = E100 nnnn 10^(nnnn-9) V - n = (vib->vife[0] & 0x0F); - snprintf(buff, sizeof(buff), "%s V", mbus_unit_prefix(n-9)); - } - else if ((vib->vife[0] & 0x70) == 0x50) - { - // VIFE = E101 nnnn 10nnnn-12 A - n = (vib->vife[0] & 0x0F); - snprintf(buff, sizeof(buff), "%s A", mbus_unit_prefix(n-12)); - } - else if ((vib->vife[0] & 0xF0) == 0x70) - { - // VIFE = E111 nnn Reserved - snprintf(buff, sizeof(buff), "Reserved VIF extension"); - } - else + + return mbus_vib_unit_lookup_fb(vib); + } + else if (vib->vif == 0xFD) // first type of VIF extention: see table 8.4.4 + { + if (vib->nvife == 0) { - snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0x%.2x", vib->vife[0]); + return "Missing VIF extension"; } - return buff; + + return mbus_vib_unit_lookup_fd(vib); } else if (vib->vif == 0x7C) { diff --git a/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml b/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml index 8b34fc2f..363ee2b4 100644 --- a/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml +++ b/test/test-frames/EMU_EMU-Professional-375-M-Bus.xml @@ -241,7 +241,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x60 + Reset counter 56 diff --git a/test/test-frames/LGB_G350.xml b/test/test-frames/LGB_G350.xml index d75231c6..45ef288d 100644 --- a/test/test-frames/LGB_G350.xml +++ b/test/test-frames/LGB_G350.xml @@ -52,7 +52,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x67 + Special supplier information 15 From 8d049910f7fd1fbe71c642a3fa3575c7d0ea3076 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Tue, 7 Jul 2020 14:44:35 +0200 Subject: [PATCH 205/238] Implement all of VIF extensions for 0xFB (#166) --- mbus/mbus-protocol.c | 245 ++++++++++++++++++++- test/test-frames/engelmann_sensostar2c.xml | 18 +- 2 files changed, 253 insertions(+), 10 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 0d813a20..80eb45cc 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -2479,7 +2479,250 @@ static const char * mbus_vib_unit_lookup_fb(mbus_value_information_block *vib) { static char buff[256]; - snprintf(buff, sizeof(buff), "Unrecognized VIF extension: 0xFB,0x%.2X", vib->vife[0]); + int n; + const char * prefix = ""; + switch (vib->vife[0] & MBUS_DIB_VIF_WITHOUT_EXTENSION) + { + case 0x0: + case 0x0 + 1: + // E000 000n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Energy (%sMWh)", prefix); + break; + case 0x2: + case 0x2 + 1: + // E000 001n + case 0x4: + case 0x4 + 1: + case 0x4 + 2: + case 0x4 + 3: + // E000 01nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x8: + case 0x8 + 1: + // E000 100n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Energy (%sGJ)", prefix); + break; + case 0xA: + case 0xA + 1: + case 0xC: + case 0xC + 1: + case 0xC + 2: + case 0xC + 3: + // E000 101n + // E000 11nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x10: + case 0x10 + 1: + // E001 000n + n = 0x01 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Volume (%sm3)", mbus_unit_prefix(n+2)); + break; + case 0x12: + case 0x12 + 1: + case 0x14: + case 0x14 + 1: + case 0x14 + 2: + case 0x14 + 3: + // E001 001n + // E001 01nn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x18: + case 0x18 + 1: + // E001 100n + n = 0x01 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Mass (%st)", mbus_unit_prefix(n+2)); + break; + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x20: + // E001 1010 to E010 0000, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x21: + // E010 0001 + snprintf(buff, sizeof(buff), "Volume (0.1 feet^3)"); + break; + case 0x22: + case 0x23: + // E010 0010 + // E010 0011 + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Volume (%samerican gallon)", prefix); + break; + + case 0x24: + // E010 0100 + snprintf(buff, sizeof(buff), "Volume flow (0.001 american gallon/min)"); + break; + case 0x25: + // E010 0101 + snprintf(buff, sizeof(buff), "Volume flow (american gallon/min)"); + break; + case 0x26: + // E010 0110 + snprintf(buff, sizeof(buff), "Volume flow (american gallon/h)"); + break; + case 0x27: + // E010 0111, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x28: + case 0x28 + 1: + // E010 100n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Power (%sMW)", prefix); + break; + case 0x2A: + case 0x2A + 1: + case 0x2C: + case 0x2C + 1: + case 0x2C + 2: + case 0x2C + 3: + // E010 101n, Reserved + // E010 11nn, Reserved + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x30: + case 0x30 + 1: + // E011 000n + n = 0x01 & vib->vife[0]; + if (n == 0) + prefix = "0.1 "; + snprintf(buff, sizeof(buff), "Power (%sGJ/h)", prefix); + break; + case 0x32: + case 0x33: + case 0x34: + case 0x35: + case 0x36: + case 0x37: + case 0x38: + case 0x39: + case 0x3A: + case 0x3B: + case 0x3C: + case 0x3D: + case 0x3E: + case 0x3F: + + case 0x40: + case 0x41: + case 0x42: + case 0x43: + case 0x44: + case 0x45: + case 0x46: + case 0x47: + case 0x48: + case 0x49: + case 0x4A: + case 0x4B: + case 0x4C: + case 0x4D: + case 0x4E: + case 0x4F: + + case 0x52: + case 0x53: + case 0x54: + case 0x55: + case 0x56: + case 0x57: + // E011 0010 to E101 0111 + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x58: + case 0x58 + 1: + case 0x58 + 2: + case 0x58 + 3: + // E101 10nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Flow Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x5C: + case 0x5C + 1: + case 0x5C + 2: + case 0x5C + 3: + // E101 11nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Return Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x60: + case 0x60 + 1: + case 0x60 + 2: + case 0x60 + 3: + // E110 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Temperature Difference (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x64: + case 0x64 + 1: + case 0x64 + 2: + case 0x64 + 3: + // E110 01nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "External Temperature (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x68: + case 0x69: + case 0x6A: + case 0x6B: + case 0x6C: + case 0x6D: + case 0x6E: + case 0x6F: + // E110 1nnn + snprintf(buff, sizeof(buff), "Reserved (0x%.2x)", vib->vife[0]); + break; + case 0x70: + case 0x70 + 1: + case 0x70 + 2: + case 0x70 + 3: + // E111 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Cold / Warm Temperature Limit (%s degree F)", mbus_unit_prefix(n -3)); + break; + case 0x74: + case 0x74 + 1: + case 0x74 + 2: + case 0x74 + 3: + // E111 00nn + n = 0x03 & vib->vife[0]; + snprintf(buff, sizeof(buff), "Cold / Warm Temperature Limit (%s degree C)", mbus_unit_prefix(n -3)); + break; + case 0x78: + case 0x78 + 1: + case 0x78 + 2: + case 0x78 + 3: + case 0x78 + 4: + case 0x78 + 5: + case 0x78 + 6: + case 0x78 + 7: + // E111 1nnn + n = 0x07 & vib->vife[0]; + snprintf(buff, sizeof(buff), "cumul. count max power (%s W)", mbus_unit_prefix(n - 3)); + break; + default: + snprintf(buff, sizeof(buff), "Unrecognized VIF 0xFB extension: 0x%.2x", vib->vife[0]); + break; + } return buff; } diff --git a/test/test-frames/engelmann_sensostar2c.xml b/test/test-frames/engelmann_sensostar2c.xml index c8476339..b33e52e8 100644 --- a/test/test-frames/engelmann_sensostar2c.xml +++ b/test/test-frames/engelmann_sensostar2c.xml @@ -36,7 +36,7 @@ Instantaneous value 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 8 @@ -45,7 +45,7 @@ 0 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -54,7 +54,7 @@ 0 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -131,7 +131,7 @@ Instantaneous value 1 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 8 @@ -140,7 +140,7 @@ 1 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -149,7 +149,7 @@ 1 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -176,7 +176,7 @@ 2 0 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 5 @@ -185,7 +185,7 @@ 2 2 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 @@ -194,7 +194,7 @@ 2 3 0 - Unrecognized VIF extension: 0x00 + Energy (0.1 MWh) 0 From 36a4fbd02199fc53ea012ed9532850a276af9536 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 11:44:17 +0200 Subject: [PATCH 206/238] Improve product strings for Aquametro and Sensus --- mbus/mbus-protocol.c | 28 +++++++++++++++-------- test/test-frames/example_data_01.norm.xml | 2 +- test/test-frames/example_data_01.xml | 2 +- test/test-frames/example_data_02.norm.xml | 2 +- test/test-frames/example_data_02.xml | 2 +- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 80eb45cc..93123644 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -955,14 +955,21 @@ mbus_data_product_name(mbus_data_variable_header *header) } else if (manufacturer == mbus_manufacturer_id("AMT")) { - switch (header->version) + if (header->version >= 0xC0) { - case 0x80: - strcpy(buff,"Aquametro CALEC MB"); - break; - case 0xC0: - strcpy(buff,"Aquametro CALEC ST"); - break; + strcpy(buff,"Aquametro CALEC ST"); + } + else if (header->version >= 0x80) + { + strcpy(buff,"Aquametro CALEC MB"); + } + else if (header->version >= 0x40) + { + strcpy(buff,"Aquametro SAPHIR"); + } + else + { + strcpy(buff,"Aquametro AMTRON"); } } else if (manufacturer == mbus_manufacturer_id("BEC")) @@ -1266,15 +1273,16 @@ mbus_data_product_name(mbus_data_variable_header *header) { switch (header->version) { + case 0x08: + case 0x19: + strcpy(buff,"Sensus PolluCom E"); + break; case 0x0B: strcpy(buff,"Sensus PolluTherm"); break; case 0x0E: strcpy(buff,"Sensus PolluStat E"); break; - case 0x19: - strcpy(buff,"Sensus PolluCom E"); - break; } } else if (manufacturer == mbus_manufacturer_id("SON")) diff --git a/test/test-frames/example_data_01.norm.xml b/test/test-frames/example_data_01.norm.xml index 54ba0bb1..587ce57e 100644 --- a/test/test-frames/example_data_01.norm.xml +++ b/test/test-frames/example_data_01.norm.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 158 00 diff --git a/test/test-frames/example_data_01.xml b/test/test-frames/example_data_01.xml index dbfede82..a344e785 100644 --- a/test/test-frames/example_data_01.xml +++ b/test/test-frames/example_data_01.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 158 00 diff --git a/test/test-frames/example_data_02.norm.xml b/test/test-frames/example_data_02.norm.xml index d135aae2..87022161 100644 --- a/test/test-frames/example_data_02.norm.xml +++ b/test/test-frames/example_data_02.norm.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 161 00 diff --git a/test/test-frames/example_data_02.xml b/test/test-frames/example_data_02.xml index ad6236fc..fda38dfc 100644 --- a/test/test-frames/example_data_02.xml +++ b/test/test-frames/example_data_02.xml @@ -5,7 +5,7 @@ 3575845 AMT 52 - + Aquametro AMTRON Heat: Outlet 161 00 From 7b10dc2fd4d1cf33bb6c008dec3c182567276e64 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 11:47:54 +0200 Subject: [PATCH 207/238] Add more test frames Aquametro CALEC MB (Heat) Eastron SDM630 (Electricity) Sensus PolluCom E (Heat) Tecson (Oil) --- test/test-frames/amt_calec_mb.hex | 1 + test/test-frames/amt_calec_mb.norm.xml | 71 ++++++++ test/test-frames/amt_calec_mb.xml | 64 ++++++++ test/test-frames/eastron_sdm630.hex | 1 + test/test-frames/eastron_sdm630.norm.xml | 199 +++++++++++++++++++++++ test/test-frames/eastron_sdm630.xml | 176 ++++++++++++++++++++ test/test-frames/sen_pollucom_e.hex | 1 + test/test-frames/sen_pollucom_e.norm.xml | 95 +++++++++++ test/test-frames/sen_pollucom_e.xml | 83 ++++++++++ test/test-frames/tecson.hex | 1 + test/test-frames/tecson.norm.xml | 41 +++++ test/test-frames/tecson.xml | 38 +++++ 12 files changed, 771 insertions(+) create mode 100644 test/test-frames/amt_calec_mb.hex create mode 100644 test/test-frames/amt_calec_mb.norm.xml create mode 100644 test/test-frames/amt_calec_mb.xml create mode 100644 test/test-frames/eastron_sdm630.hex create mode 100644 test/test-frames/eastron_sdm630.norm.xml create mode 100644 test/test-frames/eastron_sdm630.xml create mode 100644 test/test-frames/sen_pollucom_e.hex create mode 100644 test/test-frames/sen_pollucom_e.norm.xml create mode 100644 test/test-frames/sen_pollucom_e.xml create mode 100644 test/test-frames/tecson.hex create mode 100644 test/test-frames/tecson.norm.xml create mode 100644 test/test-frames/tecson.xml diff --git a/test/test-frames/amt_calec_mb.hex b/test/test-frames/amt_calec_mb.hex new file mode 100644 index 00000000..942b40d0 --- /dev/null +++ b/test/test-frames/amt_calec_mb.hex @@ -0,0 +1 @@ +68 38 38 68 08 C8 72 09 31 54 03 B4 05 B0 04 C9 10 FF FF 03 22 9A 00 00 05 2E A0 C8 51 46 05 3E B4 E3 D7 42 05 5B 90 D3 07 43 05 5F 0E AA E7 41 05 63 9C BC D5 42 04 6D 10 09 05 C5 77 16 diff --git a/test/test-frames/amt_calec_mb.norm.xml b/test/test-frames/amt_calec_mb.norm.xml new file mode 100644 index 00000000..4eef3de4 --- /dev/null +++ b/test/test-frames/amt_calec_mb.norm.xml @@ -0,0 +1,71 @@ + + + + + 3543109 + AMT + 176 + Aquametro CALEC MB + Heat: Outlet + 201 + 10 + FFFF + + + + Instantaneous value + 0 + s + On time + 554400.000000 + + + + Instantaneous value + 0 + W + Power + 13426156.250000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 107.944733 + + + + Instantaneous value + 0 + °C + Flow temperature + 135.826416 + + + + Instantaneous value + 0 + °C + Return temperature + 28.958035 + + + + Instantaneous value + 0 + K + Temperature difference + 106.868378 + + + + Instantaneous value + 0 + - + Time point (date & time) + 2096-05-05T09:16:00Z + + + diff --git a/test/test-frames/amt_calec_mb.xml b/test/test-frames/amt_calec_mb.xml new file mode 100644 index 00000000..6e4ab730 --- /dev/null +++ b/test/test-frames/amt_calec_mb.xml @@ -0,0 +1,64 @@ + + + + + 3543109 + AMT + 176 + Aquametro CALEC MB + Heat: Outlet + 201 + 10 + FFFF + + + + Instantaneous value + 0 + On time (hours) + 154 + + + + Instantaneous value + 0 + Power (kW) + 13426.156250 + + + + Instantaneous value + 0 + Volume flow ( m^3/h) + 107.944733 + + + + Instantaneous value + 0 + Flow temperature (deg C) + 135.826416 + + + + Instantaneous value + 0 + Return temperature (deg C) + 28.958035 + + + + Instantaneous value + 0 + Temperature Difference ( deg C) + 106.868378 + + + + Instantaneous value + 0 + Time Point (time & date) + 2096-05-05T09:16:00 + + + diff --git a/test/test-frames/eastron_sdm630.hex b/test/test-frames/eastron_sdm630.hex new file mode 100644 index 00000000..5666f2e1 --- /dev/null +++ b/test/test-frames/eastron_sdm630.hex @@ -0,0 +1 @@ +68 90 90 68 08 0A 72 78 65 34 21 24 40 01 02 55 00 00 00 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 47 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B FD 59 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B 2A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0B FD 3A 56 34 12 0A FD 3A 00 05 0A FD 3A 05 00 0A FD 3A 05 00 0A FD 3A 05 00 0A FD 3A 50 00 4D 16 diff --git a/test/test-frames/eastron_sdm630.norm.xml b/test/test-frames/eastron_sdm630.norm.xml new file mode 100644 index 00000000..f3fbbeb1 --- /dev/null +++ b/test/test-frames/eastron_sdm630.norm.xml @@ -0,0 +1,199 @@ + + + + + 21346578 + PAD + 1 + + Electricity + 85 + 00 + 0000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + V + Voltage + 1234.560000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + A + Current + 123.456000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + W + Power + 12345.600000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 123456.000000 + + + + Instantaneous value + 0 + + Dimensionless + 500.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 5.000000 + + + + Instantaneous value + 0 + + Dimensionless + 50.000000 + + + diff --git a/test/test-frames/eastron_sdm630.xml b/test/test-frames/eastron_sdm630.xml new file mode 100644 index 00000000..2de43526 --- /dev/null +++ b/test/test-frames/eastron_sdm630.xml @@ -0,0 +1,176 @@ + + + + + 21346578 + PAD + 1 + + Electricity + 85 + 00 + 0000 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + 1e-2 V + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + m A + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + Power (1e-1 W) + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 123456 + + + + Instantaneous value + 0 + dimensionless / no VIF + 500 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 5 + + + + Instantaneous value + 0 + dimensionless / no VIF + 50 + + + diff --git a/test/test-frames/sen_pollucom_e.hex b/test/test-frames/sen_pollucom_e.hex new file mode 100644 index 00000000..76f0a877 --- /dev/null +++ b/test/test-frames/sen_pollucom_e.hex @@ -0,0 +1 @@ +68 42 42 68 08 00 72 45 00 94 63 AE 4C 08 04 F9 00 00 00 0C 06 19 90 01 00 0C 13 19 11 62 01 0C 3B 00 00 00 00 0C 2B 00 00 00 00 02 5A 67 01 02 5E E9 00 03 60 46 31 00 0C 78 45 00 94 63 0C FD 10 45 00 94 63 1F B6 16 diff --git a/test/test-frames/sen_pollucom_e.norm.xml b/test/test-frames/sen_pollucom_e.norm.xml new file mode 100644 index 00000000..1c79a730 --- /dev/null +++ b/test/test-frames/sen_pollucom_e.norm.xml @@ -0,0 +1,95 @@ + + + + + 63940045 + SEN + 8 + Sensus PolluCom E + Heat: Outlet + 249 + 00 + 0000 + + + + Instantaneous value + 0 + Wh + Energy + 19019000.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 1621.119000 + + + + Instantaneous value + 0 + m^3/h + Volume flow + 0.000000 + + + + Instantaneous value + 0 + W + Power + 0.000000 + + + + Instantaneous value + 0 + °C + Flow temperature + 35.900000 + + + + Instantaneous value + 0 + °C + Return temperature + 23.300000 + + + + Instantaneous value + 0 + K + Temperature difference + 12.614000 + + + + Instantaneous value + 0 + + Fabrication No + 63940045.000000 + + + + Instantaneous value + 0 + + Customer location + 63940045.000000 + + + + More records follow + 0 + + + + + + diff --git a/test/test-frames/sen_pollucom_e.xml b/test/test-frames/sen_pollucom_e.xml new file mode 100644 index 00000000..1c3653bb --- /dev/null +++ b/test/test-frames/sen_pollucom_e.xml @@ -0,0 +1,83 @@ + + + + + 63940045 + SEN + 8 + Sensus PolluCom E + Heat: Outlet + 249 + 00 + 0000 + + + + Instantaneous value + 0 + Energy (kWh) + 19019 + + + + Instantaneous value + 0 + Volume (m m^3) + 1621119 + + + + Instantaneous value + 0 + Volume flow (m m^3/h) + 0 + + + + Instantaneous value + 0 + Power (W) + 0 + + + + Instantaneous value + 0 + Flow temperature (1e-1 deg C) + 359 + + + + Instantaneous value + 0 + Return temperature (1e-1 deg C) + 233 + + + + Instantaneous value + 0 + Temperature Difference (m deg C) + 12614 + + + + Instantaneous value + 0 + Fabrication number + 63940045 + + + + Instantaneous value + 0 + Customer location + 63940045 + + + + More records follow + + + + diff --git a/test/test-frames/tecson.hex b/test/test-frames/tecson.hex new file mode 100644 index 00000000..2f082269 --- /dev/null +++ b/test/test-frames/tecson.hex @@ -0,0 +1 @@ +68 1B 1B 68 08 00 72 12 34 56 78 A3 50 10 01 01 00 00 00 01 67 09 0A 14 60 45 92 10 14 88 13 18 16 diff --git a/test/test-frames/tecson.norm.xml b/test/test-frames/tecson.norm.xml new file mode 100644 index 00000000..3d04e662 --- /dev/null +++ b/test/test-frames/tecson.norm.xml @@ -0,0 +1,41 @@ + + + + + 78563412 + TEC + 16 + + Oil + 1 + 00 + 0000 + + + + Instantaneous value + 0 + °C + External temperature + 9.000000 + + + + Instantaneous value + 0 + m^3 + Volume + 45.600000 + + + + Maximum value + 0 + 1 + 0 + m^3 + Volume + 50.000000 + + + diff --git a/test/test-frames/tecson.xml b/test/test-frames/tecson.xml new file mode 100644 index 00000000..201cdfd4 --- /dev/null +++ b/test/test-frames/tecson.xml @@ -0,0 +1,38 @@ + + + + + 78563412 + TEC + 16 + + Oil + 1 + 00 + 0000 + + + + Instantaneous value + 0 + External temperature ( deg C) + 9 + + + + Instantaneous value + 0 + Volume (1e-2 m^3) + 4560 + + + + Maximum value + 0 + 1 + 0 + Volume (1e-2 m^3) + 5000 + + + From be23bda7a2bbbd9f8e4644510b86b5721143cced Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 12:30:22 +0200 Subject: [PATCH 208/238] Remove duplicate rvd235.hex is the same as siemens_rvd235.hex --- test/unsupported-frames/rvd235.hex | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/unsupported-frames/rvd235.hex diff --git a/test/unsupported-frames/rvd235.hex b/test/unsupported-frames/rvd235.hex deleted file mode 100644 index 113ab5f4..00000000 --- a/test/unsupported-frames/rvd235.hex +++ /dev/null @@ -1 +0,0 @@ -68 96 96 68 08 00 72 04 11 29 00 7A 32 29 20 0C 28 00 00 0C 78 20 71 04 00 06 FD 0C FC 03 6D 00 2D 00 0D FD 0B 06 35 33 32 44 56 52 81 30 FD 7C 01 81 20 FD 7C 00 01 FD 7C 00 0F 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 24 16 From 647cedefe3eaf31789d87e04c8a79880a1e8d203 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 8 Jul 2020 12:34:38 +0200 Subject: [PATCH 209/238] Move RVD235 out of unsupported Especially after the recent changes, we can consider Siemens RVD235 as supported. --- .../siemens_rvd235.hex | 0 test/test-frames/siemens_rvd235.norm.xml | 75 +++++++++++++++++++ test/test-frames/siemens_rvd235.xml | 66 ++++++++++++++++ 3 files changed, 141 insertions(+) rename test/{unsupported-frames => test-frames}/siemens_rvd235.hex (100%) create mode 100644 test/test-frames/siemens_rvd235.norm.xml create mode 100644 test/test-frames/siemens_rvd235.xml diff --git a/test/unsupported-frames/siemens_rvd235.hex b/test/test-frames/siemens_rvd235.hex similarity index 100% rename from test/unsupported-frames/siemens_rvd235.hex rename to test/test-frames/siemens_rvd235.hex diff --git a/test/test-frames/siemens_rvd235.norm.xml b/test/test-frames/siemens_rvd235.norm.xml new file mode 100644 index 00000000..c9105b8d --- /dev/null +++ b/test/test-frames/siemens_rvd235.norm.xml @@ -0,0 +1,75 @@ + + + + + 291104 + LSZ + 41 + + Breaker: Electricity + 12 + 28 + 0000 + + + + Instantaneous value + 0 + + Fabrication No + 47120.000000 + + + + Instantaneous value + 0 + + Model / Version + 193280672764.000000 + + + + Instantaneous value + 0 + + Parameter set identification + RVD235 + + + + Instantaneous value + 0 + 3 + 0 + Reserved + Reserved + 1.000000 + + + + Instantaneous value + 0 + 2 + 0 + Reserved + Reserved + 0.000000 + + + + Instantaneous value + 0 + Reserved + Reserved + 0.000000 + + + + Manufacturer specific + 0 + + + 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 + + + diff --git a/test/test-frames/siemens_rvd235.xml b/test/test-frames/siemens_rvd235.xml new file mode 100644 index 00000000..3b570d37 --- /dev/null +++ b/test/test-frames/siemens_rvd235.xml @@ -0,0 +1,66 @@ + + + + + 291104 + LSZ + 41 + + Breaker: Electricity + 12 + 28 + 0000 + + + + Instantaneous value + 0 + Fabrication number + 47120 + + + + Instantaneous value + 0 + Model / Version + 193280672764 + + + + Instantaneous value + 0 + Parameter set identification + RVD235 + + + + Instantaneous value + 0 + 3 + 0 + Reserved VIF extension + 1 + + + + Instantaneous value + 0 + 2 + 0 + Reserved VIF extension + 0 + + + + Instantaneous value + 0 + Reserved VIF extension + 0 + + + + Manufacturer specific + 02 78 04 00 02 7A 04 00 32 00 1E 09 32 08 00 00 34 10 00 00 00 00 31 18 00 34 18 FF FF FF FF 71 18 00 74 18 FF FF FF FF B1 01 18 00 B4 01 18 FF FF FF FF F1 01 18 00 F4 01 18 FF FF FF FF B1 02 18 00 B4 02 18 FF FF FF FF F1 02 18 00 31 28 00 34 28 FF FF FF FF 71 28 00 01 01 00 01 09 00 + + + From db42619e0e7454da84ff76321358edba05c8642d Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Tue, 7 Jul 2020 15:40:23 +0200 Subject: [PATCH 210/238] Move invalid_length*.hex to test/unsupported-frames (#165) --- test/{test-frames => unsupported-frames}/invalid_length.hex | 0 test/{test-frames => unsupported-frames}/invalid_length2.hex | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename test/{test-frames => unsupported-frames}/invalid_length.hex (100%) rename test/{test-frames => unsupported-frames}/invalid_length2.hex (100%) diff --git a/test/test-frames/invalid_length.hex b/test/unsupported-frames/invalid_length.hex similarity index 100% rename from test/test-frames/invalid_length.hex rename to test/unsupported-frames/invalid_length.hex diff --git a/test/test-frames/invalid_length2.hex b/test/unsupported-frames/invalid_length2.hex similarity index 100% rename from test/test-frames/invalid_length2.hex rename to test/unsupported-frames/invalid_length2.hex From 2dc6c6b1f98ac10ddbc224d9704eeae9296fc4fa Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 12:36:45 +0200 Subject: [PATCH 211/238] Enforce tests execute ok (#165) --- .github/workflows/ccpp.yml | 6 +++++- .travis.yml | 2 ++ test/generate-xml.sh | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 1478bc32..53147de9 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -12,7 +12,11 @@ jobs: run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. - name: generate test frames - run: ./test/generate-xml.sh test/test-frames + run: | + ./test/generate-xml.sh test/test-frames + echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" + ./test/generate-xml.sh test/error-frames || true + ./test/generate-xml.sh test/unsupported-frames || true - name: install and run gcovr run: sudo pip install gcovr && gcovr build/. diff --git a/.travis.yml b/.travis.yml index 39fe165c..70b00795 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,3 +11,5 @@ os: script: - ./build.sh - cd test && make && ./generate-xml.sh test-frames + - cd test && make && ./generate-xml.sh test/error-frames || true + - cd test && make && ./generate-xml.sh test/unsupported-frames || true diff --git a/test/generate-xml.sh b/test/generate-xml.sh index b9662d93..b504fad0 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -12,6 +12,12 @@ # #------------------------------------------------------------------------------ +NUMBER_OF_PARSING_ERRORS=0 +FAILING_TESTS=failing_tests.txt +NEW_TESTS=new_tests.txt +touch $FAILING_TESTS +touch $NEW_TESTS + # Check commandline parameter if [ $# -ne 1 ]; then echo "usage: $0 path_to_directory_with_xml_files" @@ -64,6 +70,7 @@ generate_xml() { # Check parsing result if [ $result -ne 0 ]; then + NUMBER_OF_PARSING_ERRORS=$((NUMBER_OF_PARSING_ERRORS + 1)) echo "Unable to generate XML for $hexfile" rm "$directory/$filename$mode.xml.new" return 1 @@ -81,14 +88,17 @@ generate_xml() { ;; 1) # different -> print diff + echo "== $directory/$filename$mode failed" cat "$directory/$filename$mode.dif" && rm "$directory/$filename$mode.dif" echo "" + echo "$filename$mode" >> $FAILING_TESTS ;; *) # no old -> rename XML echo "Create $filename$mode.xml" mv "$directory/$filename$mode.xml.new" "$directory/$filename$mode.xml" rm "$directory/$filename$mode.dif" + echo "$filename$mode" >> $NEW_TESTS ;; esac @@ -105,3 +115,27 @@ for hexfile in "$directory"/*.hex; do generate_xml "$directory" "$hexfile" "normalized" done +# Check the size of the file $FAILING_TESTS. Make sure to indicate failure. +if [ -s $FAILING_TESTS ]; then + echo "** There were errors in the following file(s):" + cat $FAILING_TESTS + exit 1 +else + rm $FAILING_TESTS +fi +if [ -s $NEW_TESTS ]; then + echo "** There were new test in the following file(s):" + cat $NEW_TESTS +else + rm $NEW_TESTS +fi + +# Check that there was no files that failed to parse +if [ $NUMBER_OF_PARSING_ERRORS -ne 0 ]; then + echo "** There were $NUMBER_OF_PARSING_ERRORS files that did not parse, expected 0 files." + echo + exit $NUMBER_OF_PARSING_ERRORS +fi +DIRECTORY_BASENAME="$(basename "$directory")" +echo "** Tests executed successfully in \"$DIRECTORY_BASENAME\"." +echo From 8ab5d9ebd003f1ebd5a8d38b889b965672d25c08 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 12:53:50 +0200 Subject: [PATCH 212/238] Fix bug, test script should accept both 1 and 2 arguments (#165) Usefull when placing the output in another directory. --- test/generate-xml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/generate-xml.sh b/test/generate-xml.sh index b504fad0..f6c79ff7 100755 --- a/test/generate-xml.sh +++ b/test/generate-xml.sh @@ -19,7 +19,7 @@ touch $FAILING_TESTS touch $NEW_TESTS # Check commandline parameter -if [ $# -ne 1 ]; then +if [ $# -lt 1 ] || [ $# -gt 2 ]; then echo "usage: $0 path_to_directory_with_xml_files" echo "or" echo "usage: $0 path_to_directory_with_xml_files path_to_mbus_parse_hex_with_filename" From 48c03109d742a3cc49d2ad65510066ba545487c9 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Wed, 1 Jul 2020 13:05:31 +0200 Subject: [PATCH 213/238] Rewrite ccpp.yml to use multi-line command (#165) For enhanced readability, split the commands over several lines. --- .github/workflows/ccpp.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 53147de9..df0398ab 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -9,7 +9,12 @@ jobs: steps: - uses: actions/checkout@v2 - name: build examples and tests - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd .. + run: | + rm -rf build || true + mkdir -p build + cd build + cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j + cd .. - name: generate test frames run: | @@ -27,7 +32,14 @@ jobs: steps: - uses: actions/checkout@v2 - name: build debian package - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_PACKAGE_DEB=ON && cpack .. && sudo dpkg -i *.deb && ls /usr/lib + run: | + rm -rf build || true + mkdir -p build + cd build + cmake .. -DLIBMBUS_PACKAGE_DEB=ON + cpack .. + sudo dpkg -i *.deb + ls /usr/lib doc: runs-on: ubuntu-latest @@ -38,5 +50,9 @@ jobs: run: sudo apt install -y doxygen - name: build doxygen documentation - run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_DOCS=ON && cmake --build . --target doc - + run: | + rm -rf build || true + mkdir build + cd build + cmake .. -DLIBMBUS_BUILD_DOCS=ON + cmake --build . --target doc From c8940fa267c816a57d79e5eb7b05836d3d4829d8 Mon Sep 17 00:00:00 2001 From: Fredrik Skold Date: Thu, 4 Jun 2020 16:11:52 +0200 Subject: [PATCH 214/238] Add Dockerfile.test to run tests from docker (#165) --- Dockerfile.test | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Dockerfile.test diff --git a/Dockerfile.test b/Dockerfile.test new file mode 100644 index 00000000..52ee1792 --- /dev/null +++ b/Dockerfile.test @@ -0,0 +1,18 @@ +# docker build . -f Dockerfile.test -t test_builder + +FROM ubuntu + +RUN apt update -y && apt install -y cmake gcc g++ make +COPY . /tmp +RUN cd /tmp && \ + mkdir build && \ + cd build && \ + cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && \ + cmake --build . -j && \ + cd .. && \ + ./test/generate-xml.sh test/test-frames + +RUN cd /tmp && \ + echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" && \ + ./test/generate-xml.sh test/error-frames || true ; \ + ./test/generate-xml.sh test/unsupported-frames || true From 0b4ada12d4a42d2cbdecd557a5cfdd5e7251525c Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 19 Jul 2020 12:53:59 +0200 Subject: [PATCH 215/238] build: temporary revert to autotools (#174) As long as cmake doesn't generate suitable deb packages, we need to switch back :( --- .github/workflows/ccpp.yml | 58 -------- CMakeLists.txt | 296 ------------------------------------- Dockerfile.deb | 14 -- Dockerfile.rpm | 14 -- Dockerfile.test | 18 --- Makefile-static | 25 ++++ Makefile.am | 20 +++ README.md | 32 +--- bin/CMakeLists.txt | 19 --- bin/Makefile-static | 24 +++ bin/Makefile.am | 102 +++++++++++++ build-deb.sh | 25 ++++ build.sh | 37 +++-- cmake-format.yaml | 15 -- cmake/Config.cmake.in | 4 - configure.ac | 44 ++++++ Doxyfile.in => doxygen.cfg | 9 +- libmbus.pc.in | 12 +- libmbus.spec | 87 +++++++++++ mbus/Makefile.am | 20 +++ mbus/config.h.in | 56 ------- test/CMakeLists.txt | 5 - test/Makefile.am | 25 ++++ 23 files changed, 399 insertions(+), 562 deletions(-) delete mode 100644 .github/workflows/ccpp.yml delete mode 100644 CMakeLists.txt delete mode 100644 Dockerfile.deb delete mode 100644 Dockerfile.rpm delete mode 100644 Dockerfile.test create mode 100644 Makefile-static create mode 100644 Makefile.am delete mode 100644 bin/CMakeLists.txt create mode 100644 bin/Makefile-static create mode 100644 bin/Makefile.am create mode 100755 build-deb.sh delete mode 100644 cmake-format.yaml delete mode 100644 cmake/Config.cmake.in create mode 100644 configure.ac rename Doxyfile.in => doxygen.cfg (99%) create mode 100644 libmbus.spec create mode 100644 mbus/Makefile.am delete mode 100644 mbus/config.h.in delete mode 100644 test/CMakeLists.txt create mode 100644 test/Makefile.am diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml deleted file mode 100644 index df0398ab..00000000 --- a/.github/workflows/ccpp.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: CMake - -on: [push, pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build examples and tests - run: | - rm -rf build || true - mkdir -p build - cd build - cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j - cd .. - - - name: generate test frames - run: | - ./test/generate-xml.sh test/test-frames - echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" - ./test/generate-xml.sh test/error-frames || true - ./test/generate-xml.sh test/unsupported-frames || true - - - name: install and run gcovr - run: sudo pip install gcovr && gcovr build/. - - debian: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build debian package - run: | - rm -rf build || true - mkdir -p build - cd build - cmake .. -DLIBMBUS_PACKAGE_DEB=ON - cpack .. - sudo dpkg -i *.deb - ls /usr/lib - - doc: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: build doxygen documentation - run: sudo apt install -y doxygen - - - name: build doxygen documentation - run: | - rm -rf build || true - mkdir build - cd build - cmake .. -DLIBMBUS_BUILD_DOCS=ON - cmake --build . --target doc diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index c47a94c3..00000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,296 +0,0 @@ -cmake_minimum_required(VERSION 3.5) - -project( - libmbus - LANGUAGES CXX C - VERSION "0.9.0") - -if(CMAKE_BUILD_TYPE STREQUAL "") - message(STATUS "CMAKE_BUILD_TYPE empty setting to Debug") - set(CMAKE_BUILD_TYPE "Debug") -endif() - -# ############################################################################## -# default options -> changed with e.g. cd build && cmake .. -# -DLIBMBUS_BUILD_TESTS=ON -# ############################################################################## - -option(LIBMBUS_BUILD_EXAMPLES "build examples" OFF) -option(LIBMBUS_BUILD_TESTS "build tests" OFF) -option(LIBMBUS_ENABLE_COVERAGE "build with coverage support" OFF) -option(LIBMBUS_RUN_CLANG_TIDY "use Clang-Tidy for static analysis" OFF) -option(LIBMBUS_PACKAGE_DEB "build debian package" OFF) -option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF) -option(LIBMBUS_BUILD_DOCS "build documentation" OFF) -option(BUILD_SHARED_LIBS "build shared lib" ON) - -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_C_STANDARD 11) - -# Append our module directory to CMake -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_BINARY_DIR}") - -# Set the output of the libraries and executables. -set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) -set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - -# ############################################################################## -# static analysis -# ############################################################################## - -if(LIBMBUS_RUN_CLANG_TIDY) - find_program( - CLANG_TIDY_EXE - NAMES "clang-tidy" - DOC "/usr/bin/clang-tidy") - if(NOT CLANG_TIDY_EXE) - message(WARNING "clang-tidy not found.") - else() - message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") - endif() -endif(LIBMBUS_RUN_CLANG_TIDY) - -if(LIBMBUS_ENABLE_COVERAGE) - if(NOT CMAKE_BUILD_TYPE MATCHES "(Debug)|(RelWithDebInfo)") - message(WARNING "Code coverage results with an optimised (non-Debug) build may be misleading") - endif() - - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # using Clang - message(STATUS "Not doing coverage...") - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # using GCC - message(STATUS "Building with code coverage...") - set(CMAKE_BUILD_TYPE DEBUG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -ggdb3 -O0 --coverage -fprofile-arcs -ftest-coverage ") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage ") - link_libraries(-lgcov) - endif() -endif() - -include(CheckIncludeFile) - -check_include_file(dlfcn.h HAVE_DLFCN_H) -check_include_file(inttypes.h HAVE_INTTYPES_H) -check_include_file(memory.h HAVE_MEMORY_H) -check_include_file(stdlib.h HAVE_STDINT_H) -check_include_file(stdint.h HAVE_STDLIB_H) -check_include_file(strings.h HAVE_STRINGS_H) -check_include_file(string.h HAVE_STRING_H) -check_include_file(sys/stat.h HAVE_SYS_STAT_H) -check_include_file(sys/types.h HAVE_SYS_TYPES_H) -check_include_file(unistd.h HAVE_UNISTD_H) - -# ############################################################################## -# library -# ############################################################################## - -set(PACKAGE_STRING "${PROJECT_NAME} ${PROJECT_VERSION}") - -set(PACKAGE_VERSION "${PROJECT_VERSION}") -set(VERSION "${PROJECT_VERSION}") -configure_file(${CMAKE_CURRENT_LIST_DIR}/mbus/config.h.in ${CMAKE_CURRENT_LIST_DIR}/config.h @ONLY) - -add_library( - ${PROJECT_NAME} - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-tcp.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-protocol-aux.h" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.c" - "${CMAKE_CURRENT_LIST_DIR}/mbus/mbus-serial.h") -target_include_directories( - ${PROJECT_NAME} - PUBLIC "$" "$" - "$") -if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") - target_link_libraries(${PROJECT_NAME} PRIVATE m) -endif() -if(NOT MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Wno-pedantic) -endif() - -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "") - -if(CLANG_TIDY_EXE) - set_target_properties(${PROJECT_NAME} PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_EXE}") -endif() - -add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) - -# ############################################################################## -# examples -# ############################################################################## - -if(LIBMBUS_BUILD_EXAMPLES) - message(STATUS "building examples") - add_subdirectory(bin) -endif() - -# ############################################################################## -# tests -# ############################################################################## - -if(LIBMBUS_BUILD_TESTS) - message(STATUS "building tests") - enable_testing() - add_subdirectory(test) -endif() - -# ############################################################################## -# install -# ############################################################################## - -include(GNUInstallDirs) -include(CMakePackageConfigHelpers) - -set(INSTALL_PKGCONFIG_DIR - "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" - CACHE PATH "Installation directory for pkgconfig (.pc) files") -set(INSTALL_INC_DIR - "${CMAKE_INSTALL_INCLUDEDIR}/mbus" - CACHE PATH "Installation directory for headers") -set(INSTALL_LIB_DIR - "${CMAKE_INSTALL_LIBDIR}" - CACHE PATH "Installation directory for libraries") - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmbus.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc @ONLY) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/libmbus.pc - DESTINATION "${INSTALL_PKGCONFIG_DIR}" - COMPONENT dev) - -set(LIBMBUS_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) -install( - TARGETS ${PROJECT_NAME} - EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib - ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT dev - RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT lib) -install( - EXPORT ${PROJECT_NAME}Targets - DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" - NAMESPACE ${PROJECT_NAME}:: - COMPONENT dev) - -configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake INSTALL_DESTINATION - "${LIBMBUS_CONFIG_INSTALL_DIR}") -write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake COMPATIBILITY SameMajorVersion) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake - ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - DESTINATION "${LIBMBUS_CONFIG_INSTALL_DIR}" - COMPONENT dev) - -install( - DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/mbus/" - DESTINATION "${INSTALL_INC_DIR}" - COMPONENT dev - FILES_MATCHING - PATTERN "*.h") - -# ############################################################################## -# package -# mkdir build ; cd build ; cmake .. -DLIBMBUS_PACKAGE_DEB=ON ; cpack .. -# ############################################################################## - -include(InstallRequiredSystemLibraries) - -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open source M-bus (Meter-Bus) library.") -set(CPACK_PACKAGE_DESCRIPTION - "libmbus is an open source library for the M-bus (Meter-Bus) protocol. -The Meter-Bus is a standard for reading out meter data from electricity meters, -heat meters, gas meters, etc. The M-bus standard deals with both the electrical -signals on the M-Bus, and the protocol and data format used in transmissions -on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle -the communication with M-Bus devices. - -For more information see http://www.rscada.se/libmbus") - -set(CPACK_PACKAGE_VENDOR "Raditex Control AB") -set(CPACK_PACKAGE_CONTACT "Stefan Wahren ") -set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/rscada/libmbus/") -set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) -set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}") -set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}") -set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}") -set(CPACK_DEB_COMPONENT_INSTALL ON) -set(CPACK_DEBIAN_PACKAGE_DEBUG ON) -set(CPACK_PACKAGE_RELEASE 1) - -# create 2 components, libmbus, libmbus-dev -set(CPACK_COMPONENTS_ALL lib dev) -set(CPACK_COMPONENT_LIB_DESCRIPTION "FreeSCADA M-Bus Library. - A free and open-source library for M-Bus (Meter Bus) from the rSCADA project.") -set(CPACK_DEBIAN_LIB_PACKAGE_SECTION libs) - -set(CPACK_COMPONENT_DEVEL_DESCRIPTION - "FreeSCADA M-Bus Library Development files. -A free and open-source library for M-Bus (Meter Bus) from the rSCADA project, -including development files.") -set(CPACK_DEBIAN_DEVEL_PACKAGE_SECTION libdevel) - -set(CPACK_COMPONENT_DEVEL_DEPENDS lib) - -set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") -set(CPACK_PACKAGE_FILE_NAME - "${CMAKE_PROJECT_NAME}_${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") - -if(LIBMBUS_PACKAGE_DEB) - set(CPACK_GENERATOR "DEB") - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Stefan Wahren ") - set(CPACK_DEBIAN_PACKAGE_SECTION "Development/Languages/C and C++") - set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) - set(CPACK_DEBIAN_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CPACK_PACKAGE_RELEASE}" - ) -endif() - -if(LIBMBUS_PACKAGE_RPM) - set(CPACK_GENERATOR "RPM") - set(CPACK_RPM_PACKAGE_LICENSE "BSD") -endif() - -include(CPack) - -# ############################################################################## -# doc -# mkdir build ; cd build ; cmake .. -DLIBMBUS_BUILD_DOCS=ON ; cmake --build . --target doc -# ############################################################################## - -if(LIBMBUS_BUILD_DOCS) - message(STATUS "building with documentation") - # Generate targets for documentation - # check if Doxygen is installed - find_package(Doxygen) - - if(Doxygen_FOUND) - # set input and output files - set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) - set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - - # request to configure the file - configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - - # note the option ALL which allows to build the docs together with the application - add_custom_target( - doc ALL - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - VERBATIM) - - message(STATUS "Setup up the Doxygen documention build") - - else(Doxygen_FOUND) - message(WARNING "Doxygen need to be installed to generate the doxygen documentation") - endif(Doxygen_FOUND) -endif() diff --git a/Dockerfile.deb b/Dockerfile.deb deleted file mode 100644 index 1db6923d..00000000 --- a/Dockerfile.deb +++ /dev/null @@ -1,14 +0,0 @@ -# docker build . -f Dockerfile.deb -t deb_builder - -FROM ubuntu - -RUN apt update -y && apt install -y cmake gcc g++ make -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_PACKAGE_DEB=ON && \ - cpack .. && \ - ls -al && \ - dpkg -i *.deb - diff --git a/Dockerfile.rpm b/Dockerfile.rpm deleted file mode 100644 index 2f70df96..00000000 --- a/Dockerfile.rpm +++ /dev/null @@ -1,14 +0,0 @@ -# docker build . -f Dockerfile.rpm -t rpm_builder - -FROM fedora - -RUN dnf install -y cmake gcc g++ make rpm-build -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_PACKAGE_RPM=ON && \ - cpack .. && \ - ls -al && \ - rpm -i *.rpm - diff --git a/Dockerfile.test b/Dockerfile.test deleted file mode 100644 index 52ee1792..00000000 --- a/Dockerfile.test +++ /dev/null @@ -1,18 +0,0 @@ -# docker build . -f Dockerfile.test -t test_builder - -FROM ubuntu - -RUN apt update -y && apt install -y cmake gcc g++ make -COPY . /tmp -RUN cd /tmp && \ - mkdir build && \ - cd build && \ - cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && \ - cmake --build . -j && \ - cd .. && \ - ./test/generate-xml.sh test/test-frames - -RUN cd /tmp && \ - echo "NOTE: error-frames have about 30 parse errors, and unsupported-frames have 12" && \ - ./test/generate-xml.sh test/error-frames || true ; \ - ./test/generate-xml.sh test/unsupported-frames || true diff --git a/Makefile-static b/Makefile-static new file mode 100644 index 00000000..93da7516 --- /dev/null +++ b/Makefile-static @@ -0,0 +1,25 @@ +# Copyright (c) 2010 +# Robert Johansson +# Raditex AB. +# All rights reserved. + +LIB = libmbus.so + +CFLAGS = -Wall -W -g -fPIC -I. +HEADERS = mbus.h mbus-protocol.h +OBJS = mbus.o mbus-protocol.o + +$(LIB): $(OBJS) + gcc -shared -o $(LIB) $(OBJS) + +all: $(LIB) + +clean: + rm -rf *.o *core core $(LIB) + +test: + (cd test && make) + +install: all + cp $(LIB) /usr/local/freescada/lib + cp $(HEADERS) /usr/local/freescada/include diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..fd519e14 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,20 @@ +# +# +# +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = libmbus.pc + + +docdir = $(datadir)/doc/$(PACKAGE)-$(VERSION) +dist_docdir = $(DESTDIR)$(docdir) +doc_DATA = README.md \ + COPYING \ + hardware/MBus_USB.pdf \ + hardware/MBus_USB.txt + +SUBDIRS = mbus bin +ACLOCAL = aclocal -I . +ACLOCAL_AMFLAGS = -Werror -I m4 diff --git a/README.md b/README.md index 133c243d..27d393c0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,4 @@ -# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) - -![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) +# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) ![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master) libmbus is an open source library for the M-bus (Meter-Bus) protocol. @@ -10,32 +8,4 @@ signals on the M-Bus, and the protocol and data format used in transmissions on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle the communication with M-Bus devices. - -## BUILD - -with cmake - -```bash -rm -rf _build -mkdir _build -cd _build -# configure -# e.g. on linux -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -# e.g. for a target device -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/foo-bar-baz.cmake -# compile -cmake --build . -j -# install - optional -cmake --build . --target install -``` - -## CONSUME - -```cmake -find_package(libmbus) -add_executable(my_app main.cpp) -target_link_libraries(my_app libmbus::libmbus) -``` - For more information see http://www.rscada.se/libmbus diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt deleted file mode 100644 index 73e15002..00000000 --- a/bin/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -function(add_example SRCS) - add_executable(${SRCS} ${CMAKE_CURRENT_LIST_DIR}/${SRCS}.c) - target_link_libraries(${SRCS} PRIVATE libmbus::libmbus) -endfunction() - -add_example(mbus-serial-request-data) -add_example(mbus-serial-request-data-multi-reply) -add_example(mbus-serial-scan) -add_example(mbus-serial-scan-secondary) -add_example(mbus-serial-select-secondary) -add_example(mbus-serial-set-address) -add_example(mbus-serial-switch-baudrate) -add_example(mbus-tcp-application-reset) -add_example(mbus-tcp-raw-send) -add_example(mbus-tcp-request-data) -add_example(mbus-tcp-request-data-multi-reply) -add_example(mbus-tcp-scan) -add_example(mbus-tcp-scan-secondary) -add_example(mbus-tcp-select-secondary) diff --git a/bin/Makefile-static b/bin/Makefile-static new file mode 100644 index 00000000..2b04b493 --- /dev/null +++ b/bin/Makefile-static @@ -0,0 +1,24 @@ +# +# Copyright (C) 2011, Robert Johansson, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +CFLAGS=-Wall -g -I.. +LDFLAGS=-L.. -lm -lmbus + +all: mbus-tcp-scan mbus-tcp-request-data + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ + +mbus-tcp-scan: mbus-tcp-scan.o mbus-tcp.o + gcc -o $@ $^ $(LDFLAGS) + +mbus-tcp-request-data: mbus-tcp-request-data.o mbus-tcp.o + gcc -o $@ $^ $(LDFLAGS) + +clean: + rm -rf mbus-tcp-request-data mbus-tcp-scan *.o *~ diff --git a/bin/Makefile.am b/bin/Makefile.am new file mode 100644 index 00000000..7c9ce412 --- /dev/null +++ b/bin/Makefile.am @@ -0,0 +1,102 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/src + +noinst_HEADERS = +bin_PROGRAMS = mbus-tcp-scan mbus-tcp-request-data mbus-tcp-request-data-multi-reply \ + mbus-tcp-select-secondary mbus-tcp-scan-secondary \ + mbus-serial-scan mbus-serial-request-data mbus-serial-request-data-multi-reply \ + mbus-serial-select-secondary mbus-serial-scan-secondary \ + mbus-serial-switch-baudrate mbus-tcp-raw-send mbus-tcp-application-reset \ + mbus-serial-set-address + +# tcp +mbus_tcp_scan_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_scan_LDADD = -lmbus -lm +mbus_tcp_scan_SOURCES = mbus-tcp-scan.c + +mbus_tcp_request_data_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_request_data_LDADD = -lmbus -lm +mbus_tcp_request_data_SOURCES = mbus-tcp-request-data.c + +mbus_tcp_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_request_data_multi_reply_LDADD = -lmbus -lm +mbus_tcp_request_data_multi_reply_SOURCES = mbus-tcp-request-data-multi-reply.c + +mbus_tcp_select_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_select_secondary_LDADD = -lmbus -lm +mbus_tcp_select_secondary_SOURCES = mbus-tcp-select-secondary.c + +mbus_tcp_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_scan_secondary_LDADD = -lmbus -lm +mbus_tcp_scan_secondary_SOURCES = mbus-tcp-scan-secondary.c + +mbus_tcp_raw_send_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_raw_send_LDADD = -lmbus -lm +mbus_tcp_raw_send_SOURCES = mbus-tcp-raw-send.c + +mbus_tcp_application_reset_LDFLAGS = -L$(top_builddir)/mbus +mbus_tcp_application_reset_LDADD = -lmbus -lm +mbus_tcp_application_reset_SOURCES = mbus-tcp-application-reset.c + +# serial +mbus_serial_scan_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_scan_LDADD = -lmbus -lm +mbus_serial_scan_SOURCES = mbus-serial-scan.c + +mbus_serial_request_data_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_request_data_LDADD = -lmbus -lm +mbus_serial_request_data_SOURCES = mbus-serial-request-data.c + +mbus_serial_request_data_multi_reply_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_request_data_multi_reply_LDADD = -lmbus -lm +mbus_serial_request_data_multi_reply_SOURCES = mbus-serial-request-data-multi-reply.c + +mbus_serial_select_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_select_secondary_LDADD = -lmbus -lm +mbus_serial_select_secondary_SOURCES = mbus-serial-select-secondary.c + +mbus_serial_scan_secondary_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_scan_secondary_LDADD = -lmbus -lm +mbus_serial_scan_secondary_SOURCES = mbus-serial-scan-secondary.c + +mbus_serial_switch_baudrate_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_switch_baudrate_LDADD = -lmbus -lm +mbus_serial_switch_baudrate_SOURCES = mbus-serial-switch-baudrate.c + +mbus_serial_set_address_LDFLAGS = -L$(top_builddir)/mbus +mbus_serial_set_address_LDADD = -lmbus -lm +mbus_serial_set_address_SOURCES = mbus-serial-set-address.c + +# man pages +dist_man_MANS = libmbus.1 \ + mbus-tcp-scan.1 \ + mbus-tcp-request-data.1 \ + mbus-tcp-request-data-multi-reply.1 \ + mbus-tcp-select-secondary.1 \ + mbus-tcp-scan-secondary.1 \ + mbus-tcp-raw-send.1 \ + mbus-serial-scan.1 \ + mbus-serial-request-data.1 \ + mbus-serial-request-data-multi-reply.1 \ + mbus-serial-select-secondary.1 \ + mbus-serial-scan-secondary.1 \ + mbus-serial-switch-baudrate.1 + +.pod.1: + pod2man --release=$(VERSION) --center=$(PACKAGE) $< \ + >.pod2man.tmp.$$$$ 2>/dev/null && mv -f .pod2man.tmp.$$$$ $@ || true + @if grep '\' $@ >/dev/null 2>&1; \ + then \ + echo "$@ has some POD errors!"; false; \ + fi diff --git a/build-deb.sh b/build-deb.sh new file mode 100755 index 00000000..77f3a6be --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2012, Robert Johansson , Raditex Control AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@raditex.nu +# +# ------------------------------------------------------------------------------ + +if [ ! -f Makefile ]; then + # + # regenerate automake files + # + echo "Running autotools..." + + autoheader \ + && aclocal \ + && libtoolize --ltdl --copy --force \ + && automake --add-missing --copy \ + && autoconf +fi + +debuild -i -us -uc -b +#sudo pbuilder build $(NAME)_$(VERSION)-1.dsc diff --git a/build.sh b/build.sh index 04ea869c..34c2799b 100755 --- a/build.sh +++ b/build.sh @@ -1,24 +1,21 @@ #!/bin/sh +# +if [ -f Makefile ]; then + # use existing automake files + echo >> /dev/null +else + # regenerate automake files + echo "Running autotools..." -rm -rf build -mkdir build -cd build -cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -cmake --build . + autoheader \ + && aclocal \ + && case \ + $(uname) in Darwin*) glibtoolize --ltdl --copy --force ;; \ + *) libtoolize --ltdl --copy --force ;; esac \ + && automake --add-missing --copy \ + && autoconf \ + && ./configure +fi -# build deb - -# rm -rf build -# mkdir build -# cd build -# cmake .. -DLIBMBUS_PACKAGE_DEB=ON -# cpack .. -# dpkg -i *.deb - -# build doc - -# mkdir build -# cd build -# cmake .. -DLIBMBUS_BUILD_DOCS=ON -# cmake --build . --target doc +make diff --git a/cmake-format.yaml b/cmake-format.yaml deleted file mode 100644 index 60329ed6..00000000 --- a/cmake-format.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# https://github.com/cheshirekow/cmake_format - -# How wide to allow formatted cmake files -line_width: 120 - -# How many spaces to tab for indent -tab_size: 2 - -# Format command names consistently as 'lower' or 'upper' case -command_case: "lower" - -first_comment_is_literal: False - -# enable comment markup parsing and reflow -enable_markup: False diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in deleted file mode 100644 index 9c15f36a..00000000 --- a/cmake/Config.cmake.in +++ /dev/null @@ -1,4 +0,0 @@ -@PACKAGE_INIT@ - -include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") -check_required_components("@PROJECT_NAME@") diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..d14d0e2c --- /dev/null +++ b/configure.ac @@ -0,0 +1,44 @@ +dnl ---------------------------------------------------------------------------- +dnl Copyright (C) 2010, Raditex AB +dnl All rights reserved. +dnl +dnl rSCADA +dnl http://www.rSCADA.se +dnl info@rscada.se +dnl +dnl ---------------------------------------------------------------------------- + +LT_CONFIG_LTDL_DIR([libltdl]) + +AC_INIT([libmbus], [0.9.0], [info@rscada.se], [libmbus], [http://www.rscada.se/libmbus/]) +AC_CONFIG_AUX_DIR([libltdl/config]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) + +AM_PROG_LIBTOOL +# fix for automake 1.11 & 1.12 +m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) + +LDFLAGS="$LDFLAGS -version-info 0:9:0" + +dnl ---------------------- +dnl +AC_PROG_CC + +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([Makefile mbus/Makefile test/Makefile bin/Makefile libmbus.pc]) +AC_OUTPUT + + +echo \ +"---------------------------------------------------------- +Configuration: + + Source location: ${srcdir} + Compile: ${CC} + Compiler flags: ${CFLAGS} + Linker flags: ${LDFLAGS} + Host system type: ${host} + Install path: ${prefix} + + See config.h for further configuration. +----------------------------------------------------------" diff --git a/Doxyfile.in b/doxygen.cfg similarity index 99% rename from Doxyfile.in rename to doxygen.cfg index b8393df7..ea1b569d 100644 --- a/Doxyfile.in +++ b/doxygen.cfg @@ -25,13 +25,13 @@ DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. -PROJECT_NAME = "@CMAKE_PROJECT_NAME@" +PROJECT_NAME = libmbus # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@ +PROJECT_NUMBER = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -581,7 +581,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @CMAKE_CURRENT_LIST_DIR@/mbus +INPUT = mbus # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is @@ -1628,6 +1628,3 @@ GENERATE_LEGEND = YES # the various graphs. DOT_CLEANUP = YES - - -USE_MDFILE_AS_MAINPAGE = @CMAKE_CURRENT_LIST_DIR@/README.md diff --git a/libmbus.pc.in b/libmbus.pc.in index 1baf5a3e..6c1b7d8b 100644 --- a/libmbus.pc.in +++ b/libmbus.pc.in @@ -1,12 +1,12 @@ -prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@INSTALL_LIB_DIR@ -includedir=@INSTALL_INC_DIR@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ Name: libmbus Description: Open source M-bus (Meter-Bus) library. Requires: -Version: @PROJECT_VERSION@ +Version: @PACKAGE_VERSION@ URL: http://www.rscada.se/libmbus/ Libs: -L${libdir} -lmbus -lm -Cflags: -I${includedir} \ No newline at end of file +Cflags: -I${includedir} diff --git a/libmbus.spec b/libmbus.spec new file mode 100644 index 00000000..06160f75 --- /dev/null +++ b/libmbus.spec @@ -0,0 +1,87 @@ +# +# spec file for package libmbus +# +# Copyright (c) 2010-2013, Raditex Control AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# + +Summary: Open source M-bus (Meter-Bus) library +Name: libmbus +Version: 0.9.0 +Release: 1 +Source: https://github.com/rscada/%{name}/archive/%{version}.tar.gz +URL: https://github.com/rscada/libmbus/ +License: BSD +Vendor: Raditex Control AB +Packager: Stefan Wahren +Group: Development/Languages/C and C++ +BuildRoot: {_tmppath}/%{name}-%{version}-build +AutoReqProv: on + +%description +libmbus: M-bus Library from Raditex Control (http://www.rscada.se) + +libmbus is an open source library for the M-bus (Meter-Bus) protocol. +The Meter-Bus is a standard for reading out meter data from electricity meters, +heat meters, gas meters, etc. The M-bus standard deals with both the electrical +signals on the M-Bus, and the protocol and data format used in transmissions +on the M-Bus. The role of libmbus is to decode/encode M-bus data, and to handle +the communication with M-Bus devices. + +For more information see http://www.rscada.se/libmbus + +%package devel +License: BSD +Summary: Development libraries and header files for using the M-bus library +Group: Development/Libraries/C and C++ +AutoReqProv: on +Requires: %{name} = %{version} + +%description devel +This package contains all necessary include files and libraries needed +to compile and link applications which use the M-bus (Meter-Bus) library. + +%prep -q +%setup -q +# workaround to get it's build +autoreconf + +%build +./configure --prefix=/usr +make + +%install +rm -Rf "%buildroot" +mkdir "%buildroot" +make install DESTDIR="%buildroot" + +%clean +rm -rf "%buildroot" + +%files +%defattr (-,root,root) +%doc COPYING README.md +%{_bindir}/mbus-serial-* +%{_bindir}/mbus-tcp-* +%{_libdir}/libmbus.so* +%{_mandir}/man1/libmbus.1 +%{_mandir}/man1/mbus-* + +%files devel +%defattr (-,root,root) +%{_includedir}/mbus +%{_libdir}/libmbus.a +%{_libdir}/libmbus.la +%{_libdir}/pkgconfig/libmbus.pc + +%changelog +* Fri Feb 22 2019 Stefan Wahren - 0.9.0-1 +- switch to github repo +- enable man pages + +* Fri Mar 29 2013 Stefan Wahren - 0.8.0-1 +- Initial package based on the last official release diff --git a/mbus/Makefile.am b/mbus/Makefile.am new file mode 100644 index 00000000..b0749871 --- /dev/null +++ b/mbus/Makefile.am @@ -0,0 +1,20 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) + +includedir = $(prefix)/include/mbus +include_HEADERS = mbus.h mbus-protocol.h mbus-tcp.h mbus-serial.h mbus-protocol-aux.h + +lib_LTLIBRARIES = libmbus.la +libmbus_la_SOURCES = mbus.c mbus-protocol.c mbus-tcp.c mbus-serial.c mbus-protocol-aux.c + diff --git a/mbus/config.h.in b/mbus/config.h.in deleted file mode 100644 index 9b818f65..00000000 --- a/mbus/config.h.in +++ /dev/null @@ -1,56 +0,0 @@ -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_MEMORY_H "@HAVE_MEMORY_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDINT_H "@HAVE_STDINT_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STDLIB_H "@HAVE_STDLIB_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRINGS_H "@HAVE_STRINGS_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_STRING_H "@HAVE_STRING_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_STAT_H "@HAVE_SYS_STAT_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_SYS_TYPES_H "@HAVE_SYS_TYPES_H@" - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_UNISTD_H "@HAVE_UNISTD_H@" - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "@PROJECT_NAME@" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "info@rscada.se" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "@PROJECT_NAME@" - -/* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@PROJECT_NAME@" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "http://www.rscada.se/libmbus/" - -/* Define to the version of this package. */ -#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" - -/* Version number of package */ -#cmakedefine VERSION "@PACKAGE_VERSION@" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 0303d236..00000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(mbus_parse ${CMAKE_CURRENT_LIST_DIR}/mbus_parse.c) -target_link_libraries(mbus_parse PRIVATE libmbus::libmbus) - -add_executable(mbus_parse_hex ${CMAKE_CURRENT_LIST_DIR}/mbus_parse_hex.c) -target_link_libraries(mbus_parse_hex PRIVATE libmbus::libmbus) diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 00000000..c373fa48 --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------ +# Copyright (C) 2010, Raditex AB +# All rights reserved. +# +# rSCADA +# http://www.rSCADA.se +# info@rscada.se +# +# ------------------------------------------------------------------------------ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/mbus + +noinst_HEADERS = +noinst_PROGRAMS = mbus_parse mbus_parse_hex + +mbus_parse_LDFLAGS = -L$(top_builddir)/mbus +mbus_parse_LDADD = -lmbus -lm +mbus_parse_SOURCES = mbus_parse.c + +mbus_parse_hex_LDFLAGS = -L$(top_builddir)/mbus +mbus_parse_hex_LDADD = -lmbus -lm +mbus_parse_hex_SOURCES = mbus_parse_hex.c + From fcfa11dd976189dfc065375017aad1a8bc0f3d70 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Sun, 19 Jul 2020 12:24:27 +0200 Subject: [PATCH 216/238] changelog: Add release 0.9.0 --- debian/changelog | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5dce9087..8c177b90 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +libmbus (0.9.0) xenial; urgency=medium + + * New official release + - major improvement to frame decoding + - new binaries: mbus-tcp-raw-send, mbus-tcp-application-reset, + mbus-serial-set-address + - simple echo cancellation + - replace CUnit test with test/generate-xml.sh + * debian/control: new package libmbus1-dbg + + -- Stefan Wahren Fri, 22 Feb 2019 19:08:04 +0100 + libmbus (0.8.0) precise; urgency=low * New official release. Includes support for multi-telegram communication. From 6d0916884ac274478d59f01b12921c88d230940d Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 5 Aug 2020 09:59:11 +0200 Subject: [PATCH 217/238] try to make testing work again ... do it as fredrik-sk --- .travis.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0c475fb..d324b304 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,8 +8,10 @@ os: - linux - osx -script: +script: - ./build.sh - - ./test/generate-xml.sh test/test-frames - - ./test/generate-xml.sh test/error-frames || true - - ./test/generate-xml.sh test/unsupported-frames || true + - cd test && make && cd .. + - PROG=test/mbus_parse_hex + - test/generate-xml.sh test/test-frames $PROG + - test/generate-xml.sh test/error-frames $PROG || true + - test/generate-xml.sh test/unsupported-frames $PROG || true \ No newline at end of file From 17b2c1d2bd820b8e3960795f503c1165eb41af8e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Mon, 23 Apr 2018 22:38:30 +0200 Subject: [PATCH 218/238] try offering FCB function --- mbus/mbus-protocol-aux.c | 36 ++++++++++++++++++++++++++++++++++++ mbus/mbus-protocol-aux.h | 5 +++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mbus/mbus-protocol-aux.c b/mbus/mbus-protocol-aux.c index 60b5fa66..8479d063 100755 --- a/mbus/mbus-protocol-aux.c +++ b/mbus/mbus-protocol-aux.c @@ -1924,6 +1924,42 @@ mbus_send_request_frame(mbus_handle * handle, int address) return retval; } +//------------------------------------------------------------------------------ +// send a request packet to from master to slave +//------------------------------------------------------------------------------ +int +mbus_send_request_frame_fcb(mbus_handle * handle, int address) +{ + int retval = 0; + mbus_frame *frame; + + if (mbus_is_primary_address(address) == 0) + { + MBUS_ERROR("%s: invalid address %d\n", __PRETTY_FUNCTION__, address); + return -1; + } + + frame = mbus_frame_new(MBUS_FRAME_TYPE_SHORT); + + if (frame == NULL) + { + MBUS_ERROR("%s: failed to allocate mbus frame.\n", __PRETTY_FUNCTION__); + return -1; + } + + frame->control = MBUS_CONTROL_MASK_REQ_UD2 | MBUS_CONTROL_MASK_DIR_M2S | MBUS_CONTROL_MASK_FCB; + frame->address = address; + + if (mbus_send_frame(handle, frame) == -1) + { + MBUS_ERROR("%s: failed to send mbus frame.\n", __PRETTY_FUNCTION__); + retval = -1; + } + + mbus_frame_free(frame); + return retval; +} + //------------------------------------------------------------------------------ // send a user data packet from master to slave //------------------------------------------------------------------------------ diff --git a/mbus/mbus-protocol-aux.h b/mbus/mbus-protocol-aux.h index 4dacef4c..143c7eee 100755 --- a/mbus/mbus-protocol-aux.h +++ b/mbus/mbus-protocol-aux.h @@ -97,7 +97,7 @@ typedef struct _mbus_handle { void (*recv_event) (unsigned char src_type, const char *buff, size_t len); void (*send_event) (unsigned char src_type, const char *buff, size_t len); void (*scan_progress) (struct _mbus_handle *handle, const char *mask); - void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); + void (*found_event) (struct _mbus_handle *handle, mbus_frame *frame); void *auxdata; } mbus_handle; @@ -293,7 +293,8 @@ int mbus_send_switch_baudrate_frame(mbus_handle * handle, int address, long baud * * @return Zero when successful. */ -int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame(mbus_handle * handle, int address); + int mbus_send_request_frame_fcb(mbus_handle * handle, int address); /** * Sends user data frame (SND_UD) to given slave using "unified" handle From a5b256575b1acf48b7965653b945aedab969fd0e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:08:47 +0200 Subject: [PATCH 219/238] * add github action build and tests --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..fc7b95a1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Test + +# Run this job on all pushes and pull requests +# as well as tags with a semantic version +on: + push: + branches: + - '*' + pull_request: {} + +jobs: + + # Runs lib tests on all supported node versions and OSes + build-and-test: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + + steps: + - name: Build + run: ./build.sh + + - name: Test Success Frames + run: cd test && make && ./generate-xml.sh test-frames + + - name: Test Error Frames + run: cd test && make && ./generate-xml.sh test/error-frames || true + + - name: Test Unsupported Frames + run: cd test && make && ./generate-xml.sh test/unsupported-frames || true From c98829ba3747af2b038f82358484171e235ec256 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:10:26 +0200 Subject: [PATCH 220/238] * add github action build and tests --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc7b95a1..e1d3a0ae 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,8 @@ jobs: os: [ubuntu-latest, macos-latest] steps: + - uses: actions/checkout@v1 + - name: Build run: ./build.sh From 3d59ab3b28c7a20961eb69cf1f5e44a7b5c85df1 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:20:39 +0200 Subject: [PATCH 221/238] * add automake on macos --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1d3a0ae..af35fb93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,10 @@ jobs: steps: - uses: actions/checkout@v1 + - name: Install automake (macos) + if: startsWith(runner.OS, 'darwin') + run: brew install automake + - name: Build run: ./build.sh From 28f3e607aa9617a0ea0b663a26eef2738a24ea4b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:24:24 +0200 Subject: [PATCH 222/238] * add automake on macos --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af35fb93..d87e6841 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v1 - name: Install automake (macos) - if: startsWith(runner.OS, 'darwin') + if: startsWith(runner.OS, 'macOS') run: brew install automake - name: Build From 23168648d65245648518c697f6cee8b66ef91648 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:27:11 +0200 Subject: [PATCH 223/238] * adjust testing --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d87e6841..70a576a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,11 +29,14 @@ jobs: - name: Build run: ./build.sh + - name: Build tests + run: cd test && make + - name: Test Success Frames - run: cd test && make && ./generate-xml.sh test-frames + run: ./generate-xml.sh test-frames - name: Test Error Frames - run: cd test && make && ./generate-xml.sh test/error-frames || true + run: ./generate-xml.sh error-frames || true - name: Test Unsupported Frames - run: cd test && make && ./generate-xml.sh test/unsupported-frames || true + run: ./generate-xml.sh unsupported-frames || true From 83689c7f6d7dd6ef1d185a59d2f503a9a7d8bd4b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:28:52 +0200 Subject: [PATCH 224/238] * adjust testing --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70a576a0..93bd579e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,10 +33,10 @@ jobs: run: cd test && make - name: Test Success Frames - run: ./generate-xml.sh test-frames + run: ./test/generate-xml.sh test/test-frames - name: Test Error Frames - run: ./generate-xml.sh error-frames || true + run: ./test/generate-xml.sh test/error-frames || true - name: Test Unsupported Frames - run: ./generate-xml.sh unsupported-frames || true + run: ./test/generate-xml.sh test/unsupported-frames || true From b15defbf41fc90fe404b17dfd9494ac740f4e6c3 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:30:05 +0200 Subject: [PATCH 225/238] * adjust testing --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93bd579e..2ac1d690 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,10 +33,10 @@ jobs: run: cd test && make - name: Test Success Frames - run: ./test/generate-xml.sh test/test-frames + run: cd test && ./generate-xml.sh test-frames - name: Test Error Frames - run: ./test/generate-xml.sh test/error-frames || true + run: cd test && ./generate-xml.sh error-frames || true - name: Test Unsupported Frames - run: ./test/generate-xml.sh test/unsupported-frames || true + run: cd test && ./generate-xml.sh unsupported-frames || true From fc8bb5ec1d058aeea1bd9a25f9c4f6cb0d9d2b04 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:32:32 +0200 Subject: [PATCH 226/238] * remove travis --- .travis.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 70b00795..00000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: c - -compiler: - - gcc - - clang - -os: - - linux - - osx - -script: - - ./build.sh - - cd test && make && ./generate-xml.sh test-frames - - cd test && make && ./generate-xml.sh test/error-frames || true - - cd test && make && ./generate-xml.sh test/unsupported-frames || true From 5c64b5e24035791864f1e1a6606bc09b3a2bb766 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:43:31 +0200 Subject: [PATCH 227/238] * try add windows tests too --- .github/workflows/test.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2ac1d690..15601117 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,9 +26,18 @@ jobs: if: startsWith(runner.OS, 'macOS') run: brew install automake - - name: Build + - name: Build (Linux/macOS) + if: !startsWith(runner.OS, 'Windows') run: ./build.sh + - name: Prepair WIndows build + if: startsWith(runner.OS, 'Windows') + uses: microsoft/setup-msbuild@v1.1 + + - name: Build (Windows) + if: startsWith(runner.OS, 'Windows') + run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release + - name: Build tests run: cd test && make From cf1c5449a00294301d86a9da74b91b15ed5ea914 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:44:58 +0200 Subject: [PATCH 228/238] * try add windows tests too --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 15601117..a7e3afa1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,10 +27,10 @@ jobs: run: brew install automake - name: Build (Linux/macOS) - if: !startsWith(runner.OS, 'Windows') + if: startsWith(runner.OS, 'linux') || startsWith(runner.OS, 'macOS') run: ./build.sh - - name: Prepair WIndows build + - name: Prepare Windows build if: startsWith(runner.OS, 'Windows') uses: microsoft/setup-msbuild@v1.1 From bfa5c26c86d338bbf649ca0b9cd8a7610471671e Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:45:29 +0200 Subject: [PATCH 229/238] * try add windows tests too --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a7e3afa1..ed10e09c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-2019] steps: - uses: actions/checkout@v1 From 9e30d8d31001d9f0496e941e0c478bddcffb5b25 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:46:52 +0200 Subject: [PATCH 230/238] * try add windows tests too --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ed10e09c..36b247a2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: - name: Build (Windows) if: startsWith(runner.OS, 'Windows') - run: msbuild src\YourProjectFile.csproj -t:rebuild -verbosity:diag -property:Configuration=Release + run: msbuild libmbus.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release - name: Build tests run: cd test && make From f071d3a4a6f102032870c7db4385c2a497671bea Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 14:58:42 +0200 Subject: [PATCH 231/238] * try add windows tests too --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36b247a2..4c756b95 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,6 +34,13 @@ jobs: if: startsWith(runner.OS, 'Windows') uses: microsoft/setup-msbuild@v1.1 + - name: Install Windows 8.1 SDK + if: startsWith(runner.OS, 'Windows') + shell: powershell + run: | + Invoke-WebRequest -Method Get -Uri https://go.microsoft.com/fwlink/p/?LinkId=323507 -OutFile sdksetup.exe -UseBasicParsing + Start-Process -Wait sdksetup.exe -ArgumentList "/q", "/norestart", "/features", "OptionId.WindowsDesktopSoftwareDevelopmentKit", "OptionId.NetFxSoftwareDevelopmentKit" + - name: Build (Windows) if: startsWith(runner.OS, 'Windows') run: msbuild libmbus.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release From caf4c6241256bd1d0d03f9bea00fb214f0ed5190 Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Wed, 29 Jun 2022 15:03:11 +0200 Subject: [PATCH 232/238] * try add windows tests too --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4c756b95..ea53e438 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,13 +46,17 @@ jobs: run: msbuild libmbus.vcxproj -t:rebuild -verbosity:diag -property:Configuration=Release - name: Build tests + if: startsWith(runner.OS, 'linux') || startsWith(runner.OS, 'macOS') run: cd test && make - name: Test Success Frames + if: startsWith(runner.OS, 'linux') || startsWith(runner.OS, 'macOS') run: cd test && ./generate-xml.sh test-frames - name: Test Error Frames + if: startsWith(runner.OS, 'linux') || startsWith(runner.OS, 'macOS') run: cd test && ./generate-xml.sh error-frames || true - name: Test Unsupported Frames + if: startsWith(runner.OS, 'linux') || startsWith(runner.OS, 'macOS') run: cd test && ./generate-xml.sh unsupported-frames || true From 0668dc65756ccb242686f847cc34b89723b220fb Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 27 Dec 2021 21:24:34 +0100 Subject: [PATCH 233/238] mbus_data_record_decode: print negative BCD values This hack makes mbus_data_record_decode print errors still as hex, but allow negative BCD values for the rest. (cherry picked from commit 48d25a86d6d9ae813c6690e344185ab98333f64e) --- mbus/mbus-protocol.c | 60 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/mbus/mbus-protocol.c b/mbus/mbus-protocol.c index 7f9d74aa..6aebed1d 100755 --- a/mbus/mbus-protocol.c +++ b/mbus/mbus-protocol.c @@ -3294,8 +3294,16 @@ mbus_data_record_decode(mbus_data_record *record) case 0x09: // 2 digit BCD (8 bit) - int_val = (int)mbus_data_bcd_decode_hex(record->data, 1); - snprintf(buff, sizeof(buff), "%X", int_val); + if ((record->drh.dib.dif & MBUS_DATA_RECORD_DIF_MASK_FUNCTION) == 0x30) + { + int_val = (int)mbus_data_bcd_decode_hex(record->data, 1); + snprintf(buff, sizeof(buff), "%X", int_val); + } + else + { + int_val = (int)mbus_data_bcd_decode(record->data, 1); + snprintf(buff, sizeof(buff), "%d", int_val); + } if (debug) printf("%s: DIF 0x%.2x was decoded using 2 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -3304,8 +3312,16 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0A: // 4 digit BCD (16 bit) - int_val = (int)mbus_data_bcd_decode_hex(record->data, 2); - snprintf(buff, sizeof(buff), "%X", int_val); + if ((record->drh.dib.dif & MBUS_DATA_RECORD_DIF_MASK_FUNCTION) == 0x30) + { + int_val = (int)mbus_data_bcd_decode_hex(record->data, 2); + snprintf(buff, sizeof(buff), "%X", int_val); + } + else + { + int_val = (int)mbus_data_bcd_decode(record->data, 2); + snprintf(buff, sizeof(buff), "%d", int_val); + } if (debug) printf("%s: DIF 0x%.2x was decoded using 4 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -3314,8 +3330,16 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0B: // 6 digit BCD (24 bit) - int_val = (int)mbus_data_bcd_decode_hex(record->data, 3); - snprintf(buff, sizeof(buff), "%X", int_val); + if ((record->drh.dib.dif & MBUS_DATA_RECORD_DIF_MASK_FUNCTION) == 0x30) + { + int_val = (int)mbus_data_bcd_decode_hex(record->data, 3); + snprintf(buff, sizeof(buff), "%X", int_val); + } + else + { + int_val = (int)mbus_data_bcd_decode(record->data, 3); + snprintf(buff, sizeof(buff), "%d", int_val); + } if (debug) printf("%s: DIF 0x%.2x was decoded using 6 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -3324,8 +3348,16 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0C: // 8 digit BCD (32 bit) - int_val = (int)mbus_data_bcd_decode_hex(record->data, 4); - snprintf(buff, sizeof(buff), "%X", int_val); + if ((record->drh.dib.dif & MBUS_DATA_RECORD_DIF_MASK_FUNCTION) == 0x30) + { + int_val = (int)mbus_data_bcd_decode_hex(record->data, 4); + snprintf(buff, sizeof(buff), "%X", int_val); + } + else + { + int_val = (int)mbus_data_bcd_decode(record->data, 4); + snprintf(buff, sizeof(buff), "%d", int_val); + } if (debug) printf("%s: DIF 0x%.2x was decoded using 8 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); @@ -3334,8 +3366,16 @@ mbus_data_record_decode(mbus_data_record *record) case 0x0E: // 12 digit BCD (48 bit) - long_long_val = mbus_data_bcd_decode_hex(record->data, 6); - snprintf(buff, sizeof(buff), "%llX", long_long_val); + if ((record->drh.dib.dif & MBUS_DATA_RECORD_DIF_MASK_FUNCTION) == 0x30) + { + long_long_val = mbus_data_bcd_decode_hex(record->data, 6); + snprintf(buff, sizeof(buff), "%llX", long_long_val); + } + else + { + long_long_val = mbus_data_bcd_decode(record->data, 6); + snprintf(buff, sizeof(buff), "%lld", long_long_val); + } if (debug) printf("%s: DIF 0x%.2x was decoded using 12 digit BCD\n", __PRETTY_FUNCTION__, record->drh.dib.dif); From 0293238d7330751fce77d9b0e5d60f62cf99a281 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Mon, 27 Dec 2021 21:25:59 +0100 Subject: [PATCH 234/238] test-frames: adapt to new output (cherry picked from commit f775d198a10e8153c08fe6db147bd1deda571a9a) --- test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml | 2 +- test/test-frames/landis+gyr_ultraheat_t230.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml index c2492218..f120b186 100644 --- a/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml +++ b/test/test-frames/SLB_CF-Compact-Integral-MK-MaXX.xml @@ -58,7 +58,7 @@ Instantaneous value 0 Temperature Difference (1e-2 deg C) - F00018 + -18 diff --git a/test/test-frames/landis+gyr_ultraheat_t230.xml b/test/test-frames/landis+gyr_ultraheat_t230.xml index ea3a8791..154261a4 100644 --- a/test/test-frames/landis+gyr_ultraheat_t230.xml +++ b/test/test-frames/landis+gyr_ultraheat_t230.xml @@ -72,7 +72,7 @@ Instantaneous value 0 Temperature Difference (1e-1 deg C) - F00002 + -2 From 827241a18c4c9a7de9f40512964a48839a640f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Krac=C3=ADk?= Date: Tue, 19 Mar 2024 19:30:24 +0100 Subject: [PATCH 235/238] Support IPv6 (#213) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rewritten TCP connection to support IPv6 and get rid of deprecated gethostbyname Signed-off-by: Petr Kracík (cherry picked from commit cb28aca76e79d7852e3bf3c052c46f664d0fcdf5) --- mbus/mbus-tcp.c | 52 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index 7d784368..c089bf5a 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -32,8 +32,6 @@ typedef SSIZE_T ssize_t; #else #include #include -#include -#include #include #include #endif @@ -50,6 +48,7 @@ typedef SSIZE_T ssize_t; #include "mbus-tcp.h" #define PACKET_BUFF_SIZE 2048 +#define MAX_PORT_SIZE 6 // Size of port number + NULL char static int tcp_timeout_sec = 4; static int tcp_timeout_usec = 0; @@ -61,11 +60,11 @@ int mbus_tcp_connect(mbus_handle *handle) { char error_str[128], *host; - struct hostent *host_addr; - struct sockaddr_in s; + struct addrinfo hints, *servinfo, *p; struct timeval time_out; mbus_tcp_data *tcp_data; - uint16_t port; + char port[MAX_PORT_SIZE]; + int status; if (handle == NULL) return -1; @@ -75,7 +74,7 @@ mbus_tcp_connect(mbus_handle *handle) return -1; host = tcp_data->host; - port = tcp_data->port; + snprintf(port, MAX_PORT_SIZE, "%d", tcp_data->port); #ifdef _WIN32 WORD wVersionRequested; @@ -94,32 +93,41 @@ mbus_tcp_connect(mbus_handle *handle) return -1; } #endif - // - // create the TCP connection - // - if ((handle->fd = socket(AF_INET,SOCK_STREAM, 0)) < 0) + + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + if ((status = getaddrinfo(host, port, &hints, &servinfo)) != 0) { - snprintf(error_str, sizeof(error_str), "%s: failed to setup a socket.", __PRETTY_FUNCTION__); + snprintf(error_str, sizeof(error_str), "%s: getaddrinfo: %s", __PRETTY_FUNCTION__, gai_strerror(status)); mbus_error_str_set(error_str); return -1; } - s.sin_family = AF_INET; - s.sin_port = htons(port); - - /* resolve hostname */ - if ((host_addr = gethostbyname(host)) == NULL) + // loop through all the results and connect to the first we can + for (p = servinfo; p != NULL; p = p->ai_next) { - snprintf(error_str, sizeof(error_str), "%s: unknown host: %s", __PRETTY_FUNCTION__, host); - mbus_error_str_set(error_str); - return -1; + if ((handle->fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) + { + continue; + } + + if (connect(handle->fd, p->ai_addr, p->ai_addrlen) == -1) + { + close(handle->fd); + continue; + } + + break; // if we get here, we must have connected successfully } - memcpy((void *)(&s.sin_addr), (void *)(host_addr->h_addr), host_addr->h_length); + // Free addr info, we do not need it anymore + freeaddrinfo(servinfo); - if (connect(handle->fd, (struct sockaddr *)&s, sizeof(s)) < 0) + if (p == NULL) { - snprintf(error_str, sizeof(error_str), "%s: Failed to establish connection to %s:%d", __PRETTY_FUNCTION__, host, port); + snprintf(error_str, sizeof(error_str), "%s: Failed to establish connection to %s:%s", __PRETTY_FUNCTION__, host, port); mbus_error_str_set(error_str); return -1; } From c85171bf25e9ca5dc5d531340568d61ecf67a60b Mon Sep 17 00:00:00 2001 From: Ingo Fischer Date: Tue, 26 Mar 2024 18:45:27 +0100 Subject: [PATCH 236/238] try adjust windows build --- mbus/mbus-tcp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mbus/mbus-tcp.c b/mbus/mbus-tcp.c index c089bf5a..d4498ee2 100755 --- a/mbus/mbus-tcp.c +++ b/mbus/mbus-tcp.c @@ -17,6 +17,7 @@ #include #include #include +#include #include typedef SSIZE_T ssize_t; From 77fabb7cb606c0ee2588ad01f37996535db4eb96 Mon Sep 17 00:00:00 2001 From: lin Date: Fri, 5 Apr 2024 13:14:00 +0800 Subject: [PATCH 237/238] Bug: serial baud rate 1200 --- win/termiWin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/termiWin.h b/win/termiWin.h index ba93478d..e8b3be5d 100644 --- a/win/termiWin.h +++ b/win/termiWin.h @@ -116,7 +116,7 @@ //Baud speed #define B300 CBR_300 #define B600 CBR_600 -#define B1200 CBR_2400 +#define B1200 CBR_1200 #define B2400 CBR_2400 #define B4800 CBR_4800 #define B9600 CBR_9600 From 3dee40a01396cd3220bb8d27b0df3dac825effb2 Mon Sep 17 00:00:00 2001 From: lin Date: Fri, 5 Apr 2024 14:32:48 +0800 Subject: [PATCH 238/238] Project files for build utils --- .gitignore | 5 +- libmbus.vcxproj | 96 ++++++----- mbus-serial-request-data-multi-reply.vcxproj | 167 +++++++++++++++++++ mbus-serial-request-data.vcxproj | 167 +++++++++++++++++++ mbus-serial-scan-secondary.vcxproj | 167 +++++++++++++++++++ mbus-serial-scan.vcxproj | 167 +++++++++++++++++++ mbus-serial-select-secondary.vcxproj | 167 +++++++++++++++++++ mbus-serial-set-address.vcxproj | 167 +++++++++++++++++++ mbus-serial-switch-baudrate.vcxproj | 167 +++++++++++++++++++ mbus/mbus.h | 5 + 10 files changed, 1229 insertions(+), 46 deletions(-) create mode 100644 mbus-serial-request-data-multi-reply.vcxproj create mode 100644 mbus-serial-request-data.vcxproj create mode 100644 mbus-serial-scan-secondary.vcxproj create mode 100644 mbus-serial-scan.vcxproj create mode 100644 mbus-serial-select-secondary.vcxproj create mode 100644 mbus-serial-set-address.vcxproj create mode 100644 mbus-serial-switch-baudrate.vcxproj diff --git a/.gitignore b/.gitignore index 1136a1aa..2306a166 100644 --- a/.gitignore +++ b/.gitignore @@ -73,7 +73,10 @@ test/unsupported-frames/*.xml.new /build/ _build/ +/Debug/ +/Release/ # IDE /.vscode/ -CMakeLists.txt.user \ No newline at end of file +/.vs/ +CMakeLists.txt.user diff --git a/libmbus.vcxproj b/libmbus.vcxproj index 8b489f02..e25bce3b 100644 --- a/libmbus.vcxproj +++ b/libmbus.vcxproj @@ -1,26 +1,26 @@ - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + - Release - Debug + Release + Debug {B03220E0-285E-8766-5959-75355F21213E} @@ -28,35 +28,37 @@ libmbus true x64 + libmbus + 10.0 - + StaticLibrary - v140 + v142 - - - + + + - + - + $(ExecutablePath);$(MSBuildProjectDirectory)\..\bin\;$(MSBuildProjectDirectory)\..\bin\ - $(Configuration)\obj\$(ProjectName)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ false true false true - $(SolutionDir)$(Configuration)\ + $(SolutionDir)$(Configuration)\$(Platform)\ $(ProjectName) $(OutDir)\$(ProjectName)$(TargetExt) - .\mbus;%(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) EnableFastChecks true false @@ -78,7 +80,8 @@ $(OutDir)$(ProjectName)$(TargetExt) - + + /ignore:4199 %(AdditionalOptions) true true @@ -97,7 +100,7 @@ - .\mbus;%(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) /MP %(AdditionalOptions) true false @@ -125,7 +128,8 @@ $(OutDir)$(ProjectName)$(TargetExt) - + + /ignore:4199 %(AdditionalOptions) true true @@ -147,7 +151,7 @@ - .\mbus;%(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) EnableFastChecks true false @@ -169,7 +173,8 @@ $(OutDir)$(ProjectName)$(TargetExt) - + + /ignore:4199 %(AdditionalOptions) true true @@ -188,7 +193,7 @@ - .\mbus;%(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) /MP %(AdditionalOptions) true false @@ -216,7 +221,8 @@ $(OutDir)$(ProjectName)$(TargetExt) - + + /ignore:4199 %(AdditionalOptions) true true @@ -237,14 +243,14 @@ - - - - - - + + + + + + - - - - + + + + \ No newline at end of file diff --git a/mbus-serial-request-data-multi-reply.vcxproj b/mbus-serial-request-data-multi-reply.vcxproj new file mode 100644 index 00000000..7d49dc42 --- /dev/null +++ b/mbus-serial-request-data-multi-reply.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {C4D9D19C-C88D-446D-B14A-57F0C5487A59} + mbus_serial_request_data_multi_reply + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + \ No newline at end of file diff --git a/mbus-serial-request-data.vcxproj b/mbus-serial-request-data.vcxproj new file mode 100644 index 00000000..6d888426 --- /dev/null +++ b/mbus-serial-request-data.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 16.0 + Win32Proj + {4551e229-8923-4561-8748-6d2d0c27ee3e} + mbus_serial_request_data + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + \ No newline at end of file diff --git a/mbus-serial-scan-secondary.vcxproj b/mbus-serial-scan-secondary.vcxproj new file mode 100644 index 00000000..63994096 --- /dev/null +++ b/mbus-serial-scan-secondary.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {3F6C7EC7-BA56-4A11-9551-1D5DDCB272DE} + mbusserialscansecondary + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/mbus-serial-scan.vcxproj b/mbus-serial-scan.vcxproj new file mode 100644 index 00000000..3fb0667c --- /dev/null +++ b/mbus-serial-scan.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {1fb54c4e-350c-4ba5-9892-80ec3fd95c94} + mbusserialscan + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/mbus-serial-select-secondary.vcxproj b/mbus-serial-select-secondary.vcxproj new file mode 100644 index 00000000..f0960b8b --- /dev/null +++ b/mbus-serial-select-secondary.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {8E02C033-2D69-49A4-B0AD-756FF4063F7C} + mbusserialselectsecondary + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/mbus-serial-set-address.vcxproj b/mbus-serial-set-address.vcxproj new file mode 100644 index 00000000..c3a6e3db --- /dev/null +++ b/mbus-serial-set-address.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {6327DE5C-FA2D-409E-8AA2-8E3806C3F4D7} + mbusserialsetaddress + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/mbus-serial-switch-baudrate.vcxproj b/mbus-serial-switch-baudrate.vcxproj new file mode 100644 index 00000000..c8513122 --- /dev/null +++ b/mbus-serial-switch-baudrate.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {5BAFA825-7CF6-40BC-A4A3-C30CDC878F9A} + mbusserialswitchbaudrate + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + true + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\obj\$(ProjectName)\$(Platform)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + $(SolutionDir)$(Configuration)\$(Platform)\ + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(SolutionDir) + + + Console + true + true + true + libmbus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + $(SolutionDir)$(Configuration)\$(Platform)\ + + + + + + + + + \ No newline at end of file diff --git a/mbus/mbus.h b/mbus/mbus.h index 264c8e0b..310904a9 100644 --- a/mbus/mbus.h +++ b/mbus/mbus.h @@ -42,6 +42,11 @@ extern "C" { #endif +#ifdef _WIN32 +#define __PRETTY_FUNCTION__ __FUNCSIG__ +#define strdup _strdup +#endif + // // //