Elias Bakken avatar Elias Bakken committed 0ffbdbc

comitting latest

Comments (0)

Files changed (3)

Add a comment to this file


Binary file added.


 from threading import Thread
 import socket
 import logging
+import select
 size = 1024 
     # Loop that gets messages and pushes them on the queue
     def get_message(self):
         while self.running:
+            print "Ethernet listening"
             self.client, self.address = self.s.accept()
-            try: 
-                while True:
-                    data = ''
-                    while not "\n" in data:
-                        data += self.client.recv(1)
-                    message = data.strip("\n")
-                    self.queue.put({"message": message, "prot": "Eth"})
-            except IOError as e:
-                print "Connection closed"
-            finally:
-                self.client.close()             
+            print "Ethernet connection accepted"
+            while True:
+                line = ''
+#                ready = select.select([self.client], [], [], 0.25)
+#                if ready[0]:
+                while not "\n" in line:
+                    chunk = self.client.recv(1)
+                    if chunk == '':
+                        print "Ethernet: Connection reset by Per."
+                        self.client.close()             
+                        break
+                    line = line + chunk
+                if not "\n" in line: # Make sure the whole line was read. 
+                    break
+                message = line.strip("\n")
+                self.queue.put({"message": message, "prot": "Eth"})
     # Send a message		


 import time
 import Queue 
 import logging
+import traceback
 from Mosfet import Mosfet
 from Smd import SMD
 LCD = False
 class Replicape:
     ''' Init '''
     def __init__(self):
         except KeyboardInterrupt:
-            print "Caught signal, exiting" 
+            print "Caught keyboard interrupt signal, exiting" 
         except Exception as e:
-            print e
-        finally:
+            print "Something whent wrong.."            
+            print traceback.format_exc()
+        finally:			
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.