--- a/LPCconnector/LPCAppProto.py Mon Apr 29 17:29:59 2013 +0900
+++ b/LPCconnector/LPCAppProto.py Mon Apr 29 17:31:24 2013 +0900
@@ -6,7 +6,6 @@
class LPCAppProto(LPCProto):
def HandleTransaction(self, transaction):
- self.TransactionLock.acquire()
transaction.SetPseudoFile(self.serialPort)
# send command, wait ack (timeout)
@@ -18,8 +17,6 @@
raise LPCProtoError("controller did not answer as expected")
raise LPCProtoError("application mode transaction error : "+str(e))
- self.TransactionLock.release()
return LPC_STATUS.get(current_plc_status,"Broken"), res
--- a/LPCconnector/LPCBootProto.py Mon Apr 29 17:29:59 2013 +0900
+++ b/LPCconnector/LPCBootProto.py Mon Apr 29 17:31:24 2013 +0900
@@ -2,12 +2,12 @@
class LPCBootProto(LPCProto):
def HandleTransaction(self, transaction):
- self.TransactionLock.acquire()
transaction.SetPseudoFile(self.serialPort)
res = transaction.ExchangeData()
- self.TransactionLock.release()
class LPCBootTransaction:
--- a/LPCconnector/LPCObject.py Mon Apr 29 17:29:59 2013 +0900
+++ b/LPCconnector/LPCObject.py Mon Apr 29 17:31:24 2013 +0900
@@ -24,15 +24,13 @@
def __init__(self, confnodesroot, comportstr):
+ self.TransactionLock = Lock() self.PLCStatus = "Disconnected"
self.confnodesroot = confnodesroot
self.PLCprint = confnodesroot.logger.writeyield
- comport = int(comportstr[3:]) - 1
@@ -41,19 +39,28 @@
self.PLCStatus = "Disconnected"
def HandleSerialTransaction(self, transaction):
+ self.TransactionLock.acquire() if self.SerialConnection is not None:
- self.PLCStatus, res = self.SerialConnection.HandleTransaction(transaction)
+ self.PLCStatus, res = \ + self.SerialConnection.HandleTransaction(transaction) - self.confnodesroot.logger.write(_("PLC disconnected\n"))
if self.SerialConnection is not None:
self.SerialConnection.close()
self.SerialConnection = None
self.PLCStatus = "Disconnected"
- self.confnodesroot.logger.write_warning(str(e)+"\n")
+ self.TransactionLock.release() + self.confnodesroot.logger.write(_("PLC disconnected\n")) + if failure is not None: + self.confnodesroot.logger.write_warning(failure+"\n") def StartPLC(self, debug=False):
raise LPCProtoError("Not implemented")
--- a/LPCconnector/LPCProto.py Mon Apr 29 17:29:59 2013 +0900
+++ b/LPCconnector/LPCProto.py Mon Apr 29 17:31:24 2013 +0900
@@ -14,7 +14,6 @@
def __init__(self, port, rate, timeout):
- self.TransactionLock = Lock()
self._serialPort = serial.Serial( port, rate, timeout = timeout, writeTimeout = timeout )