예제 #1
0
    def init_serial(self, serial_baud=None, serial_timeout=None):
        """ Initialize serial port.
            Function will return error is port can't be opened or initialized
        """
        # Overload serial port configuration from default to parameters' values if they are specified
        serial_baud = serial_baud if serial_baud is not None else self.serial_baud
        serial_timeout = serial_timeout if serial_timeout is not None else self.serial_timeout

        if get_module_avail('mbed_lstools') and self.options.auto_detect:
            # Ensure serial port is up-to-date (try to find it 60 times)
            found = False

            for i in range(0, 60):
                print('Looking for %s with MBEDLS' % self.options.micro)
                muts_list = get_autodetected_MUTS_list(platform_name_filter=[self.options.micro])

                if 1 in muts_list:
                    mut = muts_list[1]
                    self.port = mut['port']
                    found = True
                    break
                else:
                    sleep(3)

            if not found:
                return False

        # Clear serial port
        if self.serial:
            self.serial.close()
            self.serial = None

        # We will pool for serial to be re-mounted if it was unmounted after device reset
        result = self.pool_for_serial_init(serial_baud, serial_timeout) # Blocking

        # Port can be opened
        if result:
            self.flush()
        return result
예제 #2
0
파일: singletest.py 프로젝트: jtoews32/mbed
        exit(0)

    # Only prints matrix of supported toolchains
    if opts.supported_toolchains:
        print mcu_toolchain_matrix(platform_filter=opts.general_filter_regex)
        exit(0)

    test_spec = None
    MUTs = None

    if hasattr(opts, 'auto_detect') and opts.auto_detect:
        # If auto_detect attribute is present, we assume other auto-detection
        # parameters like 'toolchains_filter' are also set.
        print "MBEDLS: Detecting connected mbed-enabled devices... "

        MUTs = get_autodetected_MUTS_list()

        for mut in MUTs.values():
            print "MBEDLS: Detected %s, port: %s, mounted: %s" % (
                mut['mcu_unique'] if 'mcu_unique' in mut else mut['mcu'],
                mut['port'], mut['disk'])

        # Set up parameters for test specification filter function (we need to set toolchains per target here)
        use_default_toolchain = 'default' in opts.toolchains_filter.split(
            ',') if opts.toolchains_filter is not None else True
        use_supported_toolchains = 'all' in opts.toolchains_filter.split(
            ',') if opts.toolchains_filter is not None else False
        toolchain_filter = opts.toolchains_filter
        platform_name_filter = opts.general_filter_regex.split(
            ','
        ) if opts.general_filter_regex is not None else opts.general_filter_regex
예제 #3
0
파일: singletest.py 프로젝트: K4zuki/mbed
        exit(0)

    # Only prints matrix of supported toolchains
    if opts.supported_toolchains:
        print mcu_toolchain_matrix(platform_filter=opts.general_filter_regex)
        exit(0)

    test_spec = None
    MUTs = None

    if hasattr(opts, 'auto_detect') and opts.auto_detect:
        # If auto_detect attribute is present, we assume other auto-detection
        # parameters like 'toolchains_filter' are also set.
        print "MBEDLS: Detecting connected mbed-enabled devices... "

        MUTs = get_autodetected_MUTS_list()

        for mut in MUTs.values():
            print "MBEDLS: Detected %s, port: %s, mounted: %s"% (mut['mcu_unique'] if 'mcu_unique' in mut else mut['mcu'],
                                    mut['port'],
                                    mut['disk'])

        # Set up parameters for test specification filter function (we need to set toolchains per target here)
        use_default_toolchain = 'default' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else True
        use_supported_toolchains = 'all' in opts.toolchains_filter.split(',') if opts.toolchains_filter is not None else False
        toolchain_filter = opts.toolchains_filter
        platform_name_filter = opts.general_filter_regex.split(',') if opts.general_filter_regex is not None else opts.general_filter_regex
        # Test specification with information about each target and associated toolchain
        test_spec = get_autodetected_TEST_SPEC(MUTs.values(),
                                               use_default_toolchain=use_default_toolchain,
                                               use_supported_toolchains=use_supported_toolchains,
예제 #4
0
    def execute(self, capability, *args, **kwargs):
        """ Executes capability by name.
            Each capability may directly just call some command line
            program or execute building pythonic function
        """
        result = False
        if self.check_parameters(capability, *args, **kwargs) is True:
            image_path = kwargs['image_path']
            destination_disk = kwargs['destination_disk']
            target_mcu = kwargs['target_mcu']
            # Wait for mount point to be ready
            self.check_mount_point_ready(destination_disk)  # Blocking
            # Prepare correct command line parameter values
            image_base_name = basename(image_path)
            destination_path = join(destination_disk, image_base_name)
            if capability == 'smart':
                if os.name == 'posix':
                    cmd = ['cp', image_path, destination_path]
                    result = self.run_command(cmd, shell=False)

                    cmd = ['sync']
                    result = self.run_command(cmd, shell=False)
                elif os.name == 'nt':
                    cmd = ['copy', image_path, destination_path]
                    result = self.run_command(cmd, shell=True)

                # Give the OS and filesystem time to settle down
                sleep(3)

                platform_name_filter = [target_mcu]
                muts_list = {}

                remount_complete = False

                for i in range(0, 60):
                    print('Looking for %s with MBEDLS' % target_mcu)
                    muts_list = get_autodetected_MUTS_list(platform_name_filter=platform_name_filter)

                    if 1 in muts_list:
                        mut = muts_list[1]
                        destination_disk = mut['disk']
                        destination_path = join(destination_disk, image_base_name)

                        if mut['mcu'] == 'LPC1768' or mut['mcu'] == 'LPC11U24':
                            if exists(destination_disk) and exists(destination_path):
                                remount_complete = True
                                break;
                        else:
                            if exists(destination_disk) and not exists(destination_path):
                                remount_complete = True
                                break;

                    sleep(1)

                if remount_complete:
                    print('Remount complete')
                else:
                    print('Remount FAILED')

                    if exists(destination_disk):
                        print('Disk exists')
                    else:
                        print('Disk does not exist')

                    if exists(destination_path):
                        print('Image exists')
                    else:
                        print('Image does not exist')

                    result = None


        return result