Runtime: Fix IEC/ctypes/python3 type mapping
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Mon, 22 May 2023 14:38:25 +0200
changeset 3813 6f3e20690172
parent 3812 92e528718733
child 3814 ab0afe798428
Runtime: Fix IEC/ctypes/python3 type mapping
runtime/typemapping.py
--- a/runtime/typemapping.py	Mon May 22 14:37:15 2023 +0200
+++ b/runtime/typemapping.py	Mon May 22 14:38:25 2023 +0200
@@ -23,18 +23,18 @@
                 ("ns", c_long)]  # tv_nsec
 
 
-def _t(t, u=lambda x: x.contents, p=lambda t, x: t(x)):
+def _t(t, u=lambda x: x.value, p=lambda t, x: t(x)):
     return (t, u, p)
 
 
 def _ttime():
     return (IEC_TIME,
-            lambda x: td(0, x.contents.s, x.contents.ns/1000.0),
+            lambda x: td(0, x.s, x.ns/1000.0),
             lambda t, x: t(x.days * 24 * 3600 + x.seconds, x.microseconds*1000))
 
 
 SameEndianessTypeTranslator = {
-    "BOOL":       _t(c_uint8, lambda x: bool(x.contents)),
+    "BOOL":       _t(c_uint8, lambda x: bool(x.value)),
     "STEP":       _t(c_uint8),
     "TRANSITION": _t(c_uint8),
     "ACTION":     _t(c_uint8),
@@ -42,7 +42,7 @@
     "USINT":      _t(c_uint8),
     "BYTE":       _t(c_uint8),
     "STRING":     (IEC_STRING,
-                   lambda x: x.contents.body[:x.contents.len],
+                   lambda x: x.body[:x.len],
                    lambda t, x: t(len(x), x)),
     "INT":        _t(c_int16),
     "UINT":       _t(c_uint16),