Advertisement
Guest User

Untitled

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