Skip to content

Commit bc58b82

Browse files
Merge pull request #6 from NikolasK-source/main
Release 0.1.3
2 parents 89a0647 + b86610b commit bc58b82

File tree

10 files changed

+354
-5
lines changed

10 files changed

+354
-5
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: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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}}

.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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
on:
2+
push:
3+
branches: [release]
4+
pull_request:
5+
name: Flatpak_release
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+
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
16+
name: "Build"
17+
with:
18+
bundle: write-shm.flatpak
19+
manifest-path: network.koesling.write-shm.yml
20+
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/write_shm/write_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_write-shm.flatpak
29+
manifest-path: network.koesling.test-write-shm.yml
30+
cache-key: flatpak-builder-${{ github.sha }}

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR)
44
# ======================================================================================================================
55

66
# project
7-
project(write_shm LANGUAGES CXX VERSION 0.1.2)
7+
project(write-shm LANGUAGES CXX VERSION 0.1.3)
88

99
# settings
10-
set(Target "write_shm") # Executable name (without file extension!)
10+
set(Target "write-shm") # Executable name (without file extension!)
1111
set(STANDARD 17) # C++ Standard
1212
set(ARCHITECTURE "native") # CPU architecture to optimize for (only relevant if OPTIMIZE_FOR_ARCHITECTURE is ON)
1313

@@ -43,6 +43,7 @@ endif()
4343

4444
# add executable
4545
add_executable(${Target})
46+
install(TARGETS ${Target})
4647

4748
# set source and libraries directory
4849
add_subdirectory("src")
@@ -55,9 +56,11 @@ set_target_properties(${Target} PROPERTIES
5556
CXX_EXTENSIONS ${COMPILER_EXTENSIONS}
5657
)
5758

58-
# project version and name
59+
# compiler definitions
5960
target_compile_definitions(${Target} PUBLIC "PROJECT_VERSION=\"${CMAKE_PROJECT_VERSION}\"")
6061
target_compile_definitions(${Target} PUBLIC "PROJECT_NAME=\"${CMAKE_PROJECT_NAME}\"")
62+
target_compile_definitions(${Target} PUBLIC "COMPILER_INFO=\"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}\"")
63+
target_compile_definitions(${Target} PUBLIC "SYSTEM_INFO=\"${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR}\"")
6164

6265
# options that are valid for gcc and clang
6366
function(commonopts)

docs/index.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,119 @@
11
# Shared Memory Writer
2+
3+
This tool writes data that it reads from stdin into a named shared memory.
4+
5+
6+
## Use the Application
7+
The tool must be started with the name of the shared memory to be written to as an argument (--name).
8+
The shared memory with this name must already exist.
9+
10+
By default, the application reads as many bytes as available from stdin and writes them to shared memory.
11+
If the input is smaller than the shared memory, the excess bytes of the shared memory are not written.
12+
If the input is larger, it will be truncated to the size of the shared memory.
13+
14+
By setting the argument ```--repeat``` the input data, if smaller than the shared memory, is repeated until all bytes of the shared memory are written.
15+
16+
By setting the option ```--invert``` all bits of the input data are inverted.
17+
18+
By specifying the argument ```--passthrough``` all data written to the shared memory will be output to stdout.
19+
20+
### Examples
21+
All the following examples use the shared memory with the name ```mem```.
22+
23+
#### Fill the shared memory with zeroes
24+
```
25+
write-shm -n mem < /dev/zero
26+
```
27+
28+
#### Fill the shared memory with ones
29+
```
30+
write-shm -n mem -i < /dev/zero
31+
```
32+
33+
#### Fill the shared memory with random values
34+
```
35+
write-shm -n mem -i < /dev/random
36+
```
37+
38+
#### Write file to shared memory
39+
```
40+
write-shm -n mem < file
41+
```
42+
43+
#### Repeat file in shared memory
44+
```
45+
write-shm -n mem -r < file
46+
```
47+
48+
## Using the Flatpak package
49+
The flatpak package can be installed via the .flatpak file.
50+
This can be downloaded from the GitHub [projects release page](https://github.com/NikolasK-source/write_shm/releases):
51+
52+
```
53+
flatpak install --user write-shm.flatpak
54+
```
55+
56+
The application is then executed as follows:
57+
```
58+
flatpak run network.koesling.write-shm
59+
```
60+
61+
To enable calling with ```write-shm``` [this script](https://gist.github.com/NikolasK-source/76a7160a9804140b65c0fdabd77d0a28) can be used.
62+
In order to be executable everywhere, the path in which the script is placed must be in the ```PATH``` environment variable.
63+
64+
65+
## Build from Source
66+
67+
The following packages are required for building the application:
68+
- cmake
69+
- clang or gcc
70+
71+
Use the following commands to build the application:
72+
```
73+
git clone --recursive https://github.com/NikolasK-source/write_shm.git
74+
cd write_shm
75+
mkdir build
76+
cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
77+
cmake --build build
78+
```
79+
80+
81+
## Links to related projects
82+
83+
### General Shared Memory Tools
84+
- [Shared Memory Dump](https://nikolask-source.github.io/dump_shm/)
85+
- [Shared Memory Write](https://nikolask-source.github.io/write_shm/)
86+
- [Shared Memory Random](https://nikolask-source.github.io/shared_mem_random/)
87+
88+
### Modbus Clients
89+
- [RTU](https://nikolask-source.github.io/modbus_rtu_client_shm/)
90+
- [TCP](https://nikolask-source.github.io/modbus_tcp_client_shm/)
91+
92+
### Modbus Shared Memory Tools
93+
- [STDIN to Modbus](https://nikolask-source.github.io/stdin_to_modbus_shm/)
94+
- [Float converter](https://nikolask-source.github.io/modbus_conv_float/)
95+
96+
97+
## License
98+
99+
MIT License
100+
101+
Copyright (c) 2021-2022 Nikolas Koesling
102+
103+
Permission is hereby granted, free of charge, to any person obtaining a copy
104+
of this software and associated documentation files (the "Software"), to deal
105+
in the Software without restriction, including without limitation the rights
106+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
107+
copies of the Software, and to permit persons to whom the Software is
108+
furnished to do so, subject to the following conditions:
109+
110+
The above copyright notice and this permission notice shall be included in all
111+
copies or substantial portions of the Software.
112+
113+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
116+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
117+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
118+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
119+
SOFTWARE.

network.koesling.test-write-shm.yml

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

network.koesling.write-shm.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
id: network.koesling.write-shm
2+
runtime: org.freedesktop.Platform
3+
runtime-version: '21.08'
4+
sdk: org.freedesktop.Sdk
5+
command: write-shm
6+
finish-args:
7+
- --device=shm
8+
modules:
9+
- name: write-shm
10+
buildsystem: simple
11+
build-commands:
12+
# build
13+
- mkdir build
14+
- cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
15+
- cmake --build build
16+
17+
# install
18+
- mkdir -p "${FLATPAK_DEST}/bin"
19+
- cp build/write-shm ${FLATPAK_DEST}/bin
20+
sources:
21+
- type: git
22+
branch: release
23+
url: https://github.com/NikolasK-source/write_shm.git
24+

0 commit comments

Comments
 (0)