|
1 | 1 | Pymodbus simulator ReST API
|
2 | 2 | ===========================
|
3 | 3 |
|
4 |
| -TO BE DOCUMENTED. |
| 4 | +This is still a Work In Progress. There may be large changes to the API in the |
| 5 | +future. |
| 6 | + |
| 7 | +The API is a simple copy of |
| 8 | +having most of the same features as in the Web UI. |
| 9 | + |
| 10 | +The API provides the following endpoints: |
| 11 | + |
| 12 | +- /restapi/registers |
| 13 | +- /restapi/calls |
| 14 | +- /restapi/server |
| 15 | +- /restapi/log |
| 16 | + |
| 17 | +Registers Endpoint |
| 18 | +------------------ |
| 19 | + |
| 20 | +/restapi/registers |
| 21 | +^^^^^^^^^^^^^^^^^^ |
| 22 | + |
| 23 | + The registers endpoint is used to read and write registers. |
| 24 | + |
| 25 | + **Request Parameters** |
| 26 | + |
| 27 | + - `submit` (string, required): |
| 28 | + The action to perform. Must be one of `Register`, `Set`. |
| 29 | + - `range_start` (integer, optional): |
| 30 | + The starting register to read from. Defaults to 0. |
| 31 | + - `range_end` (integer, optional): |
| 32 | + The ending register to read from. Defaults to `range_start`. |
| 33 | + |
| 34 | + **Response Parameters** |
| 35 | + |
| 36 | + Returns a json object with the following keys: |
| 37 | + |
| 38 | + - `result` (string): |
| 39 | + The result of the action. Either `ok` or `error`. |
| 40 | + - `error` (string, conditional): |
| 41 | + The error message if the result is `error`. |
| 42 | + - `register_rows` (list): |
| 43 | + A list of objects containing the data of the registers. |
| 44 | + - `footer` (string): |
| 45 | + A cleartext status of the action. HTML leftover. |
| 46 | + - `register_types` (list): |
| 47 | + A static list of register types. HTML leftover. |
| 48 | + - `register_actions` (list): |
| 49 | + A static list of register actions. HTML leftover. |
| 50 | + |
| 51 | + **Example Request and Response** |
| 52 | + |
| 53 | + Request Example: |
| 54 | + |
| 55 | + .. include:: registers_request.rst |
| 56 | + |
| 57 | + Response Example: |
| 58 | + |
| 59 | + .. include:: registers_response.rst |
| 60 | + |
| 61 | +Calls Endpoint |
| 62 | +-------------- |
| 63 | + |
| 64 | +The calls endpoint is used to handle ModBus response manipulation. |
| 65 | + |
| 66 | +/restapi/calls |
| 67 | +^^^^^^^^^^^^^^ |
| 68 | + |
| 69 | + The calls endpoint is used to simulate different conditions for ModBus |
| 70 | + responses. |
| 71 | + |
| 72 | + **Request Parameters** |
| 73 | + |
| 74 | + - `submit` (string, required): |
| 75 | + The action to perform. Must be one of `Simulate`, `Reset`. |
| 76 | + |
| 77 | + The following must be present if `submit` is `Simulate`: |
| 78 | + |
| 79 | + - `response_clear_after` (integer, required): |
| 80 | + The number of packet to clear simulation after. |
| 81 | + - `response_cr` (string, required): |
| 82 | + Must be present but can be any value. Turns on change rate simulation (WIP). |
| 83 | + - `response_cr_pct` (integer, required): |
| 84 | + The percentage of change rate, how many percent of packets should be |
| 85 | + changed. |
| 86 | + - `response_split` (string, required): |
| 87 | + Must be present but can be any value. Turns on split response simulation (WIP). |
| 88 | + - `split_delay` (integer, required): |
| 89 | + The delay in seconds to wait before sending the second part of the split response. |
| 90 | + - `response_delay` (integer, required): |
| 91 | + The delay in seconds to wait before sending the response. |
| 92 | + - `response_error` (integer, required): |
| 93 | + The error code to send in the response. The valid values can be one from |
| 94 | + the response `function_error` list. |
| 95 | + |
| 96 | + When `submit` is `Reset`, no other parameters are required. It resets all |
| 97 | + simulation options to their defaults (off). |
| 98 | + |
| 99 | + **Example Request and Response** |
| 100 | + |
| 101 | + Request: |
| 102 | + |
| 103 | + .. include:: calls_request.rst |
| 104 | + |
| 105 | + Response: |
| 106 | + |
| 107 | + Unfortunately, the endpoint response contains extra clutter due to |
| 108 | + not being finalized. |
| 109 | + |
| 110 | + .. include:: calls_response.rst |
| 111 | + |
| 112 | +Server Endpoint |
| 113 | +--------------- |
| 114 | + |
| 115 | +The server endpoint has not yet been implemented. |
| 116 | + |
| 117 | +Log Endpoint |
| 118 | +------------ |
| 119 | + |
| 120 | +The log endpoint has not yet been implemented. |
0 commit comments