def _get_ip_addr():
     """ Wait until open node is booted and get its ip address"""
     with SerialExpectForSocket(logger=LOGGER) as a8_expect:
         a8_expect.send('root')
         a8_expect.expect('# ')
         a8_expect.send(IP_CMD)
         ip_addr = a8_expect.expect(r'\d+\.\d+\.\d+.\d+', timeout=10)
         a8_expect.send('exit')
         if not ip_addr:  # pragma: no cover
             raise A8ConnectionError("Invalid Ip address", ip_addr)
     return ip_addr
Beispiel #2
0
    def wait_booted(self, timeout):
        """ Monitor RPi3 tty to check if node booted """
        t_start = time.time()
        try:
            LOGGER.debug("Time before boot %s", datetime.datetime.now())
            self._rpi3_expect = SerialExpectForSocket(logger=LOGGER)
            match = self._rpi3_expect.expect(' login: '******'wait_tty' and serial creation (fast start/stop)
            match = ''
        finally:
            delta_t = time.time() - t_start
            self._debug_boot_stop()

        if match != '':
            LOGGER.info("Boot RPi3 succeeded in time: %ds", delta_t)
        else:
            LOGGER.error("Boot RPi3 failed in time: %ds", delta_t)
        return match
Beispiel #3
0
    def wait_booted(self, timeout):
        """ Monitor A8 tty to check if node booted """
        try:
            t_start = time.time()
            LOGGER.debug("Time before boot %s", datetime.datetime.now())
            self._a8_expect = SerialExpectForSocket(logger=LOGGER)
            match = self._a8_expect.expect(' login: '******'wait_tty' and serial creation (fast start/stop)
            match = ''
        finally:
            delta_t = time.time() - t_start
            self._debug_boot_stop()

        if match != '':
            LOGGER.info("Boot A8 succeeded in time: %ds", delta_t)
        else:
            LOGGER.error("Boot A8 failed in time: %ds", delta_t)
        return match
Beispiel #4
0
class NodeRpi3(OpenNodeBase):
    """ Open node RPi3 implementation """

    TYPE = 'rpi3'
    TTY = '/dev/iotlab/ttyON_RPI3'
    BAUDRATE = 115200
    ALIM = '5V'

    # 15 secs was not always enough
    RPI3_TTY_DETECT_TIME = 20

    def __init__(self):
        self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE)
        self._rpi3_expect = None

    @property
    def programmer(self):
        """There's no programmer for RPI3 node."""
        return None

    @logger_call("Node RPi3 : setup of rpi3 node")
    def setup(self, _firmware, debug=True):  # pylint: disable=arguments-differ
        """ Wait that open nodes tty appears and start RPi3 boot log """
        ret_val = 0
        common.wait_no_tty(self.TTY)
        ret_val += common.wait_tty(self.TTY, LOGGER, self.RPI3_TTY_DETECT_TIME)
        ret_val += self.serial_redirection.start()

        if ret_val == 0 and debug:
            # Timeout 15 minutes for boot (we saw 10minutes boot already)
            self._debug_boot_start(15 * 60)
        return ret_val

    @logger_call("Node RPi3 : teardown of rpi3 node")
    def teardown(self):
        """ Stop RPi3 boot log """
        ret_val = 0
        ret_val += self.serial_redirection.stop()
        ret_val += self._debug_boot_stop()
        return ret_val

    @classmethod
    def verify(cls):
        # Linux open node = no autotest and firmware target verification
        return 0

    def _debug_boot_start(self, timeout):
        """ RPi3 boot debug thread start """
        thr = Thread(target=self.wait_booted, args=(timeout, ))
        thr.daemon = True
        thr.start()

    def wait_booted(self, timeout):
        """ Monitor RPi3 tty to check if node booted """
        t_start = time.time()
        try:
            LOGGER.debug("Time before boot %s", datetime.datetime.now())
            self._rpi3_expect = SerialExpectForSocket(logger=LOGGER)
            match = self._rpi3_expect.expect(' login: '******'wait_tty' and serial creation (fast start/stop)
            match = ''
        finally:
            delta_t = time.time() - t_start
            self._debug_boot_stop()

        if match != '':
            LOGGER.info("Boot RPi3 succeeded in time: %ds", delta_t)
        else:
            LOGGER.error("Boot RPi3 failed in time: %ds", delta_t)
        return match

    def _debug_boot_stop(self):
        """ Stop the debug thread """
        try:
            self._rpi3_expect.close()
        except AttributeError:  # pragma: no cover
            pass
        return 0

    def status(self):
        """ Check RPi3 node status """
        # No check done for the moment
        return 0
Beispiel #5
0
class NodeA8(object):
    """ Open node A8 implementation """

    TYPE = 'a8'
    ELF_TARGET = ('ELFCLASS32', 'EM_ARM')
    TTY = '/dev/ttyON_A8'
    BAUDRATE = 115200
    LOCAL_A8_M3_TTY = '/tmp/local_ttyA8_M3'
    A8_M3_TTY = '/dev/ttyA8_M3'
    A8_M3_BAUDRATE = 500000
    A8_M3_FW_AUTOTEST = static_path('a8_autotest.elf')
    ALIM = '5V'

    # 15 secs was not always enough
    A8_TTY_DETECT_TIME = 20

    AUTOTEST_AVAILABLE = [
        'echo', 'get_time',  # mandatory
        'get_uid',
        'get_accelero', 'get_gyro', 'get_magneto',
        'test_gpio', 'test_i2c',
        'radio_pkt', 'radio_ping_pong',
        'test_pps_start', 'test_pps_get', 'test_pps_stop',
        'leds_on', 'leds_off', 'leds_blink',
    ]

    def __init__(self):
        self.serial_redirection = SerialRedirection(self.TTY, self.BAUDRATE)
        self._a8_expect = None

    @logger_call("Node A8 : setup of a8 node")
    def setup(self, _firmware, debug=True):  # pylint: disable=unused-argument
        """ Wait that open nodes tty appears and start A8 boot log """
        ret_val = 0
        common.wait_no_tty(self.TTY)
        ret_val += common.wait_tty(self.TTY, LOGGER, self.A8_TTY_DETECT_TIME)
        ret_val += self.serial_redirection.start()

        if ret_val == 0 and debug:
            # Timeout 15 minutes for boot (we saw 10minutes boot already)
            self._debug_boot_start(15 * 60)
        return ret_val

    @logger_call("Node A8 : teardown of a8 node")
    def teardown(self):
        """ Stop A8 boot log """
        ret_val = 0
        ret_val += self.serial_redirection.stop()
        ret_val += self._debug_boot_stop()
        return ret_val

    def _debug_boot_start(self, timeout):
        """ A8 boot debug thread start """
        thr = Thread(target=self.wait_booted, args=(timeout,))
        thr.daemon = True
        thr.start()

    def wait_booted(self, timeout):
        """ Monitor A8 tty to check if node booted """
        try:
            t_start = time.time()
            LOGGER.debug("Time before boot %s", datetime.datetime.now())
            self._a8_expect = SerialExpectForSocket(logger=LOGGER)
            match = self._a8_expect.expect(' login: '******'wait_tty' and serial creation (fast start/stop)
            match = ''
        finally:
            delta_t = time.time() - t_start
            self._debug_boot_stop()

        if match != '':
            LOGGER.info("Boot A8 succeeded in time: %ds", delta_t)
        else:
            LOGGER.error("Boot A8 failed in time: %ds", delta_t)
        return match

    def _debug_boot_stop(self):
        """ Stop the debug thread """
        try:
            self._a8_expect.close()
        except AttributeError:  # pragma: no cover
            pass
        return 0

    @staticmethod
    def status():
        """ Check A8 node status """
        # No check done for the moment
        return 0