Ejemplo n.º 1
0
def chat_client(host='192.168.1.2', port=9009):
    if (host == None or port == None):
        if (len(sys.argv) < 3):
            print('Usage: python chat_client.py hostname port')
            sys.exit()
        host = sys.argv[1]
        port = int(sys.argv[2])

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(2)

    # connect to remote host
    try:
        s.connect((host, port))
    except:
        print('Unable to connect')
        sys.exit()

    print('Connected to remote host. You can start sending messages')
    print('[Me] ')
    sys.stdout.flush()

    while True:
        socket_list = [sys.stdin, s]

        # Get the list sockets which are readable
        ready_to_read, ready_to_write, in_error = select.select(
            socket_list, [], [])

        for sock in ready_to_read:
            if sock == s:
                # incoming message from remote server, s

                data = sock.recv(4096)
                if not data:
                    print('\nDisconnected from chat server')
                    sys.exit()
                else:
                    #print data
                    #print('\033[2J')
                    print '\033[2J',
                    print data
                    print '[Me] ',

            else:
                # user entered a message
                msg = print_data()
                s.send(msg)
                print '\r\033[A\033[K',
                print msg + '\n[Me]',
Ejemplo n.º 2
0
    def init(self):
    
        body = bodyclass()

        leg = [legclass() for i in xrange(4)]
    
        leg[0].setpins(29, 30, 31)
        leg[1].setpins(16, 17, 18)
        leg[2].setpins(0, 1, 2)
        leg[3].setpins(13, 14, 15)
    
        leg[0].setcenters(1433, 1500, 1500)
        leg[1].setcenters(1550, 1360, 1450)
        leg[2].setcenters(1557, 1550, 1560)
        leg[3].setcenters(1534, 1523, 1509)
    
        leg[0].setdirections(-1, -1, 1)
        leg[1].setdirections(1, 1, -1)
        leg[2].setdirections(1, -1, 1)
        leg[3].setdirections(-1, 1, -1)
    
        leg[0].setlimits(-40.0, 90.0, -60.0, 45.0, -45.0, 45.0)
        leg[1].setlimits(-40.0, 90.0, -60.0, 45.0, -45.0, 45.0)
        leg[2].setlimits(-90.0, 40.0, -60.0, 45.0, -45.0, 45.0)
        leg[3].setlimits(-90.0, 40.0, -60.0, 45.0, -45.0, 45.0)
    
        leg[0].setoffsets(63.5, 63.5, 0.0)
        leg[1].setoffsets(63.5, 63.5, 0.0)
        leg[2].setoffsets(63.5, 63.5, 0.0)
        leg[3].setoffsets(63.5, 63.5, 0.0)

        leg[0].setfootneutral(-110.0, 110.0, -70.0)
        leg[1].setfootneutral(110.0, 110.0, -70.0)
        leg[2].setfootneutral(110.0, -110.0, -70.0)
        leg[3].setfootneutral(-110.0, -110.0, -70.0)

        leg[0].setfootposition(-110.0, 110.0, -70.0)
        leg[1].setfootposition(110.0, 110.0, -70.0)
        leg[2].setfootposition(110.0, -110.0, -70.0)
        leg[3].setfootposition(-110.0, -110.0, -70.0)
    
        leg[0].setquadrant(2)
        leg[1].setquadrant(1)
        leg[2].setquadrant(4)
        leg[3].setquadrant(3)
    
        turret = turretclass()
    
        turret.setpins(23, 24)
        turret.setcenters(1600, 1500)
        turret.setdirections(1, 1)
        turret.setlimits(-45.0, 45.0, -15.0, 35.0)
    
        gun = gunclass()
        gun.pin = 4
    
        #serial = serialclass('COM3',9600) 
        #serial = serialclass('/dev/tty.usbserial-A6007wbX', 9600) # Xbee
        serial = serialclass('/dev/tty.usbserial-A800csbR', 115200) # XbeePro
        serial.connect()
    
        gait = gaitclass()

        camera = cameraclass('192.168.1.101', 'admin', 'admin')
    
        controls = controlsclass()
    
        controlconditions = controlconditionsclass()
    
        return serial, leg, body, turret, gun, gait, camera, controls, controlconditions
Ejemplo n.º 3
0
 def __init__(self, port_a, port_b):
   self.yasnac = serial.connect(port= port_a, baudrate=4800,parity=serial.PARITY_EVEN,timeout=0)
   self.floppy = serial.connect(port= port_b, baudrate=4800,parity=serial.PARITY_EVEN,timeout=0)
   sleep(2)