def __call__(self, image_bundle=None, images=None, bootargs=None, connect=True): self.target.hard_reset() with open_serial_connection(port=self.target.platform.serial_port, baudrate=self.target.platform.baudrate, timeout=self.timeout, init_dtr=0) as tty: # pylint: disable=no-member i = tty.expect( [self.mcc_prompt, AUTOSTART_MESSAGE, OLD_AUTOSTART_MESSAGE]) if i: tty.sendline('') # pylint: disable=no-member wait_for_vemsd(self.vemsd_mount, tty, self.mcc_prompt, self.short_delay) try: if image_bundle: self._deploy_image_bundle(image_bundle) if images: self._overlay_images(images) os.system('sync') except (IOError, OSError) as e: msg = 'Could not deploy images to {}; got: {}' raise TargetStableError(msg.format(self.vemsd_mount, e)) self.target.boot() if connect: self.target.connect(timeout=30)
def _get_target_ip_address(self, target): with open_serial_connection(port=self.serial_port, baudrate=self.baudrate, timeout=30, init_dtr=0) as tty: tty.sendline('su') # this is, apprently, required to query network device # info by name on recent Juno builds... self.logger.debug('Waiting for the Android shell prompt.') tty.expect(target.shell_prompt) self.logger.debug('Waiting for IP address...') wait_start_time = time.time() try: while True: tty.sendline('ip addr list eth0') time.sleep(1) try: tty.expect(r'inet ([1-9]\d*.\d+.\d+.\d+)', timeout=10) return tty.match.group(1) except pexpect.TIMEOUT: pass # We have our own timeout -- see below. if (time.time() - wait_start_time) > self.ready_timeout: raise TargetTransientError('Could not acquire IP address.') finally: tty.sendline('exit') # exit shell created by "su" call at the start
def __call__(self): with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0) as tty: self.get_through_early_boot(tty) self.perform_boot_sequence(tty) self.wait_for_android_prompt(tty)
def __call__(self): try: if self.target.is_connected: self.target.execute('sync') except TargetError: pass with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0, get_conn=True) as (_, conn): pulse_dtr(conn, state=True, duration=0.1) # TRM specifies a pulse of >=100ms
def perform_boot_sequence(self, tty): if self.uses_bootscript: return # Will boot automatically time.sleep(self.short_delay) tty.expect(self.bootmon_prompt, timeout=self.timeout) with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0) as tty: write_characters(tty, 'fl linux fdt {}'.format(self.fdt)) write_characters(tty, 'fl linux initrd {}'.format(self.initrd)) write_characters( tty, 'fl linux boot {} {}'.format(self.image, self.bootargs))
def perform_boot_sequence(self, tty): if self.uses_bootscript: return # Will boot automatically time.sleep(self.short_delay) tty.expect(self.bootmon_prompt, timeout=self.timeout) with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0) as tty: write_characters(tty, 'fl linux fdt {}'.format(self.fdt)) write_characters(tty, 'fl linux initrd {}'.format(self.initrd)) write_characters(tty, 'fl linux boot {} {}'.format(self.image, self.bootargs))
def __call__(self): try: if self.target.is_connected: self.target.execute('sync') except TargetError: pass if not os.path.exists(self.path): self.logger.debug('{} does not exisit; attempting to mount...'.format(self.path)) with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0) as tty: wait_for_vemsd(self.path, tty, self.mcc_prompt, self.short_delay) with open(self.filepath, 'w'): pass
def __call__(self): try: if self.target.is_connected: self.target.execute('sync') except TargetError: pass if not os.path.exists(self.path): self.logger.debug( '{} does not exisit; attempting to mount...'.format(self.path)) with open_serial_connection(port=self.port, baudrate=self.baudrate, timeout=self.timeout, init_dtr=0) as tty: wait_for_vemsd(self.path, tty, self.mcc_prompt, self.short_delay) with open(self.filepath, 'w'): pass
def __call__(self, image_bundle=None, images=None, bootargs=None): self.target.hard_reset() with open_serial_connection(port=self.target.platform.serial_port, baudrate=self.target.platform.baudrate, timeout=self.timeout, init_dtr=0) as tty: i = tty.expect([self.mcc_prompt, AUTOSTART_MESSAGE]) if i: tty.sendline('') wait_for_vemsd(self.vemsd_mount, tty, self.mcc_prompt, self.short_delay) try: if image_bundle: self._deploy_image_bundle(image_bundle) if images: self._overlay_images(images) os.system('sync') except (IOError, OSError), e: msg = 'Could not deploy images to {}; got: {}' raise TargetError(msg.format(self.vemsd_mount, e))
def _get_target_ip_address(self, target): with open_serial_connection(port=self.serial_port, baudrate=self.baudrate, timeout=30, init_dtr=0) as tty: tty.sendline('') self.logger.debug('Waiting for the Android shell prompt.') tty.expect(target.shell_prompt) self.logger.debug('Waiting for IP address...') wait_start_time = time.time() while True: tty.sendline('ip addr list eth0') time.sleep(1) try: tty.expect(r'inet ([1-9]\d*.\d+.\d+.\d+)', timeout=10) return tty.match.group(1) except pexpect.TIMEOUT: pass # We have our own timeout -- see below. if (time.time() - wait_start_time) > self.ready_timeout: raise TargetError('Could not acquire IP address.')
def stop(self): with open_serial_connection(timeout=self.timeout, port=self.port, baudrate=self.baud) as target: target.sendline('motor_{}_0'.format(self.fan_pin))
def start(self): with open_serial_connection(timeout=self.timeout, port=self.port, baudrate=self.baud) as target: # pylint: disable=no-member target.sendline('motor_{}_1'.format(self.fan_pin))