SWM282 Modbus
The information in this page is updated in accordance with firmware version SWM2_R_00.01.06.3.
Summary
Modbus is a serial communications protocol. Simple and robust, it has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices.
This manual page provides an overview of the Modbus functionality in SWM282 devices.
Note: Modbus TCP Server is additional software that can be installed from the System → Package Manager page.
Modbus TCP Server
A Modbus TCP Server listens for connections from a TCP Client (client) and sends out a response or sets some system related parameter in accordance with the given query. This provides the user with the possibility to set or get system parameters.
The figure below is an example of the Modbus TCP Server window section and the table below provides information on the fields contained in that window:
Status
Status section displays Modbus TCP Server status information:
Modbus TCP server
In this section you can configure the main server settings:
| Field | Value | Description |
|---|---|---|
| Enable | off | on; default: off | Enable Modbus TCP server. |
| Port | integer [0..65535]; default: 502 | TCP port used for Modbus communications. |
| Device ID | integer [0..255]; default: 1 | The device's Modbus server ID. When set to 0, it will respond to requests addressed to any ID. |
| Enable broadcasts | off | on; default: off | Process incoming Modbus broadcast messages. |
| Keep persistent connection | off | on; default: on | Do not close the connection after each completed Modbus request. |
| Connection timeout | integer [0..60]; default: 0 | Timeout in seconds: this parameter specifies the duration after which the connection will be forcefully closed. A value of 0 is considered the same as no timeout. |
| Enable custom register block | off | on; default: off | Allows the usage of custom register block. |
| Register file path | path; default: /mnt/regfile | Path to file in which the custom register block will be stored. Files inside /tmp or /var are stored in RAM. They vanish after reboot, but do not degrade flash memory. Files elsewhere are stored in flash memory. They remain after reboot, but degrade flash memory (severely, if operations are frequent). |
| First register number | integer [10000..65536]; default: 10000 | First register in custom register block |
| Register count | integer [1..64512]; default: 128 | Register count in custom register block |
Modbus Registers
Get Parameters
Modbus parameters are held within registers. Each register contains 2 bytes of information. For simplification, the number of registers for storing numbers is 2 (4 bytes), while the number of registers for storing text information is 16 (32 bytes).
To get port-specific registers, use following formula: register_number + (port_number * register_count).
For example, to get register number:
- TX of port1: 1001 + (0 * 4) = 1001.
- TX of port2: 1001 + (1 * 4) = 1005.
The register numbers and corresponding system values are described in the table below:
| required value | register address | register number | number of registers | representation |
|---|---|---|---|---|
| Uptime | 1 | 2 | 2 | 32 bit unsigned integer |
| Hostname | 3 | 4 | 16 | ASCII |
| Serial number | 19 | 20 | 16 | ASCII |
| WAN IP | 35 | 36 | 2 | 8 bit unsigned integer |
| LAN MAC | 37 | 38 | 16 | ASCII |
| Device name | 53 | 54 | 16 | ASCII |
| Unix timestamp | 69 | 70 | 2 | 32 bit unsigned integer |
| Local ISO time | 71 | 72 | 12 | ASCII |
| UTC time | 83 | 84 | 12 | ASCII |
| Port TX counter | 1000 | 1001 | 4 | 64 bit unsigned integer |
| Port RX counter | 2000 | 2001 | 4 | 64 bit unsigned integer |
| Port link status (up/down) | 3000 | 3001 | 1 | 16 bit unsigned integer |
Set Parameters
The Modbus daemon can also set some device parameters.
| value to set | register address | register number | register value | description |
|---|---|---|---|---|
| Hostname | 3 | 4 | Hostname (in decimal form) | Changes hostname |
| Device name | 53 | 54 | Device name (in decimal form) | Changes device name |
| Reboot | 97 | 98 | 1 | Reboots the switch |
See also
- Monitoring via Modbus - detailed examples on how to use Modbus TCP

