#NEWLINE# def prepare_upload_port( self , using_programmer ) : #NEWLINE# #INDENT# settings = base . settings . get_arduino_settings ( ) #NEWLINE# self . upload_port = settings . get ( 'serial_port' , 'no_serial' ) #NEWLINE# self . params [ 'serial.port' ] = self . upload_port #NEWLINE# if self . upload_port . startswith ( '/dev/' ) : #NEWLINE# #INDENT# self . upload_port_file = self . upload_port [ 5 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . upload_port_file = self . upload_port #NEWLINE# #UNINDENT# self . params [ 'serial.port.file' ] = using_programmer . upload_port_file #NEWLINE# if ( self . upload_port in base . serial_monitor . serials_in_use ) : #NEWLINE# #INDENT# serial_monitor = base . serial_monitor . serial_monitor_dict . get ( self . upload_port , None ) #NEWLINE# if serial_monitor : #NEWLINE# #INDENT# serial_monitor . stop ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not by_using_programmer ( using_programmer , self . params ) ) : #NEWLINE# #INDENT# bootloader_file = self . params . get ( 'bootloader.file' , '' ) #NEWLINE# if ( 'caterina' in bootloader_file . lower ( ) ) : #NEWLINE# #INDENT# self . do_touch = True #NEWLINE# self . wait_for_upload_port = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( self . params . get ( 'upload.use_1200bps_touch' ) == 'true' ) : #NEWLINE# #INDENT# self . do_touch = True #NEWLINE# #UNINDENT# #UNINDENT# if ( self . params . get ( 'upload.wait_for_upload_port' ) == 'true' ) : #NEWLINE# #INDENT# self . wait_for_upload_port = True #NEWLINE# #UNINDENT# if self . do_touch : #NEWLINE# #INDENT# before_ports = base . serial_port . list_serial_ports ( ) #NEWLINE# if ( self . upload_port in before_ports ) : #NEWLINE# #INDENT# text = 'Forcing reset using 1200bps open/close ' #NEWLINE# text += 'on port {0}.\\n' #NEWLINE# self . message_queue . put ( text , self . upload_port ) #NEWLINE# base . serial_port . touch_port ( self . upload_port , 1200 ) #NEWLINE# #UNINDENT# if self . wait_for_upload_port : #NEWLINE# #INDENT# if ( base . sys_info . get_os_name ( ) != 'osx' ) : #NEWLINE# #INDENT# time . sleep ( 0.4 ) #NEWLINE# #UNINDENT# self . upload_port = base . serial_port . wait_for_port ( self . upload_port , before_ports , self . message_queue ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# time . sleep ( 4 ) #NEWLINE# #UNINDENT# self . params [ 'serial.port' ] = self . upload_port #NEWLINE# if self . upload_port . startswith ( '/dev/' ) : #NEWLINE# #INDENT# self . upload_port_file = self . upload_port [ 5 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . upload_port_file = self . upload_port #NEWLINE# #UNINDENT# self . params [ 'serial.port.file' ] = self . upload_port_file #NEWLINE# #UNINDENT# if ( self . params . get ( 'upload.auto_reset' , '' ) == 'true' ) : #NEWLINE# #INDENT# text = 'Resetting to bootloader via DTR pulse\\n' #NEWLINE# self . message_queue . put ( text ) #NEWLINE# base . serial_port . auto_reset ( self . upload_port ) #NEWLINE# #UNINDENT# #UNINDENT# self . params = arduino_target_params . replace_param_values ( self . params )