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 +