S7 Example
This example demonstrates the onboarding of an S7 device to the Edge Xpert S7 Device Service.
The example uses the S7 simulator created for Edge Xrt.
Note
If you're using rootless container, the simulator of S7 Protocol should use port 102 but Podman can not create containers bound to ports which is smaller than 1024. You have to add net.ipv4.ip_unprivileged_port_start=102
to /etc/sysctl.conf (or /etc/sysctl.d) and run sudo sysctl --system
.
Start the S7 Device Service
To start the S7 Device Service, enter the following command:
edgexpert up device-s7
Device Onboarding
Once the S7 Device Service has been started, S7 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.
-
Ensure the Edge Xpert Manager UI is started, for example:
edgexpert up xpert-manager
-
Open a browser and go to
localhost:9090
. The default username and password isadmin
-
Using the device profile upload capability, upload the provided S7 example device profile at /usr/share/edgexpert/examples/device-services/s7/Server.yml
-
Onboard the device using the device onboarding capability. The following values can be used to provision the S7 Simulation device:
Field Example Value Description Required Name S7-Device
The unique name used to identify the device Required Description Example S7 Server
Any additional information to help identify the device Optional Label S7
Any additional information to help identify the device Optional Protocol S7
The name of the protocol Required Address 172.17.0.1
Replace with the IP address of the PLC being connected to. If you are using the S7 Simulator, change this to the IP address of the host machine running the simulator Required Rack 0
Rack number of the CPU to communicate with Required Slot 2
Slot number of the CPU to communicate with Required Device Profile Server
The name of the device profile uploaded above Required Device Service device-s7
The name of the appropriate device service Required Auto Events Interval: 5s
OnChange:false
ResourceName:DB-Test
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.
-
Upload the provided S7 example device profile:
curl http://localhost:59881/api/v2/deviceprofile/uploadfile -F "file=@/usr/share/edgexpert/examples/device-services/s7/Server.yml"
-
Onboard the device using similar values as with the Edge Xpert Manager UI:
curl -X 'POST' \ 'http://localhost:59881/api/v2/device' \ -H 'Content-Type: application/json' \ -d '[ { "apiVersion": "v2", "device": { "name": "S7-Device", "description": "Example S7 Server", "adminState": "UNLOCKED", "operatingState": "UP", "labels": [ "S7" ], "serviceName": "device-s7", "profileName": "Server", "protocolName": "s7", "autoEvents": [ { "interval": "5s", "onChange": false, "sourceName": "DB-Test" } ], "protocols": { "S7": { "IP":"172.17.0.1", "Rack": "0", "Slot":"2" } } } } ]'
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}
curl http://localhost:59882/api/v2/device/name/S7-Device/DB-Test
Any data collected by the Device Service can then be processed 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.