Merge pull request #91 from lategoodbye/upstream-merge

Upstream merge
This commit is contained in:
Stefan Wahren 2016-01-31 19:19:03 +01:00
commit 012dc5ba36
5 changed files with 97 additions and 43 deletions

View File

@ -857,6 +857,7 @@ int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real,
MBUS_ERROR("Unable to allocate memory");
return -1;
}
*value_out_str[0] = '\0';
*value_out_str_size = 0;
result = 0;
break;
@ -1362,7 +1363,7 @@ mbus_data_variable_xml_normalized(mbus_data_variable *data)
mbus_data_record *record;
mbus_record *norm_record;
char *buff = NULL, *new_buff = NULL;
char str_encoded[768];
char str_encoded[768] = "";
size_t len = 0, buff_size = 8192;
size_t i;

View File

@ -429,7 +429,7 @@ int mbus_data_fixed_normalize(int medium_unit_byte, long medium_value, char **un
*
* @return zero when OK
*/
int mbus_data_variable_value_decode(mbus_record *record, double *value_out_real, char **value_out_str, int *value_out_str_size);
int mbus_variable_value_decode(mbus_data_record *record, double *value_out_real, char **value_out_str, int *value_out_str_size);
/**
* Decode units and normalize value using VIF/VIFE (used internally by mbus_vib_unit_normalize)

View File

@ -893,6 +893,30 @@ mbus_data_product_name(mbus_data_variable_header *header)
break;
}
}
else if (manufacturer == mbus_manufacturer_id("BEC"))
{
if (header->medium == MBUS_VARIABLE_DATA_MEDIUM_ELECTRICITY)
{
switch (header->version)
{
case 0x00:
strcpy(buff,"Berg DCMi");
break;
case 0x07:
strcpy(buff,"Berg BLMi");
break;
}
}
else if (header->medium == MBUS_VARIABLE_DATA_MEDIUM_UNKNOWN)
{
switch (header->version)
{
case 0x71:
strcpy(buff, "Berg BMB-10S0");
break;
}
}
}
else if (manufacturer == mbus_manufacturer_id("EFE"))
{
switch (header->version)
@ -956,6 +980,28 @@ mbus_data_product_name(mbus_data_variable_header *header)
}
}
}
else if (manufacturer == mbus_manufacturer_id("GAV"))
{
if (header->medium == MBUS_VARIABLE_DATA_MEDIUM_ELECTRICITY)
{
switch (header->version)
{
case 0x2D:
case 0x2E:
case 0x2F:
case 0x30:
strcpy(buff,"Carlo Gavazzi EM24");
break;
case 0x39:
case 0x3A:
strcpy(buff,"Carlo Gavazzi EM21");
break;
case 0x40:
strcpy(buff,"Carlo Gavazzi EM33");
break;
}
}
}
else if (manufacturer == mbus_manufacturer_id("GMC"))
{
switch (header->version)
@ -3654,7 +3700,7 @@ mbus_data_error_print(int error)
/// Encode string to XML
///
//------------------------------------------------------------------------------
void
int
mbus_str_xml_encode(unsigned char *dst, const unsigned char *src, size_t max_len)
{
size_t i, len;
@ -3663,10 +3709,16 @@ mbus_str_xml_encode(unsigned char *dst, const unsigned char *src, size_t max_len
len = 0;
if (dst == NULL)
return;
if (src != NULL)
{
return -1;
}
if (src == NULL)
{
dst[len] = '\0';
return -2;
}
while((len+6) < max_len)
{
if (src[i] == '\0')
@ -3703,9 +3755,9 @@ mbus_str_xml_encode(unsigned char *dst, const unsigned char *src, size_t max_len
i++;
}
}
dst[len] = '\0';
return 0;
}
//------------------------------------------------------------------------------

View File

@ -498,7 +498,7 @@ typedef struct _mbus_data_secondary_address {
//
unsigned int mbus_manufacturer_id(char *manufacturer);
// Since libmbus writes some special characters (ASCII > 0x7F) into the XML output (e.g. °C for centigrade == ASCII 0xB0)
// Since libmbus writes some special characters (ASCII > 0x7F) into the XML output (e.g. <EFBFBD>C for centigrade == ASCII 0xB0)
// it is useful to attach the appropriate code page for postprocessing.
#define MBUS_XML_PROCESSING_INSTRUCTION "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
@ -569,7 +569,7 @@ mbus_slave_data *mbus_slave_data_get(size_t i);
//
// XML generating functions
//
void mbus_str_xml_encode(unsigned char *dst, const unsigned char *src, size_t max_len);
int mbus_str_xml_encode(unsigned char *dst, const unsigned char *src, size_t max_len);
char *mbus_data_xml(mbus_frame_data *data);
char *mbus_data_variable_xml(mbus_data_variable *data);
char *mbus_data_fixed_xml(mbus_data_fixed *data);

View File

@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
#include "mbus-protocol.h"
#include "../config.h"
//
//
@ -19,4 +20,4 @@ int mbus_init() {return 0;}
/// Return current version of the library
///
const char*
mbus_get_current_version() {return "0.8.0";}
mbus_get_current_version() {return VERSION;}