File: restapi.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 (120 lines) | stat: -rw-r--r-- 3,440 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
Pymodbus simulator ReST API
===========================

This is still a Work In Progress. There may be large changes to the API in the
future.

The API is a simple copy of
having most of the same features as in the Web UI.

The API provides the following endpoints:

- /restapi/registers
- /restapi/calls
- /restapi/server
- /restapi/log

Registers Endpoint
------------------

/restapi/registers
^^^^^^^^^^^^^^^^^^

    The registers endpoint is used to read and write registers.

    **Request Parameters**

    - `submit` (string, required):
        The action to perform. Must be one of `Register`, `Set`.
    - `range_start` (integer, optional):
        The starting register to read from. Defaults to 0.
    - `range_end` (integer, optional):
        The ending register to read from. Defaults to `range_start`.

    **Response Parameters**

    Returns a json object with the following keys:

    - `result` (string):
        The result of the action. Either `ok` or `error`.
    - `error` (string, conditional):
        The error message if the result is `error`.
    - `register_rows` (list):
        A list of objects containing the data of the registers.
    - `footer` (string):
        A cleartext status of the action. HTML leftover.
    - `register_types` (list):
        A static list of register types. HTML leftover.
    - `register_actions` (list):
        A static list of register actions. HTML leftover.

    **Example Request and Response**

    Request Example:

    .. include:: registers_request.rst

    Response Example:

    .. include:: registers_response.rst

Calls Endpoint
--------------

The calls endpoint is used to handle ModBus response manipulation.

/restapi/calls
^^^^^^^^^^^^^^

    The calls endpoint is used to simulate different conditions for ModBus
    responses.

    **Request Parameters**

    - `submit` (string, required):
        The action to perform. Must be one of `Simulate`, `Reset`.

    The following must be present if `submit` is `Simulate`:

    - `response_clear_after` (integer, required):
        The number of packet to clear simulation after.
    - `response_cr` (string, required):
        Must be present but can be any value. Turns on change rate simulation (WIP).
    - `response_cr_pct` (integer, required):
        The percentage of change rate, how many percent of packets should be
        changed.
    - `response_split` (string, required):
        Must be present but can be any value. Turns on split response simulation (WIP).
    - `split_delay` (integer, required):
        The delay in seconds to wait before sending the second part of the split response.
    - `response_delay` (integer, required):
        The delay in seconds to wait before sending the response.
    - `response_error` (integer, required):
        The error code to send in the response. The valid values can be one from
        the response `function_error` list.

    When `submit` is `Reset`, no other parameters are required. It resets all
    simulation options to their defaults (off).

    **Example Request and Response**

    Request:

    .. include:: calls_request.rst

    Response:

    Unfortunately, the endpoint response contains extra clutter due to
    not being finalized.

    .. include:: calls_response.rst

Server Endpoint
---------------

The server endpoint has not yet been implemented.

Log Endpoint
------------

The log endpoint has not yet been implemented.