Skip to content

EtherNet/IP Example

This example usage of the EtherNet/IP Device Service demonstrates the onboarding of an EtherNet/IP device.

Start the EtherNet/IP Simulator

Edge Xpert provides a basic EtherNet/IP device simulator.

docker run --rm -d -i --name=ethernetip-sim iotechsys/ethernetip-sim:1.0

Find the device IP:

docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ethernetip-sim
172.17.0.2

Start the EtherNet/IP Device Service

To start the EtherNet/IP Device Service, enter the following command:

edgexpert up device-ethernet-ip

Device Onboarding

Once the EtherNet/IP Device Service has been started, EtherNet/IP devices can be onboarded to Edge Xpert using either the Edge Xpert Manager UI or through Edge Xpert REST API commands. Instructions on how to use both methods can be found below.

Device Onboarding with the Edge Xpert Manager UI

Note

Please refer to the Edge Xpert Manager UI Device Management capability for full details.

  1. Ensure the Edge Xpert Manager UI is started, for example:

    edgexpert up xpert-manager
    

  2. Open a browser and go to localhost:9090. The default username and password is admin

  3. Using the device profile upload capability, upload the provided EtherNet/IP example device profile at /usr/share/edgexpert/examples/device-services/ethernet-ip/ethernetip-sim-profile.yml

    This profile defines resources for users to test EtherNet/IP's Implicit, Explicit and Logix tag message type in communication.

  4. Onboard the device using the device onboarding capability. The following values can be used to provision the EtherNet/IP Simulation device:

    Field Example Value Description Required
    Name ethernet-ip-sim The unique name used to identify the device Required
    Description Example EtherNet/IP device Any additional information to help identify the device Optional
    Label ethernet-ip Any additional information to help identify the device Optional
    Protocol EtherNet/IP The name of the protocol Required
    Address 172.17.0.2 The IP address of the device Required
    Enable OT2 Settings true The radio button to enable OT2 settings Optional
    Connection Type p2p Defines whether data is communicated using peer-to-peer or multicast Required
    RPI 10 The requested packet interval, which is the interval in which data is exchanged Required
    Priority low Defines the priority in which the implicit data exchange is treated Required
    Ownership exclusive Defines the exclusivity of the data on the target If not set to exclusive, other scanners can also establish an implicit connection to the device Required
    Enable T2O Settings true The radio button to enable T2O settings Optional
    Connection Type p2p Defines whether data is communicated using peer-to-peer or multicast Required
    RPI 10 The requested packet interval, which is the interval in which data is exchanged Required
    Priority low Defines the priority in which the implicit data exchange is treated Required
    Ownership exclusive Defines the exclusivity of the data on the target If not set to exclusive, other scanners can also establish an implicit connection to the device Required
    Device Profile ethernetip-sim-profile The name of the device profile uploaded above Required
    Device Service device-ethernet-ip The name of the appropriate device service Required
    Auto Events Interval: 5s
    OnChange: false
    ResourceName: DO6
    Automated events to retrieve the data at specific frequencies

    Note: If OnChange is set to true, values will only be pushed if a change in value has occurred during the specified interval. If set to false, values will be sent on the specified regardless of if there has been a change.
    Optional

Device Onboarding using the Edge Xpert REST API

Info

If Edge Xpert is running in secure mode, you will need to replace localhost in the URL with the IP address for the service. See CLI Service Ports for details.

  1. Upload the provided EtherNet/IP example device profile:

    curl http://localhost:59881/api/v2/deviceprofile/uploadfile -F "file=@/usr/share/edgexpert/examples/device-services/ethernet-ip/ethernetip-sim-profile.yml"
    

  2. Onboard the device using similar values as with the Edge Xpert Manager UI:

Add device to core-metadata:

curl http://localhost:59881/api/v2/device -H "Content-Type:application/json" -X POST \
    -d '[ {
            "apiVersion": "v2",
             "device": {
               "name" :"ethernet-ip-sim",
               "description":"The simulated device",
               "labels":[ 
                  "ethernet-ip"
               ],
               "serviceName": "device-ethernet-ip",
               "profileName": "ethernetip-sim-profile",
               "protocolName": "ethernet-ip",
               "protocols":{
                  "ethernet-ip":{
                      "Address": "172.17.0.2"
                  },
                  "O2T":{
                      "ConnectionType": "p2p",
                      "RPI": "10",
                      "Priority": "low",
                      "Ownership": "exclusive"
                  },
                  "T2O":{
                      "ConnectionType": "p2p",
                      "RPI": "10",
                      "Priority": "low",
                      "Ownership": "exclusive"
                  }
               },
               "adminState":"UNLOCKED",
               "operatingState":"UP",
               "autoEvents": [
                  {"interval": "30s", "onChange": false, "sourceName": "DO6"}
                ]
            }
        }
    ]'

Device Data Flow

Once the device is onboarded to Edge Xpert, data flow between the Device Service and the connected device can be verified in a number of ways.

The Edge Xpert Manager UI supports Read and Write functionality for each device. Readings can also be viewed and queried within the Edge Xpert Manager UI Data Center.

Alternatively, you can read and write data with cURL commands or through REST API applications, such as Postman.

Info

If Edge Xpert is running in secure mode, you will need to replace localhost in the URL with the IP address for the service. See CLI Service Ports for details.

Both the GET and PUT commands can be made to the following address:

http://localhost:59882/api/v2/device/name/{deviceName}/{commandName}
Using the example above, we read an Implicit communication device resources DO6:
http://localhost:59882/api/v2/device/name/ethernet-ip-sim/DO6

For more information on the GET and PUT commands, see the Core Command Microservice.

Any data collected by the Device Service can then be treated like all other Edge Xpert sensor data. The data readings can be exported for data processing in a number of other applications and services. See the Supporting Services and Application Services documentation for more details.