--- a/connectors/LPC/LPCAppObject.py Thu Mar 31 19:04:03 2011 +0200
+++ b/connectors/LPC/LPCAppObject.py Thu Mar 31 19:09:49 2011 +0200
@@ -25,6 +25,7 @@
from LPCAppProto import *
+from targets.typemapping import SameEndianessTypeTranslator as TypeTranslator class LPCAppObject(LPCObject):
def connect(self,comport):
--- a/plugger.py Thu Mar 31 19:04:03 2011 +0200
+++ b/plugger.py Thu Mar 31 19:09:49 2011 +0200
@@ -680,29 +680,11 @@
from TextViewer import TextViewer
from plcopen.structures import IEC_KEYWORDS, TypeHierarchy_list
-# Construct debugger natively supported types
-DebugTypes = [t for t in zip(*TypeHierarchy_list)[0] if not t.startswith("ANY")]
-DebugTypesSize = {"BOOL" : 1,
+from targets.typemapping import DebugTypesSize from discovery import DiscoveryDialog
from weakref import WeakKeyDictionary
@@ -1346,7 +1328,7 @@
"IN":" (*fp)((void*)&%(C_path)s,%(type)s_P_ENUM);\n",
"OUT":" (*fp)((void*)&%(C_path)s,%(type)s_O_ENUM);\n",
"VAR":" (*fp)((void*)&%(C_path)s,%(type)s_ENUM);\n"}[v["vartype"]]%v
- for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ]),
+ for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypesSize ]), "find_variable_case_code":"\n".join([
" *varp = (void*)&%(C_path)s;\n"%v+
@@ -1354,7 +1336,7 @@
"IN":" return %(type)s_P_ENUM;\n",
"OUT":" return %(type)s_O_ENUM;\n",
"VAR":" return %(type)s_ENUM;\n"}[v["vartype"]]%v
- for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypes ])}
+ for v in self._VariablesList if v["vartype"] != "FB" and v["type"] in DebugTypesSize ])} @@ -1604,7 +1586,10 @@
Idx, IEC_Type = self._IECPathToIdx.get(IECPath,(None,None))
- Idxs.append((Idx, IEC_Type, fvalue, IECPath))
+ if IEC_Type in DebugTypesSize: + Idxs.append((Idx, IEC_Type, fvalue, IECPath)) + self.logger.write_warning(_("Debug : Unsuppoted type to debug %s\n")%IEC_Type) self.logger.write_warning(_("Debug : Unknown variable %s\n")%IECPath)
for IECPathToPop in IECPathsToPop:
--- a/runtime/PLCObject.py Thu Mar 31 19:04:03 2011 +0200
+++ b/runtime/PLCObject.py Thu Mar 31 19:09:49 2011 +0200
@@ -25,6 +25,8 @@
from threading import Timer, Thread, Lock
import ctypes, os, commands, types, sys
+from datetime import timedelta as td +from targets.typemapping import SameEndianessTypeTranslator as TypeTranslator if os.name in ("nt", "ce"):
from _ctypes import LoadLibrary as dlopen
@@ -320,35 +322,7 @@
- class IEC_STRING(ctypes.Structure):
- Must be changed according to changes in iec_types.h
- _fields_ = [("len", ctypes.c_uint8),
- ("body", ctypes.c_char * 126)]
- TypeTranslator = {"BOOL" : (ctypes.c_uint8, lambda x:x.value!=0, lambda t,x:t(x)),
- "STEP" : (ctypes.c_uint8, lambda x:x.value, lambda t,x:t(x)),
- "TRANSITION" : (ctypes.c_uint8, lambda x:x.value, lambda t,x:t(x)),
- "ACTION" : (ctypes.c_uint8, lambda x:x.value, lambda t,x:t(x)),
- "SINT" : (ctypes.c_int8, lambda x:x.value, lambda t,x:t(x)),
- "USINT" : (ctypes.c_uint8, lambda x:x.value, lambda t,x:t(x)),
- "BYTE" : (ctypes.c_uint8, lambda x:x.value, lambda t,x:t(x)),
- "STRING" : (IEC_STRING, lambda x:x.body[:x.len], lambda t,x:t(len(x),x)),
- "INT" : (ctypes.c_int16, lambda x:x.value, lambda t,x:t(x)),
- "UINT" : (ctypes.c_uint16, lambda x:x.value, lambda t,x:t(x)),
- "WORD" : (ctypes.c_uint16, lambda x:x.value, lambda t,x:t(x)),
- "WSTRING" : (None, None, None),#TODO
- "DINT" : (ctypes.c_int32, lambda x:x.value, lambda t,x:t(x)),
- "UDINT" : (ctypes.c_uint32, lambda x:x.value, lambda t,x:t(x)),
- "DWORD" : (ctypes.c_uint32, lambda x:x.value, lambda t,x:t(x)),
- "LINT" : (ctypes.c_int64, lambda x:x.value, lambda t,x:t(x)),
- "ULINT" : (ctypes.c_uint64, lambda x:x.value, lambda t,x:t(x)),
- "LWORD" : (ctypes.c_uint64, lambda x:x.value, lambda t,x:t(x)),
- "REAL" : (ctypes.c_float, lambda x:x.value, lambda t,x:t(x)),
- "LREAL" : (ctypes.c_double, lambda x:x.value, lambda t,x:t(x)),
def SetTraceVariablesList(self, idxs):
Call ctype imported function to append
@@ -392,7 +366,7 @@
c_type,unpack_func, pack_func = \
self.TypeTranslator.get(iectype,
- if c_type is not None and offset < size:
+ if c_type is not None and offset < size.value: ctypes.POINTER(c_type)).contents))
@@ -401,14 +375,14 @@
PLCprint("Debug error - " + iectype +
- PLCprint("Debug error - buffer too small !")
+ #if offset >= size.value: + #PLCprint("Debug error - buffer too small ! %d != %d"%(offset, size.value)) self.PLClibraryLock.release()
if offset and offset == size.value:
return self.PLCStatus, tick.value, res
- PLCprint("Debug error - wrong buffer unpack !")
- return self.PLCStatus, None, None
+ #PLCprint("Debug error - wrong buffer unpack ! %d != %d"%(offset, size.value)) + return self.PLCStatus, None, [] --- a/targets/Linux/plc_Linux_main.c Thu Mar 31 19:04:03 2011 +0200
+++ b/targets/Linux/plc_Linux_main.c Thu Mar 31 19:09:49 2011 +0200
@@ -20,7 +20,10 @@
void PLC_GetTime(IEC_TIME *CURRENT_TIME)
- clock_gettime(CLOCK_REALTIME, CURRENT_TIME);
+ clock_gettime(CLOCK_REALTIME, &tmp); + CURRENT_TIME->tv_sec = tmp.tv_sec; + CURRENT_TIME->tv_nsec = tmp.tv_nsec; void PLC_timer_notify(sigval_t val)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/targets/typemapping.py Thu Mar 31 19:09:49 2011 +0200
@@ -0,0 +1,73 @@
+#Copyright (C) 2011: Edouard TISSERANT and Laurent BESSARD +#See COPYING file for copyrights details. +#This library is free software; you can redistribute it and/or +#modify it under the terms of the GNU General Public +#License as published by the Free Software Foundation; either +#version 2.1 of the License, or (at your option) any later version. +#This library is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +#General Public License for more details. +#You should have received a copy of the GNU General Public +#License along with this library; if not, write to the Free Software +#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +class IEC_STRING(Structure): + Must be changed according to changes in iec_types.h + _fields_ = [("len", c_uint8), + ("body", c_char * 126)] +class IEC_TIME(Structure): + Must be changed according to changes in iec_types.h + _fields_ = [("s", c_long), #tv_sec + ("ns", c_long)] #tv_nsec +def _t(t, u=lambda x:x.value, p=lambda t,x:t(x)): return (t, u, p) +SameEndianessTypeTranslator = { + "BOOL" : _t(c_uint8, lambda x:x.value!=0), + "TRANSITION" : _t(c_uint8), + "ACTION" : _t(c_uint8), + "STRING" : _t(IEC_STRING, + lambda x:x.body[:x.len], + lambda t,x:t(len(x),x)), + "UDINT" : _t(c_uint32), + "DWORD" : _t(c_uint32), + "ULINT" : _t(c_uint64), + "LWORD" : _t(c_uint64), + "LREAL" : _t(c_double), + lambda x:td(0, x.s, x.ns/1000), + lambda t,x:t(x.seconds, x.microseconds*1000)), +SwapedEndianessTypeTranslator = { +# Construct debugger natively supported types +DebugTypesSize = dict([(key,sizeof(t)) for key,(t,p,u) in SameEndianessTypeTranslator.iteritems() if t is not None])