In part 1 of this blog series, we went over the basics of Modbus and what support for this well-known industrial protocol exists in netTerrain DCIM, along with its limitations.

In the second part of the series, we looked at the Modbus configuration process in netTerrain, as well as the Modbus configuration file.

In this final part of the Modbus series we will check out the supplied applications, which include:

  • ModbusTest: a windows console application program to test Modbus device access and validate configuration files without using netTerrain.
  • ModbusCU: Primary Windows Console application to collect data from Modbus devices and update properties in netTerrain.

ModbusTest

The supplied Modbus application is included as a supplemental set of files to be executed on a target machine that can access the Modbus devices or gateways. The XML configuration file specified on the command line below is a required file needed to run the application correctly.

The Syntax is as follows:

ModbusTest [/D] mbx_file IPv4_address [unit_number]
ModbusTest /A
ModbusTest /?
  
  mbx_file        Specifies the Modbus config file (.mbx)
  IPv4_address    Specifies the IPv4 Address of the Modbus device
  unit_number     Specifies the unit number of the Modbus device
  /D              Displays additional information for debugging purposes
  /A              Displays acknowledgements only
  /?              Displays this help text only

Example:

ModbusTest DataNab_MBus_xTH_LCD_ETH.mbx 172.16.10.206 3

ModbusCU

This program is a primary Windows Console application to collect data from Modbus devices and update properties in netTerrain.

The application automatically looks for a file called ModbusTypes.xml, in the same folder as the executable resides.

Syntax:

ModbusCU [/C] [/V] [/D] [/P#] [/E]
ModbusCU /A
ModbusCU /?
  
  /C          Directs output to console instead of log file
  /V          Displays step-by-step (verbose) tracing
  /D          Displays additional error information for debugging purposes
  /P[#]       Initiates periodic polling after initial update
              where # is an optional polling period from 1 to 1440 minutes
              the default polling period is 5 minutes (/P = /P5)
  /E          Records completion of each polling cycle (implied by /V)
  /A          Displays acknowledgements only
  /?          Displays this help text only

The sample Modbustypes.xml file contents are as follows:

<?xml version='1.0' encoding='UTF-8'?>
<modbus>
  <type name="APC Smart-UPS 1000" file="APC_SmartUPS.mbx" />
  <type name="SC SensorGateway" file="ServersCheck_SensorGateway.mbx" />
  <type name="SC DoorContact" file="ServersCheck_DoorContact.mbx" />
  <type name="DataNab TH Sensor" file="DataNab_MBus_xTH_LCD_ETH.mbx" />
</modbus>

Each <type> element in the XML must have the following attributes:

name The Name of the Node Type in netTerrain
file The Modbus XML configuration file for that type

ModbusCU.exe.config

The application automatically looks for this file in the same folder as the executable resides. This file is provided but the contents should be updated. It specifies the URL for the netTerrain server (which is the base URL for the REST endpoints) as well as provides authorization, either by supplying user credentials or a User Token generated in netTerrain. The netTerrain user in either case must have at least Edit level permissions.

Sample file contents (using credentials):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <appSettings>
    <add key="NetTerrainUrl" value="http://localhost/netTerrain" />
    <add key="UserName" value="modbus" />
    <add key="Password" value="modbus" />
  </appSettings>
</configuration>

Sample file contents (using User Token):

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
  </startup>
  <appSettings>
    <add key="NetTerrainUrl" value="http://localhost/netTerrain" />
    <add key="Token" value= “TCLe0mPLzSBhL6yha84oKqhe170skyqYlN6zAMaO0dA8h24EEK7FYeuPOK2QMKfreZAYbaGSYp7QL7xTEeOGiQ36" />
  </appSettings>
</configuration>

If you want to explore more ways to connect netTerrain to third-party tools and apps you may use, click here for our ongoing series on connectors.Stay tuned for more updates, and happy documenting!

About Jan Durnhofer

As CEO / Product and Engineering Manager, Jan joined Graphical Networks with the purpose of creating the most advanced DCIM and IT visualization company in the market.