Some typo fixes to make debug related methods in LPCAppOject stop throwing exceptions, less agressive error message when unplugging LPC
authoredouard
Fri, 18 Feb 2011 12:29:48 +0100
changeset 576 7fcdc0d3d8d9
parent 575 6765adf58711
child 577 04baf6607a44
Some typo fixes to make debug related methods in LPCAppOject stop throwing exceptions, less agressive error message when unplugging LPC
LPCBeremiz.py
connectors/LPC/LPCAppObject.py
connectors/LPC/LPCAppProto.py
connectors/LPC/LPCObject.py
connectors/LPC/LPCProto.py
--- a/LPCBeremiz.py	Thu Feb 17 17:34:29 2011 +0100
+++ b/LPCBeremiz.py	Fri Feb 18 12:29:48 2011 +0100
@@ -499,8 +499,7 @@
                 if self.previous_plcstate=="Started":
                     if self.DebugAvailable() and self.GetIECProgramsAndVariables():
                         self.logger.write(_("Debug connect matching running PLC\n"))
-                        #TODO re-enable
-                        #self._connect_debug()
+                        self._connect_debug()
                     else:
                         self.logger.write_warning(_("Debug do not match PLC - stop/transfert/start to re-enable\n"))
             
@@ -834,8 +833,7 @@
         if self.GetIECProgramsAndVariables():
             self._connector.StartPLC()
             self.logger.write(_("Starting PLC\n"))
-            #TODO re-enable
-            #self._connect_debug()
+            self._connect_debug()
         else:
             self.logger.write_error(_("Couldn't start PLC !\n"))
         self.UpdateMethodsFromPLCStatus()
--- 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
--- a/connectors/LPC/LPCAppProto.py	Thu Feb 17 17:34:29 2011 +0100
+++ b/connectors/LPC/LPCAppProto.py	Fri Feb 18 12:29:48 2011 +0100
@@ -17,7 +17,7 @@
             else:
                 raise LPCProtoError("controller did not answer as expected")
         except Exception, e:
-            raise LPCProtoError("LPC transaction error : "+str(e))
+            raise LPCProtoError("application mode transaction error : "+str(e))
         finally:
             self.TransactionLock.release()
         return LPC_STATUS.get(current_plc_status,"Broken"), res
--- a/connectors/LPC/LPCObject.py	Thu Feb 17 17:34:29 2011 +0100
+++ b/connectors/LPC/LPCObject.py	Fri Feb 18 12:29:48 2011 +0100
@@ -46,7 +46,7 @@
                 self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction)
                 return res
             except Exception,e:
-                self.pluginsroot.logger.write_error(str(e)+"\n")
+                self.pluginsroot.logger.write_warning(str(e)+"\n")
                 self.SerialConnection.close()
                 self.SerialConnection = None
                 self.PLCStatus = "Disconnected"
--- a/connectors/LPC/LPCProto.py	Thu Feb 17 17:34:29 2011 +0100
+++ b/connectors/LPC/LPCProto.py	Fri Feb 18 12:29:48 2011 +0100
@@ -9,7 +9,7 @@
                 self.msg = msg
 
         def __str__(self):
-                return "LPC communication error ! " + str(self.msg)
+                return "Exception in PLC protocol : " + str(self.msg)
 
 class LPCProto:
     def __init__(self, port, rate, timeout):