Elias Bakken avatar Elias Bakken committed 0ffbdbc

comitting latest

Comments (0)

Files changed (3)

Add a comment to this file

Doc/Datasheets/lm139a.pdf

Binary file added.

software/Ethernet.py

 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		

software/Replicape.py

 import time
 import Queue 
 import logging
+import traceback
 
 from Mosfet import Mosfet
 from Smd import SMD
 DEVICE_TREE = True
 LCD = False
 
-
-
 class Replicape:
     ''' Init '''
     def __init__(self):
                     self.ethernet.send_message(gcode.getAnswer())
                 self.commands.task_done()
         except KeyboardInterrupt:
-            print "Caught signal, exiting" 
+            print "Caught keyboard interrupt signal, exiting" 
             return
         except Exception as e:
-            print e
-        finally:
+            print "Something whent wrong.."            
+            print traceback.format_exc()
+        finally:			
             self.ext1.disable()            
             #self.hbp.disable()            
             self.usb.close() 
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.