# HG changeset patch # User etisserant # Date 1220533072 -7200 # Node ID a32817e81f5e56ebd03c5d99560923ff8f4c2260 # Parent a66e150f288872ffe5005c206f7d0900f3f2eb90 Now debug all ticks, not only odd ones :-) diff -r a66e150f2888 -r a32817e81f5e plugger.py --- a/plugger.py Wed Sep 03 17:28:17 2008 +0200 +++ b/plugger.py Thu Sep 04 14:57:52 2008 +0200 @@ -1349,7 +1349,7 @@ WeakCallableDict, data_log, status = data_tuple data_log.append((debug_tick, value)) for weakcallable,(args,kwargs) in WeakCallableDict.iteritems(): - wx.CallAfter(weakcallable, value, *args, **kwargs) + wx.CallAfter(weakcallable.SetValue, value, *args, **kwargs) elif debug_vars is not None: wx.CallAfter(self.logger.write_warning, "debug data not coherent %d != %d"%(len(debug_vars), len(self.TracedIECPath))) @@ -1383,7 +1383,7 @@ # self.buf = None # def setbuf(self,buf): # self.buf = buf -# def __call__(self, value, idx, name): +# def SetValue(self, value, idx, name): # print "debug call:", value, idx, name, self.buf # a = tmpcls() # res = self.SubscribeDebugIECVariable(IEC_Path, a, idx, IEC_Path) diff -r a66e150f2888 -r a32817e81f5e targets/Linux/plc_Linux_main.c --- a/targets/Linux/plc_Linux_main.c Wed Sep 03 17:28:17 2008 +0200 +++ b/targets/Linux/plc_Linux_main.c Thu Sep 04 14:57:52 2008 +0200 @@ -5,7 +5,7 @@ #include #include -long AtomicCompareExchange(long* atomicvar,long exchange, long compared) +long AtomicCompareExchange(long* atomicvar,long compared, long exchange) { return __sync_val_compare_and_swap(atomicvar, compared, exchange); } @@ -95,9 +95,9 @@ { /* Eventually unlock debugger thread*/ __debug_tick = -1; - pthread_mutex_lock(&wait_mutex); + //pthread_mutex_lock(&wait_mutex); pthread_cond_broadcast(&wait_cond); - pthread_mutex_unlock(&wait_mutex); + //pthread_mutex_unlock(&wait_mutex); } int stopPLC() @@ -126,7 +126,7 @@ { /* signal debugger thread to continue*/ __debug_tick = __tick; - pthread_mutex_lock(&wait_mutex); + //pthread_mutex_lock(&wait_mutex); pthread_cond_broadcast(&wait_cond); - pthread_mutex_unlock(&wait_mutex); + //pthread_mutex_unlock(&wait_mutex); } diff -r a66e150f2888 -r a32817e81f5e targets/plc_common_main.c --- a/targets/plc_common_main.c Wed Sep 03 17:28:17 2008 +0200 +++ b/targets/plc_common_main.c Thu Sep 04 14:57:52 2008 +0200 @@ -33,7 +33,7 @@ **/ IEC_TIME __CURRENT_TIME; -int __tick = 0; +int __tick = -1; static int init_level = 0; static int Debugging = 0; @@ -50,6 +50,8 @@ **/ void __run() { + __tick++; + %(retrieve_calls)s if(Debugging) __retrieve_debug(); @@ -62,7 +64,6 @@ %(publish_calls)s - __tick++; } /* diff -r a66e150f2888 -r a32817e81f5e targets/plc_debug.c --- a/targets/plc_debug.c Wed Sep 03 17:28:17 2008 +0200 +++ b/targets/plc_debug.c Thu Sep 04 14:57:52 2008 +0200 @@ -136,17 +136,28 @@ &buffer_state, BUFFER_BUSY, BUFFER_FREE); - subscription_cursor = subscription_table; } void* IterDebugData(int* idx, const char **type_name) { if(subscription_cursor < latest_subscription){ + char* old_cursor = buffer_cursor; *idx = *subscription_cursor; struct_plcvar* my_var = &variable_table[*(subscription_cursor++)]; *type_name = __get_type_enum_name(my_var->type); - return my_var->ptrvalue; + /* get variable size*/ + USINT size = __get_type_enum_size(my_var->type); + /* compute next cursor positon*/ + buffer_cursor = buffer_cursor + size; + if(old_cursor < debug_buffer + BUFFER_SIZE) + { + return old_cursor; + }else{ + return NULL; + } } + *idx = -1; + *type_name = NULL; return NULL; }