Skip to content

Commit b93c5cf

Browse files
Merge pull request #3 from NikolasK-source/main
Release 1.1.0
2 parents 2077f47 + 6101326 commit b93c5cf

18 files changed

+578
-51
lines changed

.github/workflows/clang-format.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: clang-format Check
2+
on: [push, pull_request]
3+
jobs:
4+
formatting-check:
5+
name: Formatting Check
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: Run clang-format style check for C/C++/Protobuf programs.
10+
uses: jidicula/clang-format-action@v4.8.0
11+
with:
12+
clang-format-version: '14'
13+
check-path: 'src'
14+

.github/workflows/cmake.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CMake
2+
3+
on:
4+
push:
5+
branches: [ "main", "development" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
11+
BUILD_TYPE: Release
12+
13+
jobs:
14+
build:
15+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
16+
# You can convert this to a matrix build if you need cross-platform coverage.
17+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v3
22+
23+
- name: Init submodules
24+
run: git submodule init
25+
26+
- name: Update submodules
27+
run: git submodule update
28+
29+
- name: Configure CMake
30+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
31+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
32+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
33+
34+
- name: Build
35+
# Build your program with the given configuration
36+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
37+
38+
# - name: Test
39+
# working-directory: ${{github.workspace}}/build
40+
# Execute tests defined by the CMake configuration.
41+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
42+
# run: ctest -C ${{env.BUILD_TYPE}}
43+

.github/workflows/codeql-analysis.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "main", "development" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "main" ]
20+
schedule:
21+
- cron: '32 20 * * 0'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'cpp' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
# - name: Autobuild
59+
# uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
- run: |
68+
echo "Run, Build Application using cmake"
69+
git submodule init
70+
git submodule update
71+
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
72+
cmake --build ${{github.workspace}}/build --config Release
73+
74+
- name: Perform CodeQL Analysis
75+
uses: github/codeql-action/analyze@v2

.github/workflows/flatpak_release.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
push:
3+
branches: [release]
4+
name: Flatpak_release
5+
jobs:
6+
flatpak:
7+
name: "Flatpak"
8+
runs-on: ubuntu-latest
9+
container:
10+
image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08
11+
options: --privileged
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
15+
name: "Build"
16+
with:
17+
bundle: modbus-tcp-client-shm.flatpak
18+
manifest-path: network.koesling.modbus-tcp-client-shm.yml
19+
cache-key: flatpak-builder-${{ github.sha }}

.github/workflows/flatpak_test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
branches: [ "main", "development" ]
4+
pull_request:
5+
name: Flatpak_test
6+
jobs:
7+
flatpak:
8+
name: "Flatpak"
9+
runs-on: ubuntu-latest
10+
container:
11+
image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08
12+
options: --privileged
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Git config
17+
run: git config --global --add safe.directory /__w/modbus_tcp_client_shm/modbus_tcp_client_shm
18+
19+
- name: Init submodules
20+
run: git submodule init
21+
22+
- name: Update submodules
23+
run: git submodule update
24+
25+
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
26+
name: "Build"
27+
with:
28+
bundle: test_modbus-tcp-client-shm.flatpak
29+
manifest-path: network.koesling.test-modbus-tcp-client-shm.yml
30+
cache-key: flatpak-builder-${{ github.sha }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,4 +466,4 @@ Module.symvers
466466
Mkfile.old
467467
dkms.conf
468468

469-
!network.koesling.modbus_tcp_client_shm.yml
469+
!network.koesling.modbus-tcp-client-shm.yml

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "libs/cxxopts"]
22
path = libs/cxxopts
3-
url = https://github.com/NikolasK-source/cxxopts.git
3+
url = https://github.com/NikolasK-source/cxxopts.git
44
[submodule "libs/libmodbus"]
55
path = libs/libmodbus
66
url = https://github.com/stephane/libmodbus

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
44
# ======================================================================================================================
55

66
# project
7-
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.3)
7+
project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.1.0)
88

99
# settings
1010
set(Target "Modbus_TCP_client_shm") # Executable name (without file extension!)

docs/index.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Shared Memory Modbus TCP Client
22

3-
This project is a simple command line based Modbus TCP client for POXIX compatible operating systems that stores the contents of its registers in shared memory.
3+
This project is a simple command line based Modbus TCP client for POSIX compatible operating systems that stores the contents of its registers in shared memory.
4+
45

56
## Basic operating principle
67

@@ -29,6 +30,29 @@ This option should be used carefully, as it generates large amounts of output de
2930

3031
The ```--reconnect``` option can be used to specify that the application is not terminated when the master disconnects, but waits for a new connection.
3132

