Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading DefaultValue from EDS is wrong for data type OCTET_STRING and DOMAIN #217

Closed
mlederhi opened this issue Jan 15, 2021 · 3 comments
Closed

Comments

@mlederhi
Copy link
Contributor

mlederhi commented Jan 15, 2021

The DefaultValue for data type OCTET_STRING and DOMAIN is formatted with two hex digits for each byte in the EDS - see corresponding CiA standard. Also the content of the default value has to end up in a bytes instance and not in a string instance. (otherwise an exception is thrown when the SDOServer tries to answer a SDO upload request for an object dictionary entry with this data type.)

Please see the following patch, and please integrate it:

--- eds.py.orig	2021-01-13 15:50:52.906669000 +0100
+++ eds.py	2021-01-15 12:48:02.089073320 +0100
@@ -138,7 +138,9 @@
 
 
 def _convert_variable(node_id, var_type, value):
-    if var_type in objectdictionary.DATA_TYPES:
+    if var_type in (objectdictionary.OCTET_STRING, objectdictionary.DOMAIN):
+        return bytes.fromhex(value)
+    elif var_type in (objectdictionary.VISIBLE_STRING, objectdictionary.UNICODE_STRING):
         return value
     elif var_type in objectdictionary.FLOAT_TYPES:
         return float(value)

@christiansandberg
Copy link
Owner

Thank you for that finding. Would you be able to provide a pull request? I don't have a development environment setup right now.

@mlederhi
Copy link
Contributor Author

Created pull requerst #219.

@christiansandberg
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants