--- a/connectors/LPC/LPCAppObject.py Fri Feb 18 12:29:48 2011 +0100
+++ b/connectors/LPC/LPCAppObject.py Tue Feb 22 14:11:50 2011 +0100
@@ -98,7 +98,7 @@
if force !=None:
c_type,unpack_func, pack_func = self.TypeTranslator.get(iectype, (None,None,None))
forced_type_size = ctypes.sizeof(c_type)
- forcedsizestr = chr(forced_type_size)
+ forced_type_size_str = chr(forced_type_size)
forcestr = ctypes.string_at(
ctypes.pointer(
pack_func(c_type,force)),
@@ -119,15 +119,16 @@
strbuf = self.HandleSerialTransaction(
GET_TRACE_VARIABLETransaction())
if strbuf is not None and len(strbuf) > 4 and self.PLCStatus == "Started":
+ res=[]
size = len(strbuf) - 4
tick = ctypes.cast(
ctypes.c_char_p(strbuf[:4]),
ctypes.POINTER(ctypes.c_int)).contents
- buffer = ctypes.cast(
+ buff = ctypes.cast(
ctypes.c_char_p(strbuf[4:]),
ctypes.c_void_p)
for idx, iectype, forced in self._Idxs:
- cursor = ctypes.c_void_p(buffer.value + offset)
+ cursor = ctypes.c_void_p(buff.value + offset)
c_type,unpack_func, pack_func = self.TypeTranslator.get(iectype, (None,None,None))
if c_type is not None and offset < size:
res.append(unpack_func(ctypes.cast(cursor,
--- a/connectors/LPC/LPCBootObject.py Fri Feb 18 12:29:48 2011 +0100
+++ b/connectors/LPC/LPCBootObject.py Tue Feb 22 14:11:50 2011 +0100
@@ -46,7 +46,9 @@
def MatchMD5(self, MD5):
res = self.HandleSerialTransaction(CHECKMD5Transaction(MD5))
- return "".join(res).find('FAILED') == -1
+ if res :
+ return "".join(res).find('FAILED') == -1
+ return False
def SetTraceVariablesList(self, idxs):
--- a/targets/LPC/plc_LPC_main.c Fri Feb 18 12:29:48 2011 +0100
+++ b/targets/LPC/plc_LPC_main.c Tue Feb 22 14:11:50 2011 +0100
@@ -6,6 +6,12 @@
/* provided by POUS.C */
extern unsigned long long common_ticktime__;
+extern unsigned long __tick;
+
+static int debug_locked = 0;
+static int _DebugDataAvailable = 0;
+static unsigned long __debug_tick;
+
void LPC_GetTime(IEC_TIME*);
void LPC_SetTimer(unsigned long long next, unsigned long long period);
@@ -43,11 +49,16 @@
int TryEnterDebugSection(void)
{
- return __DEBUG;
+ if(!debug_locked && __DEBUG){
+ debug_locked = 1;
+ return 1;
+ }
+ return 0;
}
void LeaveDebugSection(void)
{
+ debug_locked = 0;
}
int stopPLC(void)
@@ -56,30 +67,40 @@
return 0;
}
-extern unsigned long __tick;
-int _DebugDataAvailable = 0;
/* from plc_debugger.c */
int WaitDebugData(unsigned long *tick)
{
- *tick = __tick;
- return _DebugDataAvailable;
+ /* no blocking call on LPC */
+ if(_DebugDataAvailable && !debug_locked){
+ /* returns 0 on success */
+ *tick = __debug_tick;
+ _DebugDataAvailable = 0;
+ return 0;
+ }
+ return 1;
}
/* Called by PLC thread when debug_publish finished
* This is supposed to unlock debugger thread in WaitDebugData*/
void InitiateDebugTransfer(void)
{
+ /* remember tick */
+ __debug_tick = __tick;
_DebugDataAvailable = 1;
}
void suspendDebug(int disable)
{
+ /* Prevent PLC to enter debug code */
__DEBUG = !disable;
+ debug_locked = !disable;
}
void resumeDebug(void)
{
+ /* Let PLC enter debug code */
__DEBUG = 1;
+ debug_locked = 0;
}
int CheckRetainBuffer(void)