33+
The client creates four shared memories and names them ```modbus_DO```, ```modbus_DI```, ```modbus_AO``` and ```modbus_AI``` by default.
34+
The prefix modbus_ can be changed via the argument ```--name-prefix```.
35+
The suffixes for the register type (DO, DI, AO, AI) cannot be changed and will always be appended to the prefix.
36+
37+
By default, the client starts with the maximum possible number of modbus registers (65536 per register type).
38+
The number of registers can be changed using the ```--xx-registers``` (replace xx with the register type) command line arguments.
39+
40+
### Examples
41+
Start client and listen to all incoming connections on the modbus standard port:
42+
```
43+
modbus-tcp-client-shm
44+
```
45+
46+
Start client and listen to all incoming connections on port 10000 and wait for a new connection if the connection is lost:
47+
```
48+
modbus-tcp-client-shm -p 10000 -r
49+
```
50+
51+
Start client and listen to incoming connections on ip 127.0.0.1 on port 10000:
52+
```
53+
modbus-tcp-client-shm -p 10000 -i 127.0.0.1
54+
```
55+
3256
### Use privileged ports
3357
Ports below 1024 cannot be used by standard users.
3458
Therefore, the default modbus port (502) cannot be used without further action.
@@ -53,6 +77,22 @@ setcap 'cap_net_bind_service=+ep' /path/to/binary
5377
```
5478

5579

80+
## Using the Flatpak package
81+
The flatpak package can be installed via the .flatpak file.
82+
This can be downloaded from the GitHub [projects release page](https://github.com/NikolasK-source/modbus_tcp_client_shm/releases):
83+
84+
```
85+
flatpak install --user modbus-tcp-client-shm.flatpak
86+
```
87+
88+
The application is then executed as follows:
89+
```
90+
flatpak run network.koesling.modbus-tcp-client-shm
91+
```
92+
93+
To enable calling with ```modbus-tcp-client-shm``` [this script](https://gist.github.com/NikolasK-source/f0ef53fe4be7922901a1543e3cce8a97) can be used.
94+
In order to be executable everywhere, the path in which the script is placed must be in the ```PATH``` environment variable.
95+
5696

5797
## Build from Source
5898

@@ -76,3 +116,44 @@ cmake --build build
76116
```
77117

78118
The binary is located in the build directory.
119+
120+
121+
## Links to related projects
122+
123+
### General Shared Memory Tools
124+
- [Shared Memory Dump](https://nikolask-source.github.io/dump_shm/)
125+
- [Shared Memory Write](https://nikolask-source.github.io/write_shm/)
126+
- [Shared Memory Random](https://nikolask-source.github.io/shared_mem_random/)
127+
128+
### Modbus Clients
129+
- [RTU](https://nikolask-source.github.io/modbus_rtu_client_shm/)
130+
- [TCP](https://nikolask-source.github.io/modbus_tcp_client_shm/)
131+
132+
### Modbus Shared Memory Tools
133+
- [STDIN to Modbus](https://nikolask-source.github.io/stdin_to_modbus_shm/)
134+
- [Float converter](https://nikolask-source.github.io/modbus_conv_float/)
135+
136+
137+
## License
138+
139+
MIT License
140+
141+
Copyright (c) 2021-2022 Nikolas Koesling
142+
143+
Permission is hereby granted, free of charge, to any person obtaining a copy
144+
of this software and associated documentation files (the "Software"), to deal
145+
in the Software without restriction, including without limitation the rights
146+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
147+
copies of the Software, and to permit persons to whom the Software is
148+
furnished to do so, subject to the following conditions:
149+
150+
The above copyright notice and this permission notice shall be included in all
151+
copies or substantial portions of the Software.
152+
153+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
154+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
155+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
156+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
157+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
158+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
159+
SOFTWARE.

network.koesling.modbus_tcp_client_shm.yml renamed to network.koesling.modbus-tcp-client-shm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
id: network.koesling.modbus_tcp_client_shm
1+
id: network.koesling.modbus-tcp-client-shm
22
runtime: org.freedesktop.Platform
33
runtime-version: '21.08'
44
sdk: org.freedesktop.Sdk
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
id: network.koesling.test-modbus-tcp-client-shm
2+
runtime: org.freedesktop.Platform
3+
runtime-version: '21.08'
4+
sdk: org.freedesktop.Sdk
5+
command: Modbus_TCP_client_shm
6+
finish-args:
7+
- --device=shm
8+
- --share=network
9+
modules:
10+
- name: Modbus_TCP_client_shm
11+
buildsystem: simple
12+
build-commands:
13+
# build
14+
- mkdir build
15+
- cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
16+
- cmake --build build
17+
18+
# install
19+
- mkdir -p "${FLATPAK_DEST}/bin"
20+
- cp build/Modbus_TCP_client_shm ${FLATPAK_DEST}/bin
21+
- ls -lah ${FLATPAK_DEST}
22+
sources:
23+
- type: dir
24+
path: .
25+

0 commit comments

Comments
 (0)