fix: support Leonardo, Yun and derivatives upload with IDE 1.5.x

Esse commit está contido em:
Victor Nakoryakov
2014-04-15 17:40:31 +04:00
commit 0db2b4b60c
+10 -6
Ver Arquivo
@@ -83,8 +83,12 @@ class Upload(Command):
# this wait a moment for the bootloader to enumerate. On Windows, also must # this wait a moment for the bootloader to enumerate. On Windows, also must
# deal with the fact that the COM port number changes from bootloader to # deal with the fact that the COM port number changes from bootloader to
# sketch. # sketch.
if board['bootloader']['path'] == "caterina": touch_port = \
caterina_port = None board['upload'].get('use_1200bps_touch') == 'true' or \
board['upload']['protocol'] == 'avr109'
if touch_port:
new_port = None
before = self.e.list_serial_ports() before = self.e.list_serial_ports()
if port in before: if port in before:
ser = Serial() ser = Serial()
@@ -106,20 +110,20 @@ class Upload(Command):
now = self.e.list_serial_ports() now = self.e.list_serial_ports()
diff = list(set(now) - set(before)) diff = list(set(now) - set(before))
if diff: if diff:
caterina_port = diff[0] new_port = diff[0]
break break
before = now before = now
sleep(enum_delay) sleep(enum_delay)
elapsed += enum_delay elapsed += enum_delay
if caterina_port == None: if not new_port:
raise Abort("Couldnt find a Leonardo on the selected port. " raise Abort("Couldnt find a board on the selected port. "
"Check that you have the correct port selected. " "Check that you have the correct port selected. "
"If it is correct, try pressing the board's reset " "If it is correct, try pressing the board's reset "
"button after initiating the upload.") "button after initiating the upload.")
port = caterina_port port = new_port
# call avrdude to upload .hex # call avrdude to upload .hex
subprocess.call([ subprocess.call([