Ejemplo n.º 1
0
def writer():
    while 1:
        try:
            # Esperar a que se pulse una tecla.
            c = consola_io.getkey()
            # Si es la tecla de fin se termina.
            if c == EXITCHARCTER:
                break
            else:
                # Enviar tecla por el puerto serie.
                s.write(c)
        except:  # Si se ha pulsado control-c terminar.
            print "Abortando..."
            break
Ejemplo n.º 2
0
def writer():

 while 1:
 
   try:
     #-- Esperar a que se pulse una tecla
     c = consola_io.getkey()
   
     #-- Si es la tecla de fin se termina
     if c == EXITCHARCTER: 
       break                
     else:
       #-- Enviar tecla por el puerto serie
       s.write(c)
       
   except: #-- Si se ha pulsado control-c terminar
     print "Abortando..."
     break    
Ejemplo n.º 3
0
def main():

    # -- Process the arguments
    input_file, test, interactive, port = parse_arguments()

    if test:
        # -- Load the test example
        print("Test!")
        prog = [
            0x24D, 0x1FB, 0xF00, 0x24E, 0x1FB, 0xF00, 0x24F, 0x1FB, 0xF00,
            0x250, 0x1FB, 0xF00, 0x640, 0x001, 0x002, 0x004, 0x008
        ]
    else:
        # -- Load from file
        # -- Parse the input file. Format: verilog memory. Data is hexadecimal
        init_addr, prog = parse_file(input_file)

        print("File: {}".format(input_file))
        print("Size: {} words".format(len(prog)))
        print("Initial address: H'{:03X}".format(init_addr))

        if init_addr < INITIAL_ADDR:
            print("Error: Initial address below H'{:03X}".format(INITIAL_ADDR))
            sys.exit(0)

        if init_addr > INITIAL_ADDR:
            print("Warning: Initial address is NOT H'{:03X}".format(
                INITIAL_ADDR))

    # -- Try open the serial port
    try:
        ser = serial.Serial(port, baudrate=115200, timeout=0.5)
    except:
        print("Error: Serial port not found: {}".format(port))
        sys.exit(0)

    # -- Reset Simplez
    ser.setDTR(1)
    time.sleep(0.2)
    ser.setDTR(0)

    # -- Wait for the character "B" to be received. It means the bootloader
    # --  is ready
    if ser.read() == BREADY:
        print("Bootloader ready!!!!")
    else:
        print("ERROR: NO bootloader")
        sys.exit(0)

    # -- Send any character to the bootloader. It is a kind of pring
    # -- if the the bootloader detects this character, it goes to the
    # -- booloader mode. If nothing is detected, the code in the RAM
    # -- is execute
    # -- 500ms delay is a MUST! do not remove it!
    ser.write(BREADY)
    time.sleep(0.5)

    # download(ser, LEDS)
    # download(ser, SEC2)
    if sys.version_info >= (3, ):
        download(ser, prog)
    else:
        download_27(ser, prog)

    print("EXECUTING!!!")

    # -- If in interactive mode (-i option), a simple terminal is created
    if interactive:
        print("Entering the interactive mode...")
        print("Press CTRL-D to exit\n")

        consola_io.init()

        # -- Launch a thread for reading the data coming from simplez
        r = threading.Thread(target=reader, args=[ser])
        r.start()

        # -- Sending data to simplez from the keyboard
        while 1:
            try:
                # -- Wait for a key typed
                c = consola_io.getkey()

                # -- Exit char
                if c == EXITCHAR:
                    break
                else:
                    # -- Send the char to simplez
                    ser.write(c)

            except:  # -- Si se ha pulsado control-c terminar
                print("Abortando...")
                break

        global executing
        executing = 0
        r.join()

    ser.close()
Ejemplo n.º 4
0
def main():

    # -- Process the arguments
    input_file, test, interactive = parse_arguments()

    if test:
        # -- Load the test example
        print("Test!")
        prog = [0x24D, 0x1FB, 0xF00, 0x24E, 0x1FB, 0xF00, 0x24F, 0x1FB, 0xF00,
                0x250, 0x1FB, 0xF00, 0x640, 0x001, 0x002, 0x004, 0x008]
    else:
        # -- Load from file
        # -- Parse the input file. Format: verilog memory. Data is hexadecimal
        init_addr, prog = parse_file(input_file)

        print("File: {}".format(input_file))
        print("Size: {} words".format(len(prog)))
        print("Initial address: H'{:03X}".format(init_addr))

        if init_addr < INITIAL_ADDR:
            print("Error: Initial address below H'{:03X}".format(INITIAL_ADDR))
            sys.exit(0)

        if init_addr > INITIAL_ADDR:
            print("Warning: Initial address is NOT H'{:03X}".format(
                   INITIAL_ADDR))

    ser = serial.Serial('/dev/ttyUSB1', baudrate=115200, timeout=0.5)

    # -- Reset Simplez
    ser.setDTR(1)
    time.sleep(0.2)
    ser.setDTR(0)

    # -- Wait for the character "B" to be received. It means the bootloader
    # --  is ready
    if ser.read() == BREADY:
        print("Bootloader ready!!!!")
    else:
        print("ERROR: NO bootloader")
        sys.exit(0)

    # -- Send any character to the bootloader. It is a kind of pring
    # -- if the the bootloader detects this character, it goes to the
    # -- booloader mode. If nothing is detected, the code in the RAM
    # -- is execute
    # -- 500ms delay is a MUST! do not remove it!
    ser.write(BREADY)
    time.sleep(0.5)

    # download(ser, LEDS)
    # download(ser, SEC2)
    download(ser, prog)

    print("EXECUTING!!!")

    # -- If in interactive mode (-i option), a simple terminal is created
    if interactive:
        print("Entering the interactive mode...")
        print("Press CTRL-D to exit\n")

        consola_io.init()

        # -- Launch a thread for reading the data coming from simplez
        r = threading.Thread(target=reader, args=[ser])
        r.start()

        # -- Sending data to simplez from the keyboard
        while 1:
            try:
                # -- Wait for a key typed
                c = consola_io.getkey()

                # -- Exit char
                if c == EXITCHAR:
                    break
                else:
                    # -- Send the char to simplez
                    ser.write(c)

            except:  # -- Si se ha pulsado control-c terminar
                print ("Abortando...")
                break

        global executing
        executing = 0
        r.join()

    ser.close()
