Unserver Configuration

Index > Unserver Configuration

This page covers Unserver communication settings in detail. These are the settings usually stored in network.json file.

Editing JSON Configuration Files

All configuration files used by Unserver are in JSON format. JSON is a simple text-based format that allows to describe structured data.

You can use any text editor to edit .json files. But it’s easier to use a more powerful free editor with syntax highlighting and validation, for example VS Code.

JSON Schema Validation

Every Unserver configuration files comes with a corresponding .schema.json file, which allows text editors to check the file for errors during editing.

Some editors don’t support JSON schema by default or require additional setup.

network.json Reference

Type: object array

The links property is an array of objects, each representing a communication link, for example:

"links":[
  { 
    /* link configuration object */ 
  },
  { 
    /* another link configuration object */ 
  }
]

For Modbus RTU communication links, a configuration object looks like this:

{
  "name": "link-name",
  "protocol": "modbus-rtu",
  "settings": {
    "port": "COM1",
    "baudRate": 9600,    
    "dataBits": 8,
    "parity": "none",
    "stopBits": 1,
    "timeoutMs": 500
  }
}

For Modbus TCP communication links, a configuration object looks like this:

{
  "name": "link-name",
  "protocol": "modbus-tcp",
  "settings": {
    "ip": "127.0.0.1",
    "port": 502
  }
}

devices

Describes a list of devices connected to Unserver.

Type: object array

devices.name

Name is the identifier of a device. It is used to refer to a particular device when creating tags:

+-------------+  +--------------+
|    DEVICE   |  |     TAG      |
+-------------+  +--------------+
|name:  "plc1"|  |device: "plc1"|
+---------+---+  +----------+---+
          ^                 |
          |                 |
          +-----------------+

It’s best to pick something short, but descriptive for a device name.

The device name must be unique across all devices.

Type: string

Supported values: any

The name of a communication link used to connect to the device.

Type: string

devices.address

The address of the device on the Modbus network. Also knows as slave Id.

Type: string

Supported values: integer in range [1, 255]

devices.unsupportedOperations

A list of Modbus function codes not supported by the device.

This optional property instructs Unserver to avoid certain Modbus function codes when communicating with the particular device.

For instance, you could forbid code 15 (force multiple coils):

{
    ...
    "unsupportedOperations":[15]
}

This means Unserver will use the closest alternative - code 5 (force single coil) to write coils.

If the Modbus device supports all basic Modbus codes listed below, you don’t need to specify this property.

Type: integer array

Supported Values: any combination of 1, 2, 3, 4, 5, 6, 15, 16 or []

api

Contains configuration of the HTTP API endpoint.

Type: object

api.port

TCP port used by Unserver HTTP API.

The port number is specified in HTTP requests of API clients:

http://localhost:9000/tags/example

This URL uses port 9000.

Type: integer

Supported values: number in range [1, 65535]

After modifying this parameter Unserver will likely require adding a new URL reservation.

FREE TRIALLearned Something? Try it for yourself with free community license.Download Now

Never Miss an Update

If you enjoy our products or posts, please subscribe. You will get our best content via email.
Unsubscribe at any time. Don't worry - we don't spam.