Skip to content

Commit

Permalink
Merge branch 'Krzysztow:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
webconn authored Jan 12, 2023
2 parents a327424 + d7af2b2 commit 59c3fc1
Show file tree
Hide file tree
Showing 9 changed files with 329 additions and 26 deletions.
35 changes: 35 additions & 0 deletions .gear/modbus-utils.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
%define unpackaged_files_terminate_build 1

Name: modbus-utils
Version: 1.0.0
Release: alt1

Summary: CLI utilities to work with Modbus devices
License: %mit
Group: Other
Url: https://github.com/Krzysztow/modbus-utils
Source0: %name-%version.tar

BuildRequires(pre): rpm-build-licenses
BuildRequires(pre): rpm-macros-cmake
BuildRequires: cmake
BuildRequires: libmodbus-devel

%description
Client and server CLI utilities to work with Modbus devices

%prep
%setup -q

%build
%cmake
%install
%cmakeinstall_std
%files
%_bindir/modbus_client
%_bindir/modbus_server

%changelog
* Tue Aug 10 2021 Aleksey Saprunov <[email protected]> 1.0.0-alt1
- Initial release

2 changes: 2 additions & 0 deletions .gear/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
spec: .gear/modbus-utils.spec
tar: .
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.10)

project(modbus-utils VERSION 1.0.0 LANGUAGES C)

find_package(PkgConfig REQUIRED)
pkg_check_modules(MODBUS REQUIRED IMPORTED_TARGET libmodbus)

add_executable(modbus_client "${CMAKE_CURRENT_SOURCE_DIR}/modbus_client/modbus_client.c")
target_link_libraries(modbus_client PkgConfig::MODBUS)
target_include_directories(modbus_client PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/common" "${MODBUS_INCLUDE_DIRS}")

add_executable(modbus_server "${CMAKE_CURRENT_SOURCE_DIR}/modbus_server/modbus_server.c")
target_link_libraries(modbus_server PkgConfig::MODBUS)
target_include_directories(modbus_server PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/common" "${MODBUS_INCLUDE_DIRS}")

install(TARGETS modbus_server modbus_client DESTINATION ${CMAKE_INSTALL_BINDIR}
RUNTIME DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
25 changes: 25 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The MIT License (MIT)
=====================

Copyright © `2013` `Krzysztow`

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,32 @@ Both apps are linked with libmodbus library. After repository is pulled do the f
compilation
===========

## option 1 (cmake)

```sh
$ git clone https://github.com/Krzysztow/modbus-utils
$ cd modbus-utils
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ make
```

## option 2

#assumes you are in a root of the repository

#go to libmodbus dir and compile it

cd ./libmodbus
./configure
./make

#as a result *.so libraries are in export ./src/.libs/ directory

#get back to the root

cd ..
gcc ./modbus_client/modbus_client.c -I./common -I./libmodbus/src/ -L./libmodbus/src/.libs/ -lmodbus -o mbClient
gcc ./modbus_server/modbus_server.c -I./common -I./libmodbus/src/ -L./libmodbus/src/.libs/ -lmodbus -o mbServer
Expand Down
24 changes: 24 additions & 0 deletions common/mbu-common.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/*
* MIT License
* Copyright (c) 2013 Krzysztow
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#ifndef MBU_COMMON_H
#define MBU_COMMON_H

Expand Down
26 changes: 25 additions & 1 deletion modbus_client/modbus_client.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
/*
* MIT License
* Copyright (c) 2013 Krzysztow
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include <stdio.h> /* for printf */
#include <stdlib.h> /* for exit */
#include <getopt.h>
#include <string.h>
#include <stdint.h>

#include "modbus.h"
#include <modbus.h>
#include "errno.h"

#include "mbu-common.h"
Expand Down
Loading

0 comments on commit 59c3fc1

Please sign in to comment.