示例#1
0
def enterDfuMode():
    global serialPorts
    previousSerialPorts = serialPorts
    serialPorts = list(autoSerial.find_compatible_serial_ports())
    newPorts = list(set(serialPorts) - set(previousSerialPorts))
    if len(newPorts):
        print "Found new serial port connected: {0}".format(newPorts[0])
        port = newPorts[0][0]
        name = newPorts[0][1]
        if name == "Particle Photon" or "Particle P1":
            print "Putting {0} in DFU mode".format(name)
            ser = serial.Serial(port)
            try:
                ser.baudrate = 14400  # this triggers a reboot in DFU mode
                ser.baudrate = 57600  # don't leave serial port at 14400, or a second reboot into DFU will be triggered later
                ser.close()
            except serial.serialutil.SerialException, ValueError:
                pass  # because device reboots while reconfiguring an exception is thrown, ignore
            if ser.isOpen():
                ser.close()
            ser.baudrate = 57600  # don't leave serial port at 14400, or a reboot will be triggered later
            time.sleep(1)
        else:
            print "Automatically rebooting in DFU mode is not supported for {0}".format(
                name)
示例#2
0
def enterDfuMode():
    global serialPorts
    previousSerialPorts = serialPorts
    serialPorts = list(autoSerial.find_compatible_serial_ports())
    newPorts = list(set(serialPorts) - set(previousSerialPorts))
    if len(newPorts):
        print "Found new serial port connected: {0}".format(newPorts[0])
        port = newPorts[0][0]
        name = newPorts[0][1]
        if name == "Particle Photon" or "Particle P1":
            print "Putting {0} in DFU mode".format(name)
            ser = serial.Serial(port)
            try:
                ser.baudrate = 14400 # this triggers a reboot in DFU mode
                ser.baudrate = 57600 # don't leave serial port at 14400, or a second reboot into DFU will be triggered later
                ser.close()
            except serial.serialutil.SerialException, ValueError:
                pass # because device reboots while reconfiguring an exception is thrown, ignore
            if ser.isOpen():
                ser.close()
            ser.baudrate = 57600 # don't leave serial port at 14400, or a reboot will be triggered later
            time.sleep(1)
        else:
            print "Automatically rebooting in DFU mode is not supported for {0}".format(name)
示例#3
0
                if 'socket:' in config['port']:
                    print "Socket configured as serial port, using auto detect to find USB serial"
                    config_copy['port'] = 'auto'

                raw_input("Press Enter to continue...")

                programmer = SerialProgrammer.create(config_copy, device_type)
                # open serial port
                print "Opening serial port to reset factory defaults"
                if not programmer.open_serial_with_retry(config_copy, 57600, 1):
                    print "Could not open serial port after programming"
                else:
                    programmer.fetch_version("Success! ")
                    time.sleep(5)
                    programmer.reset_settings(testMode)
                     # update serial ports here so device will not be seen as new
                    serialPorts = list(autoSerial.find_compatible_serial_ports())
        else:
            print "found DFU device, but no binary specified for flashing"
        if not multi:
            break
    else:
        if first_loop:
            print "Did not find any DFU devices."
            print "Is your Photon or Spark Core running in DFU mode (blinking yellow)?"
            print "Waiting until a DFU device is connected..."
        first_loop = False
        if autoDfu:
            enterDfuMode()
    time.sleep(1)
示例#4
0
                config = util.readCfgWithDefaults(configFile)
                config_copy = config
                if 'socket:' in config['port']:
                    print "Socket configured as serial port, using auto detect to find USB serial"
                    config_copy['port'] = 'auto'

                programmer = SerialProgrammer.create(config_copy, device_type)
                # open serial port
                print "Opening serial port to reset factory defaults"
                if not programmer.open_serial_with_retry(config_copy, 57600, 1):
                    print "Could not open serial port after programming"
                else:
                    programmer.fetch_version("Success! ")
                    time.sleep(5)
                    programmer.reset_settings(testMode)
                     # update serial ports here so device will not be seen as new
                    serialPorts = list(autoSerial.find_compatible_serial_ports())
        else:
            print "found DFU device, but no binary specified for flashing"
        if not multi:
            break
    else:
        if first_loop:
            print "Did not find any DFU devices."
            print "Is your Photon or Spark Core running in DFU mode (blinking yellow)?"
            print "Waiting until a DFU device is connected..."
        first_loop = False
        if autoDfu:
            enterDfuMode()
    time.sleep(1)
示例#5
0
            if not noReset:
                print "Now resetting EEPROM to defaults"
                # reset EEPROM to defaults
                configFile = util.scriptPath() + '/settings/config.cfg'
                config = util.readCfgWithDefaults(configFile)
                programmer = SerialProgrammer.create(config, type)

                # open serial port
                print "Opening serial port"
                if not programmer.open_serial_with_retry(config, 57600, 1):
                    print "Could not open serial port after programming"
                else:
                    programmer.fetch_version("Success! ")
                    time.sleep(5)
                    programmer.reset_settings(testMode)
                    serialPorts = list(autoSerial.find_compatible_serial_ports()) # update serial ports here so device will not be seen as new

        else:
            print "found DFU device, but no binary specified for flashing"
        if not multi:
            break
    else:
        if firstLoop:
            print "Did not find any DFU devices."
            print "Is your Photon or Spark Core running in DFU mode (blinking yellow)?"
            print "Waiting until a DFU device is connected..."
        firstLoop = False
        if autoDfu:
            previousSerialPorts = serialPorts
            serialPorts = list(autoSerial.find_compatible_serial_ports())
            newPorts = list(set(serialPorts) - set(previousSerialPorts))
示例#6
0
                    config_copy['port'] = 'auto'

                raw_input("Press Enter to continue...")

                programmer = SerialProgrammer.create(config_copy, device_type)
                # open serial port
                print "Opening serial port to reset factory defaults"
                if not programmer.open_serial_with_retry(
                        config_copy, 57600, 1):
                    print "Could not open serial port after programming"
                else:
                    programmer.fetch_version("Success! ")
                    time.sleep(5)
                    programmer.reset_settings(testMode)
                    # update serial ports here so device will not be seen as new
                    serialPorts = list(
                        autoSerial.find_compatible_serial_ports())
        else:
            print "found DFU device, but no binary specified for flashing"
        if not multi:
            break
    else:
        if first_loop:
            print "Did not find any DFU devices."
            print "Is your Photon or Spark Core running in DFU mode (blinking yellow)?"
            print "Waiting until a DFU device is connected..."
        first_loop = False
        if autoDfu:
            enterDfuMode()
    time.sleep(1)