mbed-os

Dependents:   cobaLCDJoyMotor_Thread odometry_omni_3roda_v3 odometry_omni_3roda_v1 odometry_omni_3roda_v2 ... more

Committer:
be_bryan
Date:
Mon Dec 11 17:54:04 2017 +0000
Revision:
0:b74591d5ab33
motor ++

Who changed what in which revision?

UserRevisionLine numberNew contents of line
be_bryan 0:b74591d5ab33 1 """
be_bryan 0:b74591d5ab33 2 mbed SDK
be_bryan 0:b74591d5ab33 3 Copyright (c) 2011-2013 ARM Limited
be_bryan 0:b74591d5ab33 4
be_bryan 0:b74591d5ab33 5 Licensed under the Apache License, Version 2.0 (the "License");
be_bryan 0:b74591d5ab33 6 you may not use this file except in compliance with the License.
be_bryan 0:b74591d5ab33 7 You may obtain a copy of the License at
be_bryan 0:b74591d5ab33 8
be_bryan 0:b74591d5ab33 9 http://www.apache.org/licenses/LICENSE-2.0
be_bryan 0:b74591d5ab33 10
be_bryan 0:b74591d5ab33 11 Unless required by applicable law or agreed to in writing, software
be_bryan 0:b74591d5ab33 12 distributed under the License is distributed on an "AS IS" BASIS,
be_bryan 0:b74591d5ab33 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
be_bryan 0:b74591d5ab33 14 See the License for the specific language governing permissions and
be_bryan 0:b74591d5ab33 15 limitations under the License.
be_bryan 0:b74591d5ab33 16 """
be_bryan 0:b74591d5ab33 17 # Be sure that the tools directory is in the search path
be_bryan 0:b74591d5ab33 18 import sys
be_bryan 0:b74591d5ab33 19 from os.path import join, abspath, dirname
be_bryan 0:b74591d5ab33 20 ROOT = abspath(join(dirname(__file__), "..", ".."))
be_bryan 0:b74591d5ab33 21 sys.path.insert(0, ROOT)
be_bryan 0:b74591d5ab33 22
be_bryan 0:b74591d5ab33 23 from mbed_settings import LOCALHOST
be_bryan 0:b74591d5ab33 24 from SocketServer import BaseRequestHandler, TCPServer
be_bryan 0:b74591d5ab33 25
be_bryan 0:b74591d5ab33 26
be_bryan 0:b74591d5ab33 27 class TCP_EchoHandler(BaseRequestHandler):
be_bryan 0:b74591d5ab33 28 def handle(self):
be_bryan 0:b74591d5ab33 29 print "\nHandle connection from:", self.client_address
be_bryan 0:b74591d5ab33 30 while True:
be_bryan 0:b74591d5ab33 31 data = self.request.recv(1024)
be_bryan 0:b74591d5ab33 32 if not data: break
be_bryan 0:b74591d5ab33 33 self.request.sendall(data)
be_bryan 0:b74591d5ab33 34 self.request.close()
be_bryan 0:b74591d5ab33 35 print "socket closed"
be_bryan 0:b74591d5ab33 36
be_bryan 0:b74591d5ab33 37 if __name__ == '__main__':
be_bryan 0:b74591d5ab33 38 server = TCPServer((LOCALHOST, 7), TCP_EchoHandler)
be_bryan 0:b74591d5ab33 39 print "listening for connections on:", (LOCALHOST, 7)
be_bryan 0:b74591d5ab33 40 server.serve_forever()