File: examples.rst

package info (click to toggle)
pymodbus 3.8.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,720 kB
  • sloc: python: 14,867; makefile: 27; sh: 17
file content (219 lines) | stat: -rw-r--r-- 4,614 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Examples
========

Examples are divided in 2 parts:

The first part are some simple client examples which can be copied and run directly.
These examples show the basic functionality of the library.

The second part are more advanced examples, but in order to not duplicate code,
this requires you to download the examples directory and run
the examples in the directory.

Ready to run examples:
----------------------

These examples are very basic examples,
showing how a client can communicate with a server.

You need to modify the code to adapt it to your situation.

Simple asynchronous client
^^^^^^^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/simple_async_client.py`

.. literalinclude:: ../../examples/simple_async_client.py

Simple synchronous client
^^^^^^^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/simple_sync_client.py`

.. literalinclude:: ../../examples/simple_sync_client.py


Client performance sync vs async
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/client_performance.py`

.. literalinclude:: ../../examples/client_performance.py


Advanced examples
-----------------

These examples are considered essential usage examples, and are guaranteed to work,
because they are tested automatilly with each dev branch commit using CI.

.. tip:: The examples needs to be run from within the examples directory, unless you modify them.
    Most examples use helper.py and client_*.py or server_*.py. This is done to avoid maintaining the
    same code in multiple files.

    - :download:`examples.zip <_static/examples.zip>`
    - :download:`examples.tgz <_static/examples.tgz>`


Client asynchronous calls
^^^^^^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/client_async_calls.py`

.. automodule:: examples.client_async_calls
    :undoc-members:
    :noindex:


Client asynchronous
^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/client_async.py`

.. automodule:: examples.client_async
    :undoc-members:
    :noindex:


Client calls
^^^^^^^^^^^^
Source: :github:`examples/client_calls.py`

.. automodule:: examples.client_calls
    :undoc-members:
    :noindex:


Custom message
^^^^^^^^^^^^^^
Source: :github:`examples/custom_msg.py`

.. automodule:: examples.custom_msg
    :undoc-members:
    :noindex:


Client payload
^^^^^^^^^^^^^^
Source: :github:`examples/client_payload.py`

.. automodule:: examples.client_payload
    :undoc-members:
    :noindex:

Client synchronous
^^^^^^^^^^^^^^^^^^
Source: :github:`examples/client_sync.py`

.. automodule:: examples.client_sync
    :undoc-members:
    :noindex:


Server asynchronous
^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/server_async.py`

.. automodule:: examples.server_async
    :undoc-members:
    :noindex:


Server callback
^^^^^^^^^^^^^^^
Source: :github:`examples/server_callback.py`

.. automodule:: examples.server_callback
    :undoc-members:
    :noindex:


Server tracer
^^^^^^^^^^^^^
Source: :github:`examples/server_hook.py`

.. automodule:: examples.server_hook
    :undoc-members:
    :noindex:


Server payload
^^^^^^^^^^^^^^
Source: :github:`examples/server_payload.py`

.. automodule:: examples.server_payload
    :undoc-members:
    :noindex:


Server synchronous
^^^^^^^^^^^^^^^^^^
Source: :github:`examples/server_sync.py`

.. automodule:: examples.server_sync
    :undoc-members:
    :noindex:


Server updating
^^^^^^^^^^^^^^^
Source: :github:`examples/server_updating.py`

.. automodule:: examples.server_updating
    :undoc-members:
    :noindex:


Simulator example
^^^^^^^^^^^^^^^^^
Source: :github:`examples/simulator.py`

.. automodule:: examples.simulator
    :undoc-members:
    :noindex:


Simulator datastore (shared storage) example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Source: :github:`examples/datastore_simulator_share.py`

.. automodule:: examples.datastore_simulator_share
    :undoc-members:
    :noindex:


Message Parser
^^^^^^^^^^^^^^
Source: :github:`examples/message_parser.py`

.. automodule:: examples.message_parser
    :undoc-members:
    :noindex:


Modbus forwarder
^^^^^^^^^^^^^^^^
Source: :github:`examples/modbus_forwarder.py`

.. automodule:: examples.modbus_forwarder
    :undoc-members:
    :noindex:


Examples contributions
----------------------

These examples are supplied by users of pymodbus.
The pymodbus team thanks for sharing the examples.

Solar
^^^^^
Source: :github:`examples/contrib/solar.py`

.. automodule:: examples.contrib.solar
    :undoc-members:
    :noindex:


Serial Forwarder
^^^^^^^^^^^^^^^^
Source: :github:`examples/contrib/serial_forwarder.py`

.. automodule:: examples.contrib.serial_forwarder
    :undoc-members:
    :noindex: