コード例 #1
0
    #Initialise the cflib
    cload = Cloader(link, clink)

    #########################################
    # Get the connection with the bootloader
    #########################################
    #The connection is done by reseting to the bootloader (default)
    if boot == "reset":
        sys.stdout.write("Reset to bootloader mode ...")
        sys.stdout.flush()
        if cload.reset_to_bootloader(cload.decode_cpu_id(cpu_id)):
            print " Done."
        else:
            print "\nFailed!\nThe loader with the ID",
            print cpu_id, "does not answer."
            cload.close()
            sys.exit(-1)
    else:  # The connection is done by a cold boot ...
        print "Restart the CrazyFlie you want to bootload in the next",
        print " 10 seconds ..."

        if cload.coldboot():
            print "Connection established!"
        else:
            print "Cannot connect the bootloader!"
            cload.close()
            sys.exit(-1)

    ######################################
    # Doing something (hopefully) usefull
    ######################################