hutcheb commented on a change in pull request #174:
URL: https://github.com/apache/plc4x/pull/174#discussion_r462135084



##########
File path: protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
##########
@@ -247,9 +247,9 @@
 ]
 
 [type 'ModbusPDUReadFileRecordResponseItem'
-    [implicit   uint 8     'dataLength'     '(COUNT(data) * 2) + 1']
+    [simple   uint 8     'dataLength']

Review comment:
       Hi Chris,
   
   For this response you can have multiple sub responses/response items within 
the one response. In the overall PDU/response header there is only a total 
length and function code, there isn't any details about the length of each sub 
response or the number of sub responses. 
   I don't see a way of determining the number of sub responses without using 
the length from each sub response.

##########
File path: protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
##########
@@ -247,9 +247,9 @@
 ]
 
 [type 'ModbusPDUReadFileRecordResponseItem'
-    [implicit   uint 8     'dataLength'     '(COUNT(data) * 2) + 1']
+    [simple   uint 8     'dataLength']

Review comment:
       Hi Chris,
   
   The response does include the length of the sub-response within each 
sub-response, but this length can't be implied without using the other 
information such as from the request. Changing it to simple uses the length 
returned within the response.
   
   The length included in the sub-response is in bytes (not including the 
datalength byte), so if three short items are being returned the length would 
be 6 + 1.
   
   

##########
File path: protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
##########
@@ -247,9 +247,9 @@
 ]
 
 [type 'ModbusPDUReadFileRecordResponseItem'
-    [implicit   uint 8     'dataLength'     '(COUNT(data) * 2) + 1']
+    [simple   uint 8     'dataLength']

Review comment:
       Yes the value works out the same, but if you used implicit then you 
assume (Without using the returned value) that you know the length of the data 
in the response. 
   
   If we take an example with a response like this, we queried 2 memory areas. 
(in our case this would only happen when we request data that spans a file 
record e.g.609999[2]). The response would be:-
   
   0x14 - Function Code
   0x08 - Length of Overall Response
   0x03 - Length of Sub Response 1
   0x06 - Reference Type
   0x00 - Data Byte 1
   0x01 - Data Byte 2
   0x03 - Length of Sub Response 2
   0x06 - Reference Type
   0x00 - Data Byte 1
   0x00 - Data Byte 2
   
   If we used implicit for the sub response length, when parsing sub response 1 
we would assume the rest of the overall response is the data section in sub 
response 1 and the length would be 7 instead of 3. We would then not parse the 
second sub response.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to