Skip to content

Commit d9b820a

Browse files
update README.md
1 parent 8200bb6 commit d9b820a

File tree

1 file changed

+47
-36
lines changed

1 file changed

+47
-36
lines changed

README.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,67 @@
22

33
Modbus tcp client that stores its data (registers) in shared memory objects.
44

5+
## Dependencies
6+
- cxxopts by jarro2783 (https://github.com/jarro2783/cxxopts) (only required for building the application)
7+
- libmodbus by Stéphane Raimbault (https://github.com/stephane/libmodbus)
8+
- cxxshm (https://github.com/NikolasK-source/cxxshm)
9+
- cxxsemaphore (https://github.com/NikolasK-source/cxxsemaphore)
10+
11+
On Arch linux they are available via the official repositories and the AUR:
12+
- https://archlinux.org/packages/extra/any/cxxopts/
13+
- https://aur.archlinux.org/packages/libmodbus
14+
- https://aur.archlinux.org/packages/cxxshm
15+
- https://aur.archlinux.org/packages/cxxsemaphore
16+
517
## Build
618
```
7-
git submodule init
8-
git submodule update
9-
mkdir build
10-
cd build
11-
cmake .. -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF
19+
cmake -B build -DCMAKE_CXX_COMPILER=$(which clang++) -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCLANG_TIDY=OFF -DCOMPILER_WARNINGS=OFF -DBUILD_DOC=OFF
1220
cmake --build .
1321
```
1422

15-
As an alternative to the ```git submodule``` commands, the ```--recursive``` option can be used with ```git clone```.
16-
1723
## Use
1824
```
1925
modbus-tcp-client-shm [OPTION...]
2026
21-
-i, --ip arg ip to listen for incoming connections (default: 0.0.0.0)
22-
-p, --port arg port to listen for incoming connections (default: 502)
23-
-n, --name-prefix arg shared memory name prefix (default: modbus_)
27+
network options:
28+
-i, --host arg host to listen for incoming connections (default: any)
29+
-p, --service arg service or port to listen for incoming connections (default: 502)
30+
-c, --connections arg number of allowed simultaneous Modbus Server connections. (default: 1)
31+
-r, --reconnect do not terminate if no Modbus Server is connected anymore.
32+
-t, --tcp-timeout arg tcp timeout in seconds. Set to 0 to use the system defaults (not recommended). (default: 5)
33+
34+
shared memory options:
35+
-n, --name-prefix arg shared memory name prefix (default: modbus_)
36+
--force Force the use of the shared memory even if it already exists. Do not use this option per default! It should only be used if the shared memory of an improperly terminated instance continues to exist as an orphan
37+
and is no longer used.
38+
-s, --separate arg Use a separate shared memory for requests with the specified client id. The client id (as hex value) is appended to the shared memory prefix (e.g. modbus_fc_DO). You can specify multiple client ids by
39+
separating them with ','. Use --separate-all to generate separate shared memories for all possible client ids.
40+
--separate-all like --separate, but for all client ids (creates 1028 shared memory files! check/set 'ulimit -n' before using this option.)
41+
--semaphore arg protect the shared memory with a named semaphore against simultaneous access
42+
--semaphore-force Force the use of the semaphore even if it already exists. Do not use this option per default! It should only be used if the semaphore of an improperly terminated instance continues to exist as an orphan and is
43+
no longer used.
44+
-b, --permissions arg permission bits that are applied when creating a shared memory. (default: 0640)
45+
46+
modbus options:
2447
--do-registers arg number of digital output registers (default: 65536)
2548
--di-registers arg number of digital input registers (default: 65536)
2649
--ao-registers arg number of analog output registers (default: 65536)
2750
--ai-registers arg number of analog input registers (default: 65536)
2851
-m, --monitor output all incoming and outgoing packets to stdout
29-
-r, --reconnect do not terminate if the Modbus Server disconnects.
30-
--byte-timeout arg timeout interval in seconds between two consecutive bytes of the same message. In most
31-
cases it is sufficient to set the response timeout. Fractional values are possible.
32-
--response-timeout arg set the timeout interval in seconds used to wait for a response. When a byte timeout is
33-
set, if the elapsed time for the first byte of response is longer than the given timeout,
34-
a timeout is detected. When byte timeout is disabled, the full confirmation response must
35-
be received before expiration of the response timeout. Fractional values are possible.
36-
-t, --tcp-timeout arg tcp timeout in seconds. Set to 0 to use the system defaults (not recommended). (default:
37-
5)
38-
--force Force the use of the shared memory even if it already exists. Do not use this option per
39-
default! It should only be used if the shared memory of an improperly terminated instance
40-
continues to exist as an orphan and is no longer used.
41-
-s, --separate arg Use a separate shared memory for requests with the specified client id. The client id
42-
(as hex value) is appended to the shared memory prefix (e.g. modbus_fc_DO). You can
43-
specify multiple client ids by separating them with ','. Use --separate-all to generate
44-
separate shared memories for all possible client ids.
45-
--separate-all like --separate, but for all client ids (creates 1028 shared memory files! check/set
46-
'ulimit -n' before using this option.)
47-
-h, --help print usage
48-
--version print version information
49-
--license show licences
52+
--byte-timeout arg timeout interval in seconds between two consecutive bytes of the same message. In most cases it is sufficient to set the response timeout. Fractional values are possible.
53+
--response-timeout arg set the timeout interval in seconds used to wait for a response. When a byte timeout is set, if the elapsed time for the first byte of response is longer than the given timeout, a timeout is detected. When
54+
byte timeout is disabled, the full confirmation response must be received before expiration of the response timeout. Fractional values are possible.
55+
56+
other options:
57+
-h, --help print usage
58+
--license show licences (short)
59+
--license-full show licences (full license text)
60+
61+
version information options:
62+
--version print version and exit
63+
--longversion print version (including compiler and system info) and exit
64+
--shortversion print version (only version string) and exit
65+
--git-hash print git hash
5066
5167
5268
The modbus registers are mapped to shared memory objects:
@@ -66,8 +82,3 @@ The following example redirects packets from port 502 (standard modbus port) to
6682
iptables -A PREROUTING -t nat -p tcp --dport 502 -j REDIRECT --to-port 5020
6783
```
6884
The modbus client must be called with the option ```-p 5020```
69-
70-
## Libraries
71-
This application uses the following libraries:
72-
- cxxopts by jarro2783 (https://github.com/jarro2783/cxxopts)
73-
- libmodbus by Stéphane Raimbault (https://github.com/stephane/libmodbus)

0 commit comments

Comments
 (0)