connectors/LPC/LPCAppObject.py
changeset 576 7fcdc0d3d8d9
parent 575 6765adf58711
child 577 04baf6607a44
--- a/connectors/LPC/LPCAppObject.py	Thu Feb 17 17:34:29 2011 +0100
+++ b/connectors/LPC/LPCAppObject.py	Fri Feb 18 12:29:48 2011 +0100
@@ -94,10 +94,11 @@
             for idx,iectype,force in idxs:
                 idxstr = ctypes.string_at(
                           ctypes.pointer(
-                           ctypes.c_uint32(length)),4)
+                           ctypes.c_uint32(idx)),4)
                 if force !=None:
                     c_type,unpack_func, pack_func = self.TypeTranslator.get(iectype, (None,None,None))
-                    forcedsizestr = chr(ctypes.sizeof(c_type))
+                    forced_type_size = ctypes.sizeof(c_type)
+                    forcedsizestr = chr(forced_type_size)
                     forcestr = ctypes.string_at(
                                 ctypes.pointer(
                                  pack_func(c_type,force)),
@@ -117,8 +118,8 @@
         offset = 0
         strbuf = self.HandleSerialTransaction(
                                      GET_TRACE_VARIABLETransaction())
-        size = len(strbuf) - 4
-        if size > 0 and self.PLCStatus == "Started":
+        if strbuf is not None and len(strbuf) > 4 and self.PLCStatus == "Started":
+            size = len(strbuf) - 4
             tick = ctypes.cast(
                     ctypes.c_char_p(strbuf[:4]),
                     ctypes.POINTER(ctypes.c_int)).contents