Ejemplo n.º 5
0
def detener(b):
    motor_traccion = Motor(R2D2, PORT_C)
    Trac[0] = 0
    motor_traccion.idle()
    print "Detener"


Direc = [0, 60]
Trac = [0, 50]
R2D2 = nxt.locator.find_one_brick()

menu()

while 1:

    c = consola_io.getkey()

    if c == 'd':
        derecha(R2D2)
    elif c == 'a':
        izquierda(R2D2)
    elif c == 'w':
        avanzar(R2D2)
    elif c == 's':
        retroceder(R2D2)
    elif c == 'n':
        retroceder(R2D2)
    elif c == ' ':
        detener(R2D2)
        menu()
    elif c == 'q':
Ejemplo n.º 6
0
def main():
        
        # creamos la ventana y le indicamos un titulo:
       
	#empieza el proyecto narrando una introduccion
	#reproducir.reproduce("1a.wav")
	#reproducir.limpiar()

	#Inicia el cuento y se espera que el usuario ingrese un numero
	reproducir.reproduce("1a.wav")

	#validacion de un numero
	t=1
	while t:
               
		 #num2 = raw_input("Escoja una opcion: 1,2,3,4 o 9 \n Su eleccion es: ")
		print("Escoja una opcion: 1,2,3,4 o 9 \n  ")
		num2=consola_io.getkey()
		print("Su eleccion es: "+num2)
		try:
			num2=int(num2)
			if(num2==9):
				main()
			elif(num2==1):
				reproducir.reproduce("2.wav")
				t2=1
				while t2:
					#num3 = raw_input("Escoja una opcion: 1,2,3,4,5 o 9 \n Su eleccion es: ")
					print("Escoja una opcion: 1,2,3,4,5 o 9 \n ")					
					num3=consola_io.getkey()
					print("Su eleccion es: "+num3)
					try:
						num3=int(num3)
						if(num3==9):
							main()
						elif(num3==1):
							reproducir.reproduce("6.wav")
							t2=0
						elif(num3==2):
							reproducir.reproduce("7.wav")
							t2=0
						elif(num3==3):		
							reproducir.reproduce("8.wav")
							t2=0
						elif(num3==4):
							reproducir.reproduce("9.wav")
							t2=0
						elif(num3==5):
							reproducir.reproduce("10.wav")
							t2=0
								
					except ValueError:
						pass
				t=0

			elif(num2==2):
				reproducir.reproduce("3.wav")
				t3=1
				while t3:
					#num4 = raw_input("Escoja una opcion: 1,2 o 9 \n Su eleccion es:  ")
					print("Escoja una opcion: 1,2 o 9 \n ")
					num4=consola_io.getkey()
					print("Su eleccion es: "+num4)
					try:
						num4=int(num4)
						if(num4==9):
							main()
						elif(num4==1):
							reproducir.reproduce("11.wav")
							t3=0
							t4=1
							while t4:
								#num5 = raw_input("Escoja una opcion: 1,2 o 9 \n Su eleccion es: ")
								print("Escoja una opcion: 1,2 o 9 \n ")
								num5=consola_io.getkey()
								print("Su eleccion es: "+num5)
								try:
									num5=int(num5)
									if(num5==9):
										main()
									elif(num5==1):
										reproducir.reproduce("12.wav")
										t4=0
									elif(num5==2):
										reproducir.reproduce("13.wav")
										t4=0
										t5=1
										while t5:
											#num6 = raw_input("Escoja una opcion: 1,2 o 9 \n Su eleccion es: ")
											print("Escoja una opcion: 1,2 o 9 \n ")
											num6=consola_io.getkey()
											print("Su eleccion es: "+num6)
											try:
												num6=int(num6)
												if(num6==9):
													main()
												elif(num6==1):
													reproducir.reproduce("14.wav")
													t5=0
												elif(num6==2):
													reproducir.reproduce("15.wav")
													t5=0
											except ValueError:
												pass


								except ValueError:
									pass




						elif(num4==2):
							reproducir.reproduce("7.wav")
							t3=0
					except ValueError:
						pass
				t=0
				
			elif(num2==3):
				reproducir.reproduce("4.wav")
				t=0
			elif(num2==4):		
				reproducir.reproduce("5.wav")
				main()
		
		except ValueError:
			pass
	print "\nY asi \ncolorin colorado \neste cuento se ha acabado"
Ejemplo n.º 7
0
    print("EXECUTING!!!")

    # -- If in interactive mode (-i option), a simple terminal is created
    if interactive:
        print("Entering the interactive mode...")
        print("Press CTRL-D to exit\n")

        # -- Launch a thread for reading the data coming from simplez
        r = threading.Thread(target=reader, args=[ser])
        r.start()

        # -- Sending data to simplez from the keyboard
        while 1:
            try:
                # -- Wait for a key typed
                c = consola_io.getkey()

                # -- Exit char
                if c == EXITCHAR:
                    break
                else:
                    # -- Send the char to simplez
                    ser.write(c)

            except:  # -- Si se ha pulsado control-c terminar
                print ("Abortando...")
                break

        executing = 0
        r.join()