SHARE
TWEET

Untitled

a guest May 19th, 2017 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
  3. # See LICENSE for details.
  4.  
  5.  
  6. from twisted.internet import reactor, protocol
  7. from twisted.protocols.basic import LineReceiver
  8. #from pyroomba import *
  9.  
  10. class RoombaPro(LineReceiver):
  11.     """This is .... """
  12.     #def __init__(self):
  13.         #roomba = None
  14.  
  15.     def connectionMade(self):
  16.         "Starting Roomba"
  17.         #roomba = RoombaClassic(2)
  18.         #roomba.start()
  19.         #roomba.safe()
  20.  
  21.     def lineReceived(self, data):
  22.         "As soon as any data is received, write it back."
  23.         #roomba.drive(255,0)
  24.         print data
  25.         self.sendLine(sendSensors())
  26.  
  27.     def connectionLost(self, reason):
  28.         "Stop Roomba"
  29.         #roomba.drive(0,0)
  30.         #roomba.stop()
  31.         #roomba.close()
  32.    
  33.     def sendSensors(self):
  34.         return "Test"
  35.  
  36. def main():
  37.     """This runs the protocol on port 8000"""
  38.     factory = protocol.ServerFactory()
  39.     factory.protocol = RoombaPro
  40.     reactor.listenTCP(8000, factory)
  41.     reactor.run()
  42.  
  43. # this only runs if the module was *not* imported
  44. if __name__ == '__main__':
  45.     main()
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top