connectors/LPC/LPCProto.py
changeset 563 c74a37d156df
parent 545 627e5c636a4f
child 571 427bf9130d12
--- a/connectors/LPC/LPCProto.py	Fri Jun 04 15:39:14 2010 +0200
+++ b/connectors/LPC/LPCProto.py	Fri Jun 04 16:11:19 2010 +0200
@@ -17,25 +17,32 @@
         # open serial port
 #        self.serialPort = serial.Serial( port, rate, timeout = timeout )
         # Debugging serial stuff
-        self._serialPort = serial.Serial( port, rate, timeout = timeout )
-        class myser:
-            def read(self_,cnt):
-                res = self._serialPort.read(cnt)
-                if len(res) > 16:
-                    print "Recv :", map(hex,map(ord,res[:16])), "[...]"
-                else:
-                    print "Recv :", map(hex,map(ord,res))
-                    
-                return res
-            def write(self_, str):
-                if len(str) > 16:
-                    print "Send :", map(hex,map(ord,str[:16])), "[...]"
-                else:
-                    print "Send :", map(hex,map(ord,str))
-                self._serialPort.write(str)
-            def flush(self_):
-                self._serialPort.flush()
-        self.serialPort = myser()
+        self.serialPort = serial.Serial( port, rate, timeout = timeout )
+#        class myser:
+#            def read(self_,cnt):
+#                res = self._serialPort.read(cnt)
+#                if len(res) > 16:
+#                    print "Recv :", map(hex,map(ord,res[:16])), "[...]"
+#                else:
+#                    print "Recv :", map(hex,map(ord,res))
+#                    
+#                return res
+#            def write(self_, str):
+#                if len(str) > 16:
+#                    print "Send :", map(hex,map(ord,str[:16])), "[...]"
+#                else:
+#                    print "Send :", map(hex,map(ord,str))
+#                self._serialPort.write(str)
+#            def flush(self_):
+#                self._serialPort.flush()
+#        self.serialPort = myser()
         # start with empty
         self.serialPort.flush()
     
+    def __del__(self):
+        if self.serialPort:
+            self.serialPort.close()
+
+    def close(self):
+        self.serialPort.close()
+        self.serialPort = None