How to use do_touch method in ATX

Best Python code snippet using ATX

serial_port.py

Source:serial_port.py Github

copy

Full Screen

...186 if board_hwid in port_hwid:187 upload_port = port188 break189 return upload_port190def check_do_touch(board_info):191 """."""192 do_touch = False193 bootloader_file = board_info.get('bootloader.file', '')194 if 'caterina' in bootloader_file.lower():195 do_touch = True196 elif board_info.get('upload.use_1200bps_touch') == 'true':197 do_touch = True198 return do_touch199def checke_do_reset(board_info):200 """."""201 return board_info.get('upload.auto_reset', '') == 'true'202def prepare_upload_port(upload_port, do_touch=False, do_reset=False):203 """."""204 if do_touch:...

Full Screen

Full Screen

arduino_uploader.py

Source:arduino_uploader.py Github

copy

Full Screen

1#!/usr/bin/env python2#-*- coding: utf-8 -*-3# 1. Copyright4# 2. Lisence5# 3. Author6"""7Documents8"""9from __future__ import absolute_import10from __future__ import print_function11from __future__ import division12from __future__ import unicode_literals13import threading14import time15from . import base16from . import arduino_compiler17from . import arduino_target_params18class Uploader(object):19 def __init__(self, path, console=None):20 self.message_queue = base.message_queue.MessageQueue(console)21 self.compiler = arduino_compiler.Compiler(path, console)22 self.error_occured = False23 self.params = {}24 self.do_touch = False25 self.wait_for_upload_port = False26 def upload(self, using_programmer=False):27 self.compiler.build()28 self.message_queue.start_print()29 upload_thread = threading.Thread(30 target=lambda: self.start_upload(using_programmer))31 upload_thread.start()32 def start_upload(self, using_programmer):33 while not self.compiler.is_finished():34 time.sleep(1)35 if not self.compiler.has_error():36 self.message_queue.put('[Stino - Start uploading...]\\n')37 self.params = self.compiler.get_params()38 self.prepare_upload_port(using_programmer)39 self.prepare_cmds(using_programmer)40 self.exec_cmds()41 if not self.error_occured:42 self.retouch_serial_port()43 self.message_queue.put('[Stino - Done uploading.]\\n')44 time.sleep(20)45 self.message_queue.stop_print()46 def prepare_upload_port(self, using_programmer):47 settings = base.settings.get_arduino_settings()48 self.upload_port = settings.get('serial_port', 'no_serial')49 self.params['serial.port'] = self.upload_port50 if self.upload_port.startswith('/dev/'):51 self.upload_port_file = self.upload_port[5:]52 else:53 self.upload_port_file = self.upload_port54 self.params['serial.port.file'] = self.upload_port_file55 if self.upload_port in base.serial_monitor.serials_in_use:56 serial_monitor = base.serial_monitor.serial_monitor_dict.get(57 self.upload_port, None)58 if serial_monitor:59 serial_monitor.stop()60 if not by_using_programmer(using_programmer, self.params):61 bootloader_file = self.params.get('bootloader.file', '')62 if 'caterina' in bootloader_file.lower():63 self.do_touch = True64 self.wait_for_upload_port = True65 elif self.params.get('upload.use_1200bps_touch') == 'true':66 self.do_touch = True67 if self.params.get('upload.wait_for_upload_port') == 'true':68 self.wait_for_upload_port = True69 if self.do_touch:70 before_ports = base.serial_port.list_serial_ports()71 if self.upload_port in before_ports:72 text = 'Forcing reset using 1200bps open/close '73 text += 'on port {0}.\\n'74 self.message_queue.put(text, self.upload_port)75 base.serial_port.touch_port(self.upload_port, 1200)76 if self.wait_for_upload_port:77 if base.sys_info.get_os_name() != 'osx':78 time.sleep(0.4)79 self.upload_port = base.serial_port.wait_for_port(80 self.upload_port, before_ports, self.message_queue)81 else:82 time.sleep(4)83 self.params['serial.port'] = self.upload_port84 if self.upload_port.startswith('/dev/'):85 self.upload_port_file = self.upload_port[5:]86 else:87 self.upload_port_file = self.upload_port88 self.params['serial.port.file'] = self.upload_port_file89 if self.params.get('upload.auto_reset', '') == 'true':90 text = 'Resetting to bootloader via DTR pulse\\n'91 self.message_queue.put(text)92 base.serial_port.auto_reset(self.upload_port)93 self.params = arduino_target_params.replace_param_values(self.params)94 def prepare_cmds(self, using_programmer):95 self.cmds = []96 if not by_using_programmer(using_programmer, self.params):97 if 'post_compile.pattern' in self.params:98 self.cmds.append(self.params.get('post_compile.pattern', ''))99 self.cmds.append(self.params.get('upload.pattern'))100 else:101 self.cmds.append(self.params.get('program.pattern', ''))102 settings = base.settings.get_arduino_settings()103 verify_code = settings.get('verify_code', False)104 if verify_code:105 self.cmds[-1] = self.cmds[-1] + ' -V'106 def exec_cmds(self):107 settings = base.settings.get_arduino_settings()108 show_upload_output = settings.get('upload_verbose', False)109 working_dir = self.compiler.get_ide_path()110 self.error_occured = arduino_compiler.exec_cmds(111 working_dir, self.cmds, self.message_queue, show_upload_output)112 def retouch_serial_port(self):113 if self.do_touch:114 if self.wait_for_upload_port:115 time.sleep(0.1)116 timeout = time.time() + 2117 while timeout > time.time():118 ports = base.serial_port.list_serial_ports()119 if self.upload_port in ports:120 base.serial_port.touch_port(self.upload_port, 9600)121 break122 time.sleep(0.25)123 else:124 base.serial_port.touch_port(self.upload_port, 9600)125def by_using_programmer(using_programmer, params):126 state = False127 upload_protocol = params.get('upload.protocol', '')128 upload_uploader = params.get('upload.uploader', '')129 if (using_programmer or upload_protocol is None) and \130 upload_uploader != 'dfu-util':131 state = True...

Full Screen

Full Screen

touch_plugin.py

Source:touch_plugin.py Github

copy

Full Screen

1from ...tools.toolbox import bash2def main(self, line):3 do_touch(line)4def do_touch(line):5 """touch a file, either creating it or modifying the modified date"""6 files = bash(line)7 for file in files:8 try:9 with open(file,'ab') as f:10 pass11 except Exception as e:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful