--- a/targets/plc_debug.c Fri Jul 03 14:02:04 2020 +0200
+++ b/targets/plc_debug.c Tue Jan 14 11:04:18 2020 +0100
@@ -100,7 +100,7 @@
void __init_debug(void)
{
/* init local static vars */
-#ifndef TARGET_ONLINE_DEBUG_DISABLE
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
buffer_cursor = debug_buffer;
buffer_state = BUFFER_FREE;
#endif
@@ -109,9 +109,9 @@
InitRetain();
/* Iterate over all variables to fill debug buffer */
if(CheckRetainBuffer()){
- __for_each_variable_do(RemindIterator);
+ __for_each_variable_do(RemindIterator);
}else{
- char mstr[] = "RETAIN memory invalid - defaults used";
+ char mstr[] = "RETAIN memory invalid - defaults used";
LogMessage(LOG_WARNING, mstr, sizeof(mstr));
}
retain_offset = 0;
@@ -124,7 +124,7 @@
void __cleanup_debug(void)
{
-#ifndef TARGET_ONLINE_DEBUG_DISABLE
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
buffer_cursor = debug_buffer;
InitiateDebugTransfer();
#endif
@@ -150,16 +150,14 @@
if(flags & ( __IEC_DEBUG_FLAG | __IEC_RETAIN_FLAG)){
USINT size = __get_type_enum_size(dsc->type);
-#ifndef TARGET_ONLINE_DEBUG_DISABLE
+#ifndef TARGET_ONLINE_DEBUG_DISABLE
if(flags & __IEC_DEBUG_FLAG){
/* copy visible variable to buffer */;
if(do_debug){
/* compute next cursor positon.
No need to check overflow, as BUFFER_SIZE
is computed large enough */
- if((dsc->type == STRING_ENUM) ||
- (dsc->type == STRING_P_ENUM) ||
- (dsc->type == STRING_O_ENUM)){
+ if(__Is_a_string(dsc)){
/* optimization for strings */
size = ((STRING*)visible_value_p)->len + 1;
}
@@ -174,7 +172,7 @@
memcpy(real_value_p, visible_value_p, size);
}
}
-#endif
+#endif
if(flags & __IEC_RETAIN_FLAG){
/* compute next cursor positon*/
--- a/targets/var_access.c Fri Jul 03 14:02:04 2020 +0200
+++ b/targets/var_access.c Tue Jan 14 11:04:18 2020 +0100
@@ -14,6 +14,10 @@
forced_value_p = &((__IEC_##TYPENAME##_p *)varp)->fvalue;\
break;
+#define __Is_a_string(dsc) (dsc->type == STRING_ENUM) ||\
+ (dsc->type == STRING_P_ENUM) ||\
+ (dsc->type == STRING_O_ENUM)
+
static void* UnpackVar(__Unpack_desc_type *dsc, void **real_value_p, char *flags)
{
void *varp = dsc->ptr;