6.5 Modbus interworking procedures
6.5.1 Retrieve data from a Modbus device
Suppose a scenario when current readings of a Modbus device need to be displayed at an AE application and Modbus-IPE continuously monitors a Modbus device and uploads that data to a CSE hosted on a server in the network. Initially, the AE shall be subscribed to the <flexContainer> resource, which is a specialization of some SDT module for a Modbus device, using a <subscription> resource (notificationEventType A, see clause 9.6.8 in oneM2M TS0001 [1]). The following steps described in Figure 6.5.1-1 shall be performed for this scenario:
- The Modbus IPE shall send a retrieve <flexContainer> request to the hosting CSE. This <flexContainer> resource is a specialization of some Modbus module and contains nodnProperties attribute.
- The Hosting CSE shall respond to the retrieve request with <flexContainer> data that includes nodnProperties .
- The Modbus IPE shall use information stored in nodnProperties to compose Modbus read request. The function code can be identified from a register type as in Table 6.4-1. Slave id, address and length should be written in corresponding message fields. After the Modbus message is composed, the Modbus IPE sends this message to Modbus device.
- The Modbus device responds with requested data.
- The Modbus IPE shall send an update <flexContainer> request (see clause 7.4.37.2.3 in oneM2M TS0004 [2]). The request body specifies the customAttributes to be updated and their new values read from Modbus device.
- After verifying the privileges and the given attributes, the hosting CSE shall update <flexContainer> resource.
- The hosting CSE shall respond with updated <flexContainer> data after successful update to the Modbus IPE, otherwise it responds with an error.
- The hosting CSE shall send a notification for <flexContainer> resource update to the AE (see clause 7.5.1.2.2 in oneM2M TS0004 [2]).
- The AE sends a confirmation message about notification receiving to the hosting CSE (see clause 7.5.1.2.2 in oneM2M TS0004 [2]).
Figure 6.5.1-1: Modbus Slave Device monitoring call flow
6.5.2 Write data to a Modbus device
Suppose a scenario when it is required to update some value in a Modbus device through an AE application registered to a CSE. Initially, the Modbus IPE shall be subscribed to the <flexContainer> resource, which is a specialization of some SDT module for a Modbus device, using a blocking type of <subscription> resource (notificationEventType G, see clause 9.6.8 in oneM2M TS0001 [1]). The following steps described in Figure 6.5.2-1 shall be performed for this scenario:
- In order to write data to a Modbus device from the AE, the AE sends a request to update specified customAttributes of the < flexContainer > resource which map to the Modbus Device (see clause 7.4.37.2.3 in oneM2M TS0004 [2]).
- After verifying the privileges and the given attributes, the hosting CSE shall send a notification for the received write request to the Modbus IPE (notification shall include nodnProperties ) and temporarily blocks the <flexContainer> resource for any UPDATE operations (see clause 7.5.1.2.2 in oneM2M TS0004 [2]).
- The Modbus IPE shall use information stored in nodnProperties to compose Modbus write request. The function code to be used can be identified from a register type and length as in Table 6.4-2. Slave id, address, and length should be written in corresponding message fields. After the Modbus message is composed the Modbus IPE shall send this message to Modbus device.
- The Modbus device responds with written data to the Modbus IPE.
- The Modbus IPE shall respond to the hosting CSE with successful device update message, otherwise respond with an error (see clause 7.5.1.2.2 in oneM2M TS0004 [2]).
- If the device was updated successfully, the hosting CSE shall update the <flexContainer> resource internally, otherwise discard the changes. The resource is unlocked for UPDATE operations.
- The hosting CSE shall respond to the AE with the result of the UPDATE request.
Figure 6.5.2-1: Writing to a Modbus Slave Device call flow