Beispiel #1
0
            except socket.error as msg:
                sys.stderr.write('ERROR: %s\n' % msg)
                # probably got disconnected
                break
        self.alive = False
        self.thread_read.join()

    def stop(self):
        """Stop copying"""
        if self.alive:
            self.alive = False
            self.thread_read.join()


LOCAL_PORT = 7777
ser = detect_sfp_serial()
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.bind(('', LOCAL_PORT))
srv.listen(1)
while True:
    try:
        sys.stderr.write("Waiting for connection on %s...\n" % LOCAL_PORT)
        connection, addr = srv.accept()
        sys.stderr.write('Connected by %s\n' % (addr,))
        Redirector(ser, connection)
        sys.stderr.write('Disconnected\n')
        connection.close()
    except KeyboardInterrupt:
        break
    except socket.error as msg:
        sys.stderr.write('ERROR: %s\n' % msg)
Beispiel #2
0
 def __init__(self, serial_port=None, uid=None):
     self.serial_port = serial_port
     if not self.serial_port:
         self.serial_port = detect_sfp_serial(uid)