fdupont-epsilia commented on code in PR #1902:
URL: https://github.com/apache/plc4x/pull/1902#discussion_r1858618754


##########
plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java:
##########
@@ -1953,13 +1949,28 @@ protected Optional<AdsDataTypeTableEntry> 
getDataTypeTableEntry(String name) {
             return Optional.of(dataTypeTable.get(name));
         }
         try {
-            AdsDataType adsDataType = AdsDataType.valueOf(name);
+            AdsDataType adsDataType;
+            int numBytes;
+
+            if (name.startsWith("STRING(")) {
+                adsDataType = AdsDataType.valueOf("CHAR");
+                numBytes = Integer.parseInt(name.substring(7, name.length() - 
1)) + 1;
+            }
+            else if (name.startsWith("WSTRING(")) {
+                adsDataType = AdsDataType.valueOf("WCHAR");
+                numBytes = Integer.parseInt(name.substring(8, name.length() - 
1)) * 2 + 2;
+            }
+            else {
+                adsDataType = AdsDataType.valueOf(name);
+                numBytes = adsDataType.getNumBytes();
+            }
+
             // !It seems that the dataType value differs from system to system,
             // !However, we never really seem to use that value, so I would 
say it doesn't matter.
             return Optional.of(new AdsDataTypeTableEntry(
-                128, 1, 0, 0, adsDataType.getNumBytes(), 0,
+                128, 1, 0, 0, numBytes, 0,
                 adsDataType.getValue(), 0, 0, 0,
-                adsDataType.name(), "", "",

Review Comment:
   Sorry, there are delay in my reply. My reply was to sruehl question.
   adsDataType.name() = "STRING"
   name = "STRING(any length here)"
   So they are not « semantical still the same » for STRING. For other base 
type (such as BOOL), they are the same. 
   And we need "STRING(any length here)" for the rest of the code to work.



-- 
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.

To unsubscribe, e-mail: dev-unsubscr...@plc4x.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to