|
1 | 1 | # 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. |
0 commit comments