View Issue Details

IDProjectCategoryView StatusLast Update
000819110000-014: PubSubSpecpublic2022-09-22 17:06
ReporterThomas Merk Assigned ToMatthias Damm  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version1.05.01 
Fixed in Version1.05.02 
Summary0008191: Padding of Strings unclear
Description

Regarding padding of String (and ByteString) specification is totally unclear.

Excerpts from specification:
1.
Table 7 – FieldMetaData structure
maxStringLength UInt32
If the dataType field is a String, LocalizedText or ByteString then this field
specifies the maximum supported length. If the maximum is unknown the value
shall be 0.
If the dataType field is not a String, LocalizedText or ByteString the value shall
be 0.
If the valueRank is greater than 0 this field applies to each element of the
array.

2.
7.2.2.5.9 RawData field encoding
The encoding of the DataSetMessage fields is handled like a Structure DataType where the
DataSet fields are handled like Structure fields and fields with Structure DataType are handled
like nested structures.
...
If the DataType of a DataSet field or a Structure field is String or ByteString and the
actual size is smaller than the maximum possible size indicated by the dimensions, the
field shall be padded with bytes with value zero.

Issue A)
It is allowed to specify maxStringLength for LocalizedText.
As far as I understand this member is used for RawData encoding only.
But LocalizedText is not allowed for RawData encoding.
Or is there any other place (e.g. Variant encoding) where the length of a localize text shall be validated too?
And if yes, what reaction is defined if length exceeds maxStringLength?

Issue B)
I just refer to String instead of "String and ByteString" at all the places.

According to 1. maxStringLength shall not be specified for structures.
According to 2. Strings shall be padded within structures "indicated by the dimension"

Nowhere is mentioned what that "indicated by dimensions" means.
Since maxStringLength cannot be specified, it could be the maxStringLength from "StructureField Structure" in part 3.
If it is so, please state is explicitely.
By the way - in part 3 nowhere is mentioned how encoding shall be affected if the string (ByteString or LocalizedText) exceeds this value...
For PubSub I assume that the DataSetPayload shall be marked as "Invalid".

De facto "encoding ... is handled like a Structure DataType" is not correct - a different behavior (algorithm) has to be implemented.
Since encoding in PubSub shall use padding of String values encoding of Structures shall not.
=> "encoding ... is handled like a Structure DataType modulo padding of String values (and arrays and matrices)" would be more correct.

I did not mention here arrayDimensions and row-wise padding in matrices (within structure fields); but the same issues are there as well.

TagsNo tags attached.
Commit Version
Fix Due Date

Activities

jpfr

2022-09-21 07:29

reporter   ~0017741

If the DataType of a DataSet field or a Structure field is String or ByteString and the
actual size is smaller than the maximum possible size indicated by the dimensions.

Why does this mention dimensions? This sounds like array dimensions.
I would expect this to be the MaxStringLength setting.

What is the relation between the MaxStringLength in the FieldMetaData and the MaxStringLength in the "StructureFieldStructure" from Part 3? Do they have to be the same valeu?
Because the FieldMetaData is generated and not set from the outside.

Matthias Damm

2022-09-22 15:41

developer   ~0017802

Issue A)
FieldMetaData.MaxStringLength definition is copied from StructureField.MaxStringLength.
The information MaxStringLength and ArrayDimensions was available in OPCUA before PubSub or raw encoding was introduced.
Example for use outside raw encoding is write to a variable value. With MaxStringLength a client can know the maximum length of the localized text that can be written to a LocalizedText variable.
In PubSub it can be used on the receive side in case of Variant encoding to verified if the target variable allows the expected max size. This is a important topic in controller to controller communication since they are typically working with fixed length registers.

Issue B)
Structures are described by StructureDefinition + StructureField and the MaxStringLength in StructureField. Therefore there is a dedicated MaxStringLength for all String fields either in the DataSetField (FieldMetaData ) or in the structure field (StructureField).

The only problem is that in (2) the text about String refers to dimensions instead of MaxStringLength.

Changes made to 1.05.02 for release:

Replaced
If the DataType of a DataSet field or a Structure field is String or ByteString and the actual size is smaller than the maximum possible size indicated by the dimensions, the field shall be padded with bytes with value zero.
with
If the DataType of a DataSet field or a Structure field is String or ByteString and the actual size is smaller than the maximum possible size indicated by the MaxStringLength, the field shall be padded with bytes with value zero.

Extended
The encoding of the DataSetMessage fields is handled like a Structure DataType where the DataSet fields are handled like Structure fields and fields with Structure DataType are handled like nested structures.
with
... but in addition the fields are padded to the maximum size indicated by ArrayDimensions or MaxStringLength

Jim Luth

2022-09-22 17:06

administrator   ~0017808

Agreed to changes in F2F meeting.

Issue History

Date Modified Username Field Change
2022-08-10 14:11 Thomas Merk New Issue
2022-08-23 16:38 Jim Luth Assigned To => Matthias Damm
2022-08-23 16:38 Jim Luth Status new => assigned
2022-09-21 07:29 jpfr Note Added: 0017741
2022-09-22 15:41 Matthias Damm Status assigned => resolved
2022-09-22 15:41 Matthias Damm Resolution open => fixed
2022-09-22 15:41 Matthias Damm Note Added: 0017802
2022-09-22 17:06 Jim Luth Status resolved => closed
2022-09-22 17:06 Jim Luth Fixed in Version => 1.05.02
2022-09-22 17:06 Jim Luth Note Added: 0017808