def AutodetectUploadPort(env): if "UPLOAD_PORT" in env: return if env.subst("$FRAMEWORK") == "mbed": msdlabels = ("mbed", "nucleo", "frdm") for item in get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue env.Replace(UPLOAD_PORT=item['disk']) break else: board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {}) for item in get_serialports(): if "VID:PID" not in item['hwid']: continue env.Replace(UPLOAD_PORT=item['port']) for hwid in board_build_opts.get("hwid", []): board_hwid = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") if board_hwid in item['hwid']: break if "UPLOAD_PORT" in env: print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT'] else: env.Exit("Error: Please specify `upload_port` for environment or use " "global `--upload-port` option.\n" "For some development platforms this can be a USB flash " "drive (i.e. /media/<user>/<device name>)\n")
def AutodetectUploadPort(env): if "UPLOAD_PORT" in env: return if env.subst("$FRAMEWORK") == "mbed": msdlabels = ("mbed", "nucleo", "frdm") for item in get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue print "Auto-detected UPLOAD_PORT/DISK: %s" % item['disk'] env.Replace(UPLOAD_PORT=item['disk']) break else: for item in get_serialports(): if "VID:PID" not in item['hwid']: continue print "Auto-detected UPLOAD_PORT: %s" % item['port'] env.Replace(UPLOAD_PORT=item['port']) break if "UPLOAD_PORT" not in env: Exit("Error: Please specify `upload_port` for environment or use " "global `--upload-port` option.\n" "For the some development platforms it can be USB flash drive\n")
def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm") for item in util.get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue return item['disk'] return None
def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): if not _is_match_pattern(item['disk']): continue if (item['name'] and any([l in item['name'].lower() for l in msdlabels])): return item['disk'] if isfile(join(item['disk'], "mbed.html")): return item['disk'] return None
def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): if item['disk'].startswith( "/net") or not _is_match_pattern(item['disk']): continue mbed_pages = [ join(item['disk'], n) for n in ("mbed.htm", "mbed.html") ] if any([isfile(p) for p in mbed_pages]): return item['disk'] if (item['name'] and any([l in item['name'].lower() for l in msdlabels])): return item['disk'] return None
def _look_for_mbed_disk(): msdlabels = ("mbed", "nucleo", "frdm", "microbit") for item in util.get_logicaldisks(): if item['disk'].startswith("/net") or not _is_match_pattern( item['disk']): continue mbed_pages = [ join(item['disk'], n) for n in ("mbed.htm", "mbed.html") ] if any([isfile(p) for p in mbed_pages]): return item['disk'] if (item['name'] and any([l in item['name'].lower() for l in msdlabels])): return item['disk'] return None
def AutodetectUploadPort(env): if "UPLOAD_PORT" in env: return if env.subst("$FRAMEWORK") == "mbed": msdlabels = ("mbed", "nucleo", "frdm") for item in get_logicaldisks(): if (not item['name'] or not any([l in item['name'].lower() for l in msdlabels])): continue env.Replace(UPLOAD_PORT=item['disk']) break else: if (system() == "Linux" and not isfile("/etc/udev/99-platformio-udev.rules")): print( "\nWarning! Please install `99-platformio-udev.rules` and " "check that your board's PID and VID are listed in the rules." "\n https://raw.githubusercontent.com/platformio/platformio" "/develop/scripts/99-platformio-udev.rules\n") board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {}) for item in get_serialports(): if "VID:PID" not in item['hwid']: continue env.Replace(UPLOAD_PORT=item['port']) for hwid in board_build_opts.get("hwid", []): board_hwid = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "") if board_hwid in item['hwid']: break if "UPLOAD_PORT" in env: print "Auto-detected UPLOAD_PORT/DISK: %s" % env['UPLOAD_PORT'] else: env.Exit("Error: Please specify `upload_port` for environment or use " "global `--upload-port` option.\n" "For some development platforms this can be a USB flash " "drive (i.e. /media/<user>/<device name>)\n")