Line 1,397: |
Line 1,397: |
| <span style="color:red"> <b>Note: </b></span>MQTT Gateway uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>Register Number</i> field. | | <span style="color:red"> <b>Note: </b></span>MQTT Gateway uses <i>Register Number</i> instead of <i>Register Address</i> for pointing to a register. For example, to request the <i>Uptime</i> of a device, you must use <b>2</b> in the <i>Register Number</i> field. |
| | | |
− | Modbus request data sent in the MQTT payload should be generated in accordance with the following format: | + | Modbus request data sent in the MQTT payload should be generated in accordance with the one of the following formats: |
| | | |
− | <b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <REGISTER_NUMBER> <REGISTER_COUNT/VALUE></b>
| + | * TCP: |
| + | <b>0 <COOKIE> <IP_TYPE> <IP> <PORT> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES></b> |
| + | * Serial: |
| + | <b>1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES></b> |
| + | * MODBUS TCP connection management messages: |
| + | <b>2 <COOKIE> <CONNECTION_INDEX> <ACTION></b><br> |
| + | <b>2 <COOKIE> <CONNECTION_INDEX> 0 <IP_TYPE> <IP> <PORT> <TIMEOUT></b> |
| | | |
| Explanation: | | Explanation: |
| | | |
| <ul> | | <ul> |
− | <li><b>0</b> - must be 0, which signifies a textual format (currently the only one implemented).</li>
| + | <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>-1]). A cookie is used in order to distinguish which response belongs to which request, each request and the corresponding response contain a matching cookie: a 64-bit unsigned integer.</li> |
− | <li><b>Cookie</b> - a 64-bit unsigned integer in range [0..2<sup>64</sup>]). A cookie is used in order to distinguish which response belongs to which request, each request and the corresponding response contain a matching cookie: a 64-bit unsigned integer.</li> | |
| <li><b>IP type</b> - host IP address type. Possible values: | | <li><b>IP type</b> - host IP address type. Possible values: |
| <ul> | | <ul> |
Line 1,411: |
Line 1,416: |
| <li><b>1</b> - IPv6 address;</li> | | <li><b>1</b> - IPv6 address;</li> |
| <li><b>2</b> - hostname that will be resolved to an IP address.</li> | | <li><b>2</b> - hostname that will be resolved to an IP address.</li> |
− | </ul></li> | + | </ul> |
| + | </li> |
| <li><b>IP</b> - IP address of a Modbus TCP slave. IPv6 must be presented in full form (e.g., <i>2001:0db8:0000:0000:0000:8a2e:0370:7334</i>).</li> | | <li><b>IP</b> - IP address of a Modbus TCP slave. IPv6 must be presented in full form (e.g., <i>2001:0db8:0000:0000:0000:8a2e:0370:7334</i>).</li> |
| <li><b>Port</b> - port number of the Modbus TCP slave.</li> | | <li><b>Port</b> - port number of the Modbus TCP slave.</li> |
− | <li><b>Timeout</b> - timeout for Modbus TCP connection, in seconds. Range [1..999].</li> | + | <li><b>Timeout</b> - timeout for Modbus connection, in seconds. Range [1..999].</li> |
| <li><b>Slave ID</b> - Modbus TCP slave ID. Range [1..255].</li> | | <li><b>Slave ID</b> - Modbus TCP slave ID. Range [1..255].</li> |
| <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are: | | <li><b>Modbus function</b> - Modbus task type that will be executed. Possible values are: |
| <ul> | | <ul> |
| + | <li><b>1</b> - read coils;</li> |
| + | <li><b>2</b> - read input coils;</li> |
| <li><b>3</b> - read holding registers;</li> | | <li><b>3</b> - read holding registers;</li> |
| + | <li><b>4</b> - read input registers;</li> |
| + | <li><b>5</b> - set single coil;</li> |
| <li><b>6</b> - write to a single holding register;</li> | | <li><b>6</b> - write to a single holding register;</li> |
| + | <li><b>15</b> - set multiple coils;</li> |
| <li><b>16</b> - write to multiple holding registers.</li> | | <li><b>16</b> - write to multiple holding registers.</li> |
− | </ul></li> | + | </ul> |
− | <li><b>Register number</b> - number (not address) of the first register (in range [1..65536]) from which the registers will be read/written to. | + | </li> |
| + | <li><b>First register</b> - number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.</li> |
| <li><b>Register count/value</b> - this value depends on the Modbus function: | | <li><b>Register count/value</b> - this value depends on the Modbus function: |
| <ul> | | <ul> |
− | <li><b>3</b> - <u>register count</u> (in range [1..125]); must not exceed the boundary (first register number + register count <= 65537);</li> | + | <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li> |
− | <li><b>6</b> - <u>register value</u> (in range [0..65535]);</li> | + | <li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li> |
| + | <li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li> |
| + | <li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li> |
| + | <li><b>5</b> - <u>coil value</u> (in range [0..1]);</li> |
| + | <li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li> |
| + | <li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].</li> |
| <li><b>16</b> - <u>register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].</li> | | <li><b>16</b> - <u>register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].</li> |
− | </ul></li> | + | </ul> |
| + | </li> |
| + | <li><b>Serial device ID</b> - a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section.</li> |
| + | <li><b>Connection index</b> - a number used to identify a connection on which an action will be preformed (in range [0..7]).</li> |
| + | <li><b>Action</b> - a connection action. Possible values are: |
| + | <ul> |
| + | <li><b>0</b> - OPEN. This will open a closed connection, reopen an already open connection with the same parameters or close an already open connection and open a new one with new parameters.</li> |
| + | <li><b>1</b> - CLOSE. This will close an open connection and do nothing to the closed one.</li> |
| + | <li><b>2</b> - STATUS. This will respond with either <b>OK 1</b> for an open connection or <b>OK 0</b> for a closed connection.</li> |
| + | </ul> |
| + | </li> |
| + | <!-- <li><b>Timeout count</b> - number of timeouts. (in range []) </li> --> |
| </ul> | | </ul> |
| | | |