variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
authorEdouard Tisserant
Mon, 26 Aug 2019 08:54:02 +0200
changeset 2632 534387caf43d
parent 2631 b5402859dfad
child 2633 fecdb71e7514
variable access code moved from plc_debug.c to targets/var_access.c for easiewr re-use in ext.
ProjectController.py
targets/plc_debug.c
targets/var_access.c
--- a/ProjectController.py	Tue Aug 20 10:08:11 2019 +0200
+++ b/ProjectController.py	Mon Aug 26 08:54:02 2019 +0200
@@ -1053,7 +1053,8 @@
                     "FB":  "extern       %(type)s   %(C_path)s;"
                 }[v["vartype"]] % v
                 for v in self._VariablesList if v["C_path"].find('.') < 0]),
-            "variable_decl_array": ",\n".join(variable_decl_array)
+            "variable_decl_array": ",\n".join(variable_decl_array),
+            "var_access_code": targets.GetCode("var_access.c")
         }
 
         return debug_code
--- a/targets/plc_debug.c	Tue Aug 20 10:08:11 2019 +0200
+++ b/targets/plc_debug.c	Mon Aug 26 08:54:02 2019 +0200
@@ -71,37 +71,9 @@
     }
 }
 
-#define __Unpack_case_t(TYPENAME) \
-        case TYPENAME##_ENUM :\
-            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
-            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
-            break;
-
-#define __Unpack_case_p(TYPENAME)\
-        case TYPENAME##_O_ENUM :\
-            *flags = __IEC_OUTPUT_FLAG;\
-        case TYPENAME##_P_ENUM :\
-            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
-            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
-            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
-            break;
-
-void* UnpackVar(dbgvardsc_t *dsc, void **real_value_p, char *flags)
-{
-    void *varp = dsc->ptr;
-    void *forced_value_p = NULL;
-    *flags = 0;
-    /* find data to copy*/
-    switch(dsc->type){
-        __ANY(__Unpack_case_t)
-        __ANY(__Unpack_case_p)
-    default:
-        break;
-    }
-    if (*flags & __IEC_FORCE_FLAG)
-        return forced_value_p;
-    return *real_value_p;
-}
+#define __Unpack_desc_type dbgvardsc_t
+
+%(var_access_code)s
 
 void Remind(unsigned int offset, unsigned int count, void * p);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/var_access.c	Mon Aug 26 08:54:02 2019 +0200
@@ -0,0 +1,33 @@
+
+#define __Unpack_case_t(TYPENAME) \
+        case TYPENAME##_ENUM :\
+            *flags = ((__IEC_##TYPENAME##_t *)varp)->flags;\
+            forced_value_p = *real_value_p = &((__IEC_##TYPENAME##_t *)varp)->value;\
+            break;
+
+#define __Unpack_case_p(TYPENAME)\
+        case TYPENAME##_O_ENUM :\
+            *flags = __IEC_OUTPUT_FLAG;\
+        case TYPENAME##_P_ENUM :\
+            *flags |= ((__IEC_##TYPENAME##_p *)varp)->flags;\
+            *real_value_p = ((__IEC_##TYPENAME##_p *)varp)->value;\
+            forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
+            break;
+
+static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
+{
+    void *varp = dsc->ptr;
+    void *forced_value_p = NULL;
+    *flags = 0;
+    /* find data to copy*/
+    switch(dsc->type){
+        __ANY(__Unpack_case_t)
+        __ANY(__Unpack_case_p)
+    default:
+        break;
+    }
+    if (*flags & __IEC_FORCE_FLAG)
+        return forced_value_p;
+    return *real_value_p;
+}
+