forked from platformio/platformio-core
Add HWID option for the boards // Issue #632
This commit is contained in:
1 parent
7cb21dd981
commit
1872ecff16
9 files changed
+134
-76
No files matched your search
@@ -118,8 +118,8 @@ ARDUINO_VERSION = int(
|
||||
ARDUINO_USBDEFINES = []
|
||||
if "usb_product" in BOARD_BUILDOPTS:
|
||||
ARDUINO_USBDEFINES = [
|
||||
"USB_VID=${BOARD_OPTIONS['build']['vid']}",
|
||||
"USB_PID=${BOARD_OPTIONS['build']['pid']}",
|
||||
"USB_VID=${BOARD_OPTIONS['build']['hwid'][0][0]}",
|
||||
"USB_PID=${BOARD_OPTIONS['build']['hwid'][0][1]}",
|
||||
'USB_PRODUCT=\\"%s\\"' % (env.subst(
|
||||
"${BOARD_OPTIONS['build']['usb_product']}").replace('"', "")),
|
||||
'USB_MANUFACTURER=\\"%s\\"' % (env.subst(
|
||||
|
||||
@@ -84,17 +84,14 @@ def AutodetectUploadPort(env):
|
||||
break
|
||||
else:
|
||||
board_build_opts = env.get("BOARD_OPTIONS", {}).get("build", {})
|
||||
board_hwid = ("%s:%s" % (
|
||||
board_build_opts.get("vid"),
|
||||
board_build_opts.get("pid")
|
||||
)).replace("0x", "")
|
||||
|
||||
for item in get_serialports():
|
||||
if "VID:PID" not in item['hwid']:
|
||||
continue
|
||||
env.Replace(UPLOAD_PORT=item['port'])
|
||||
if board_hwid in item['hwid']:
|
||||
break
|
||||
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']
|
||||
|
||||
Reference in new issue
Block a user