Compare commits

...

2 Commits

Author SHA1 Message Date
Stefan Wahren
5bab975c70 changelog: Add release 0.9.0 2020-07-19 12:57:16 +02:00
Stefan Wahren
5588d2614b build: temporary revert to autotools (#174)
As long as cmake doesn't generate suitable deb packages, we need to
switch back :(
2020-07-19 12:53:59 +02:00
24 changed files with 411 additions and 562 deletions

View File

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

View File

@ -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 "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
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 <info@lategoodbye.de>")
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 <info@lategoodbye.de>")
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()

View File

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

View File

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

View File

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

25
Makefile-static Normal file
View File

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

20
Makefile.am Normal file
View File

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

View File

@ -1,6 +1,4 @@
# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) <span style="float:right;"><a href="https://travis-ci.org/rscada/libmbus" style="border-bottom:none">
![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master)</a></span>
# libmbus: M-bus Library from Raditex Control (http://www.rscada.se) <span style="float:right;"><a href="https://travis-ci.org/rscada/libmbus" style="border-bottom:none">![Build Status](https://travis-ci.org/rscada/libmbus.svg?branch=master)</a></span>
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

View File

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

24
bin/Makefile-static Normal file
View File

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

102
bin/Makefile.am Normal file
View File

@ -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 '\<POD ERRORS\>' $@ >/dev/null 2>&1; \
then \
echo "$@ has some POD errors!"; false; \
fi

25
build-deb.sh Executable file
View File

@ -0,0 +1,25 @@
# ------------------------------------------------------------------------------
# Copyright (C) 2012, Robert Johansson <rob@raditex.nu>, 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

View File

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

View File

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

View File

@ -1,4 +0,0 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components("@PROJECT_NAME@")

44
configure.ac Normal file
View File

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

12
debian/changelog vendored
View File

@ -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 <stefan.wahren@i2se.com> Fri, 22 Feb 2019 19:08:04 +0100
libmbus (0.8.0) precise; urgency=low
* New official release. Includes support for multi-telegram communication.

View File

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

View File

@ -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}
Cflags: -I${includedir}

87
libmbus.spec Normal file
View File

@ -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 <info@lategoodbye.de>
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 <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

20
mbus/Makefile.am Normal file
View File

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

View File

@ -1,56 +0,0 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine HAVE_DLFCN_H "@HAVE_DLFCN_H@"
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine HAVE_INTTYPES_H "@HAVE_INTTYPES_H@"
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine HAVE_MEMORY_H "@HAVE_MEMORY_H@"
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H "@HAVE_STDINT_H@"
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine HAVE_STDLIB_H "@HAVE_STDLIB_H@"
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine HAVE_STRINGS_H "@HAVE_STRINGS_H@"
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine HAVE_STRING_H "@HAVE_STRING_H@"
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine HAVE_SYS_STAT_H "@HAVE_SYS_STAT_H@"
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine HAVE_SYS_TYPES_H "@HAVE_SYS_TYPES_H@"
/* Define to 1 if you have the <unistd.h> 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@"

View File

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

25
test/Makefile.am Normal file
View File

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