3 Commits

Author SHA1 Message Date
2dc3daaf70 Prepare new release 0.9.0 2019-02-22 19:08:04 +01:00
36a85d3737 Add product string of Hydrometer Sharky 775 2019-02-20 22:01:47 +01:00
2f9fa5ccc8 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.
2019-02-20 22:01:47 +01:00
4 changed files with 45 additions and 13 deletions

View File

@ -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

View File

@ -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 <info@lategoodbye.de>
@ -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 <info@lategoodbye.de> - 0.9.0-1
- switch to github repo
- enable man pages
* Fri Mar 29 2013 Stefan Wahren <info@lategoodbye.de> - 0.8.0-1
- Initial package based on the last official release
- Initial package based on the last official release

View File

@ -461,9 +461,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++)
{
@ -477,6 +477,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;
}
@ -498,8 +503,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 = (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;
@ -1088,6 +1105,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"))

View File

@ -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):
--------------------------