mbed_lstools.lstools_base.MbedLsToolsBase Class Reference
Inheritance diagram for mbed_lstools.lstools_base.MbedLsToolsBase:

## Public Member Functions

| __init__ (self, list_unmounted=False, **kwargs)
| find_candidates (self)
| list_mbeds_ext (self)
| Function adds extra information for each mbed device.
| list_mbeds (self, fs_interaction=FSInteraction.BeforeFilter, filter_function=None, unique_names=False, read_details_txt=False)
| mock_manufacture_id (self, mid, platform_name, oper='+')
| Replace (or add if manufacture id doesn't exist) entry in self.manufacture_ids.
| list_manufacture_ids (self)
| Creates list of all available mappings for target_id -> Platform.
| retarget_read (self)
| Load retarget data from local file.
| retarget (self)
| Enable retargeting.
| get_dummy_platform (self, platform_name)
| Returns simple dummy platform.
| get_supported_platforms (self, device_type=None)
| Return a dictionary of supported target ids and the corresponding platform name.
| list_platforms (self)
| Useful if you just want to know which platforms are currently available on the system.
| list_platforms_ext (self)
| Useful if you just want to know how many platforms of each type are currently available on the system.
| list_mbeds_by_targetid (self)
| Get information about mbeds with extended parameters/info included.
| __str__ (self)
| Object to string casting.
| get_string (self, border=False, header=True, padding_width=1, sortby='platform_name')
| Printing with some sql table like decorators.
| get_json_data_from_file (self, json_spec_filename, verbose=False)
| Loads from file JSON formatted string to data structure.
| get_htm_target_id (self, mount_point)
| get_mbed_htm (self, mount_point)
| get_mbed_htm_comment_section_ver_build (self, line)
| get_mbed_htm_lines (self, mount_point)
| get_details_txt (self, mount_point)
| parse_details_txt (self, lines)
| scan_html_line_for_target_id (self, line)
| mount_point_ready (self, path)
| Check if a mount point is ready for file operations.

## Static Public Member Functions

| run_cli_process (cmd, shell=True)

## Public Attributes

| retarget_data
| MOCK_FILE_NAME
| plat_db
| list_unmounted
| RETARGET_FILE_NAME
| dummy_counter

## Static Public Attributes

list | os_supported = []
| HOME_DIR = expanduser("~")
str | MOCK_FILE_NAME = '.mbedls-mock'
str | RETARGET_FILE_NAME = 'mbedls.json'
str | DETAILS_TXT_NAME = 'DETAILS.TXT'
str | MBED_HTM_NAME = 'mbed.htm'
dict | VENDOR_ID_DEVICE_TYPE_MAP

## Protected Member Functions

| _fs_never (self, device, filter_function, read_details_txt)
| _fs_before_id_check (self, device, filter_function, read_details_txt)
| _fs_after_id_check (self, device, filter_function, read_details_txt)
| _update_device_from_fs (self, device, read_details_txt)
| _detect_device_type (self, device)
| _update_device_details_daplink_compatible (self, device, read_details_txt)
| _update_device_details_jlink (self, device, _)
| _update_device_from_htm (self, device)
| _update_device_details_atmel (self, device, _)
| _read_htm_ids (self, mount_point)
| Function scans mbed.htm to get information about TargetID.
| _mbed_htm_comment_section_ver_build (self, line)
| Check for Version and Build date of interface chip firmware im mbed.htm file.
| _htm_lines (self, mount_point)
| _details_txt (self, mount_point)
| Load DETAILS.TXT to dictionary: DETAILS.TXT example: Version: 0226 Build: Aug 24 2015 17:06:30 Git Commit SHA: 27a236b9fe39c674a703c5c89655fbd26b8e27e1 Git Local mods: Yes.
| _parse_details (self, lines)
| _target_id_from_htm (self, line)
| Extract Target id from htm line.

## Static Protected Member Functions

| _run_cli_process (cmd, shell=True)
| Runs command as a process and return stdout, stderr and ret code.

## Protected Attributes

| _fs_before_id_check
| _fs_after_id_check

## Detailed Description

     Base class for mbed-lstools, defines mbed-ls tools interface for
    mbed-enabled devices detection for various hosts

Definition at line 54 of file lstools_base.py.

## Constructor & Destructor Documentation

## __init__()

mbed_lstools.lstools_base.MbedLsToolsBase.__init__ | ( |  | self,
|  |  | list_unmounted = `False`,
|  | ** | kwargs
| ) |  |

     ctor

Reimplemented in mbed_lstools.linux.MbedLsToolsLinuxGeneric.

Definition at line 79 of file lstools_base.py.

## Member Function Documentation

## __str__()

mbed_lstools.lstools_base.MbedLsToolsBase.__str__ | ( |  | self | ) |

Object to string casting.

Returns
  Stringified class object should be prettytable formated string

Definition at line 489 of file lstools_base.py.

## _details_txt()

mbed_lstools.lstools_base.MbedLsToolsBase._details_txt | ( |  | self,
|  |  | mount_point
| ) |  |

protected

Load DETAILS.TXT to dictionary: DETAILS.TXT example: Version: 0226 Build: Aug 24 2015 17:06:30 Git Commit SHA: 27a236b9fe39c674a703c5c89655fbd26b8e27e1 Git Local mods: Yes.

or:

# DAPLink Firmware - see https://mbed.com/daplink

Unique ID: 0240000029164e45002f0012706e0006f301000097969900 HIF ID: 97969900 Auto Reset: 0 Automation allowed: 0 Daplink Mode: Interface Interface Version: 0240 Git SHA: c765cbb590f57598756683254ca38b211693ae5e Local Mods: 0 USB Interfaces: MSD, CDC, HID Interface CRC: 0x26764ebf

Definition at line 620 of file lstools_base.py.

## _detect_device_type()

mbed_lstools.lstools_base.MbedLsToolsBase._detect_device_type | ( |  | self,
|  |  | device
| ) |  |

protected

     Returns a string of the device type
        @param device Dictionary containing device information
        @return Device type located in VENDOR_ID_DEVICE_TYPE_MAP or None if unknown

Definition at line 244 of file lstools_base.py.

## _fs_after_id_check()

mbed_lstools.lstools_base.MbedLsToolsBase._fs_after_id_check | ( |  | self,
|  |  | device,
|  |  | filter_function,
|  |  | read_details_txt
| ) |  |

protected

    Filter device before touching the file system of the device.
    Said another way: Touch the file system after filtering

Definition at line 201 of file lstools_base.py.

## _fs_before_id_check()

mbed_lstools.lstools_base.MbedLsToolsBase._fs_before_id_check | ( |  | self,
|  |  | device,
|  |  | filter_function,
|  |  | read_details_txt
| ) |  |

protected

    Filter device after touching the file system of the device.
    Said another way: Touch the file system before filtering

Definition at line 189 of file lstools_base.py.

## _fs_never()

mbed_lstools.lstools_base.MbedLsToolsBase._fs_never | ( |  | self,
|  |  | device,
|  |  | filter_function,
|  |  | read_details_txt
| ) |  |

protected

    Filter device without touching the file system of the device

Definition at line 180 of file lstools_base.py.

## _htm_lines()

mbed_lstools.lstools_base.MbedLsToolsBase._htm_lines | ( |  | self,
|  |  | mount_point
| ) |  |

protected

Definition at line 609 of file lstools_base.py.

## _mbed_htm_comment_section_ver_build()

mbed_lstools.lstools_base.MbedLsToolsBase._mbed_htm_comment_section_ver_build | ( |  | self,
|  |  | line
| ) |  |

protected

Check for Version and Build date of interface chip firmware im mbed.htm file.

Returns
  (version, build) tuple if successful, None if no info found

Definition at line 581 of file lstools_base.py.

## _parse_details()

mbed_lstools.lstools_base.MbedLsToolsBase._parse_details | ( |  | self,
|  |  | lines
| ) |  |

protected

Definition at line 654 of file lstools_base.py.

## _read_htm_ids()

mbed_lstools.lstools_base.MbedLsToolsBase._read_htm_ids | ( |  | self,
|  |  | mount_point
| ) |  |

protected

Function scans mbed.htm to get information about TargetID.

Parameters

  mount_point | mbed mount point (disk / drive letter)

Returns
  Function returns targetID, in case of failure returns None.

Note: This function should be improved to scan variety of boards' mbed.htm files

Definition at line 557 of file lstools_base.py.

## _run_cli_process()

mbed_lstools.lstools_base.MbedLsToolsBase._run_cli_process | ( |  | cmd,
|  |  | shell = `True`
| ) |  |

static protected

Runs command as a process and return stdout, stderr and ret code.

Parameters

  cmd | Command to execute

Returns
  Tuple of (stdout, stderr, returncode)

Definition at line 701 of file lstools_base.py.

## _target_id_from_htm()

mbed_lstools.lstools_base.MbedLsToolsBase._target_id_from_htm | ( |  | self,
|  |  | line
| ) |  |

protected

Extract Target id from htm line.

Returns
  Target id or None

Definition at line 670 of file lstools_base.py.

## _update_device_details_atmel()

mbed_lstools.lstools_base.MbedLsToolsBase._update_device_details_atmel | ( |  | self,
|  |  | device,
|  |  | _
| ) |  |

protected

     Updates the Atmel device information based on files from its 'mount_point'
        @param device Dictionary containing device information
        @param read_details_txt A boolean controlling the presense of the
          output dict attributes read from other files present on the 'mount_point'

Definition at line 339 of file lstools_base.py.

## _update_device_details_daplink_compatible()

mbed_lstools.lstools_base.MbedLsToolsBase._update_device_details_daplink_compatible | ( |  | self,
|  |  | device,
|  |  | read_details_txt
| ) |  |

protected

     Updates the daplink-specific device information based on files from its 'mount_point'
        @param device Dictionary containing device information
        @param read_details_txt A boolean controlling the presense of the
          output dict attributes read from other files present on the 'mount_point'

Definition at line 253 of file lstools_base.py.

## _update_device_details_jlink()

mbed_lstools.lstools_base.MbedLsToolsBase._update_device_details_jlink | ( |  | self,
|  |  | device,
|  |  | _
| ) |  |

protected

     Updates the jlink-specific device information based on files from its 'mount_point'
        @param device Dictionary containing device information

Definition at line 288 of file lstools_base.py.

## _update_device_from_fs()

mbed_lstools.lstools_base.MbedLsToolsBase._update_device_from_fs | ( |  | self,
|  |  | device,
|  |  | read_details_txt
| ) |  |

protected

     Updates the device information based on files from its 'mount_point'
        @param device Dictionary containing device information
        @param read_details_txt A boolean controlling the presense of the
          output dict attributes read from other files present on the 'mount_point'

Definition at line 213 of file lstools_base.py.

## _update_device_from_htm()

mbed_lstools.lstools_base.MbedLsToolsBase._update_device_from_htm | ( |  | self,
|  |  | device
| ) |  |

protected

    Set the 'target_id', 'target_id_mbed_htm', 'platform_name' and
    'daplink_*' attributes by reading from mbed.htm on the device

Definition at line 320 of file lstools_base.py.

## find_candidates()

mbed_lstools.lstools_base.MbedLsToolsBase.find_candidates | ( |  | self | ) |

    Find all candidate devices connected to this computer

    Note: Should not open any files

    @return A dict with the keys 'mount_point', 'serial_port' and 'target_id_usb_id'

Reimplemented in mbed_lstools.linux.MbedLsToolsLinuxGeneric.

Definition at line 98 of file lstools_base.py.

## get_details_txt()

mbed_lstools.lstools_base.MbedLsToolsBase.get_details_txt | ( |  | self,
|  |  | mount_point
| ) |  |

Definition at line 617 of file lstools_base.py.

## get_dummy_platform()

mbed_lstools.lstools_base.MbedLsToolsBase.get_dummy_platform | ( |  | self,
|  |  | platform_name
| ) |  |

Returns simple dummy platform.

Definition at line 412 of file lstools_base.py.

## get_htm_target_id()

mbed_lstools.lstools_base.MbedLsToolsBase.get_htm_target_id | ( |  | self,
|  |  | mount_point
| ) |  |

Definition at line 547 of file lstools_base.py.

## get_json_data_from_file()

mbed_lstools.lstools_base.MbedLsToolsBase.get_json_data_from_file | ( |  | self,
|  |  | json_spec_filename,
|  |  | verbose = `False`
| ) |  |

Loads from file JSON formatted string to data structure.

Returns
  None if JSON can be loaded

Definition at line 530 of file lstools_base.py.

## get_mbed_htm()

mbed_lstools.lstools_base.MbedLsToolsBase.get_mbed_htm | ( |  | self,
|  |  | mount_point
| ) |  |

Definition at line 553 of file lstools_base.py.

## get_mbed_htm_comment_section_ver_build()

mbed_lstools.lstools_base.MbedLsToolsBase.get_mbed_htm_comment_section_ver_build | ( |  | self,
|  |  | line
| ) |  |

Definition at line 578 of file lstools_base.py.

## get_mbed_htm_lines()

mbed_lstools.lstools_base.MbedLsToolsBase.get_mbed_htm_lines | ( |  | self,
|  |  | mount_point
| ) |  |

Definition at line 606 of file lstools_base.py.

## get_string()

mbed_lstools.lstools_base.MbedLsToolsBase.get_string | ( |  | self,
|  |  | border = `False`,
|  |  | header = `True`,
|  |  | padding_width = `1`,
|  |  | sortby = `'platform_name'`
| ) |  |

Printing with some sql table like decorators.

Parameters

  border | Table border visibility
  header | Table header visibility
  padding_width | Table padding
  sortby | Column used to sort results

Returns
  Returns string which can be printed on console

Definition at line 498 of file lstools_base.py.

## get_supported_platforms()

mbed_lstools.lstools_base.MbedLsToolsBase.get_supported_platforms | ( |  | self,
|  |  | device_type = `None`
| ) |  |

Return a dictionary of supported target ids and the corresponding platform name.

Parameters

  device_type | Filter which device entries are returned from the platform database

Returns
  Dictionary of { 'target_id': 'platform_name', ... }

Definition at line 433 of file lstools_base.py.

## list_manufacture_ids()

mbed_lstools.lstools_base.MbedLsToolsBase.list_manufacture_ids | ( |  | self | ) |

Creates list of all available mappings for target_id -> Platform.

Returns
  String with table formatted output

Definition at line 373 of file lstools_base.py.

## list_mbeds()

mbed_lstools.lstools_base.MbedLsToolsBase.list_mbeds | ( |  | self,
|  |  | fs_interaction = `FSInteraction.BeforeFilter`,
|  |  | filter_function = `None`,
|  |  | unique_names = `False`,
|  |  | read_details_txt = `False`
| ) |  |

     List details of connected devices
    @return Returns list of structures with detailed info about each mbed
    @param fs_interaction A member of the FSInteraction class that picks the
      trade of between quality of service and speed
    @param filter_function Function that is passed each mbed candidate,
      should return True if it should be included in the result
      Ex. mbeds = list_mbeds(filter_function=lambda m: m['platform_name'] == 'K64F')
    @param unique_names A boolean controlling the presence of the
      'platform_unique_name' member of the output dict
    @param read_details_txt A boolean controlling the presense of the
      output dict attributes read from other files present on the 'mount_point'
    @details Function returns list of dictionaries with mbed attributes 'mount_point', TargetID name etc.
    Function returns mbed list with platform names if possible

Definition at line 118 of file lstools_base.py.

## list_mbeds_by_targetid()

mbed_lstools.lstools_base.MbedLsToolsBase.list_mbeds_by_targetid | ( |  | self | ) |

Get information about mbeds with extended parameters/info included.

Returns
  Returns dictionary where keys are TargetIDs and values are mbed structures

Ordered by target id (key: target_id).

Definition at line 477 of file lstools_base.py.

## list_mbeds_ext()

mbed_lstools.lstools_base.MbedLsToolsBase.list_mbeds_ext | ( |  | self | ) |

Function adds extra information for each mbed device.

Returns
  Returns list of mbed devices plus extended data like 'platform_name_unique'

Get information about mbeds with extended parameters/info included

Definition at line 110 of file lstools_base.py.

## list_platforms()

mbed_lstools.lstools_base.MbedLsToolsBase.list_platforms | ( |  | self | ) |

Useful if you just want to know which platforms are currently available on the system.

Returns
  List of (unique values) available platforms

Definition at line 447 of file lstools_base.py.

## list_platforms_ext()

mbed_lstools.lstools_base.MbedLsToolsBase.list_platforms_ext | ( |  | self | ) |

Useful if you just want to know how many platforms of each type are currently available on the system.

Returns
  Dict of platform: platform_count

Definition at line 461 of file lstools_base.py.

## mock_manufacture_id()

mbed_lstools.lstools_base.MbedLsToolsBase.mock_manufacture_id | ( |  | self,
|  |  | mid,
|  |  | platform_name,
|  |  | oper = `'+'`
| ) |  |

Replace (or add if manufacture id doesn't exist) entry in self.manufacture_ids.

Parameters

  oper | '+' add new mock / override existing entry '-' remove mid from mocking entry

Returns
  Mocked structure (json format)

Definition at line 358 of file lstools_base.py.

## mount_point_ready()

mbed_lstools.lstools_base.MbedLsToolsBase.mount_point_ready | ( |  | self,
|  |  | path
| ) |  |

Check if a mount point is ready for file operations.

Definition at line 689 of file lstools_base.py.

## parse_details_txt()

mbed_lstools.lstools_base.MbedLsToolsBase.parse_details_txt | ( |  | self,
|  |  | lines
| ) |  |

Definition at line 651 of file lstools_base.py.

## retarget()

mbed_lstools.lstools_base.MbedLsToolsBase.retarget | ( |  | self | ) |

Enable retargeting.

Read data from local retarget configuration file

Returns
  Retarget data structure read from configuration file

Definition at line 404 of file lstools_base.py.

## retarget_read()

mbed_lstools.lstools_base.MbedLsToolsBase.retarget_read | ( |  | self | ) |

Load retarget data from local file.

Returns
  Curent retarget configuration (dictionary)

Definition at line 389 of file lstools_base.py.

## run_cli_process()

mbed_lstools.lstools_base.MbedLsToolsBase.run_cli_process | ( |  | cmd,
|  |  | shell = `True`
| ) |  |

static

Definition at line 697 of file lstools_base.py.

## scan_html_line_for_target_id()

mbed_lstools.lstools_base.MbedLsToolsBase.scan_html_line_for_target_id | ( |  | self,
|  |  | line
| ) |  |

Definition at line 667 of file lstools_base.py.

## Member Data Documentation

## _fs_after_id_check

mbed_lstools.lstools_base.MbedLsToolsBase._fs_after_id_check

protected

Definition at line 156 of file lstools_base.py.

## _fs_before_id_check

mbed_lstools.lstools_base.MbedLsToolsBase._fs_before_id_check

protected

Definition at line 155 of file lstools_base.py.

## DETAILS_TXT_NAME

str mbed_lstools.lstools_base.MbedLsToolsBase.DETAILS_TXT_NAME = 'DETAILS.TXT'

static

Definition at line 69 of file lstools_base.py.

## dummy_counter

mbed_lstools.lstools_base.MbedLsToolsBase.dummy_counter

Definition at line 415 of file lstools_base.py.

## HOME_DIR

mbed_lstools.lstools_base.MbedLsToolsBase.HOME_DIR = expanduser("~")

static

Definition at line 66 of file lstools_base.py.

## list_unmounted

mbed_lstools.lstools_base.MbedLsToolsBase.list_unmounted

Definition at line 92 of file lstools_base.py.

## MBED_HTM_NAME

str mbed_lstools.lstools_base.MbedLsToolsBase.MBED_HTM_NAME = 'mbed.htm'

static

Definition at line 70 of file lstools_base.py.

## MOCK_FILE_NAME [1/2]

str mbed_lstools.lstools_base.MbedLsToolsBase.MOCK_FILE_NAME = '.mbedls-mock'

static

Definition at line 67 of file lstools_base.py.

## MOCK_FILE_NAME [2/2]

mbed_lstools.lstools_base.MbedLsToolsBase.MOCK_FILE_NAME

Definition at line 85 of file lstools_base.py.

## os_supported

list mbed_lstools.lstools_base.MbedLsToolsBase.os_supported = []

static

Definition at line 63 of file lstools_base.py.

## plat_db

mbed_lstools.lstools_base.MbedLsToolsBase.plat_db

Definition at line 90 of file lstools_base.py.

## retarget_data

mbed_lstools.lstools_base.MbedLsToolsBase.retarget_data

Definition at line 82 of file lstools_base.py.

## RETARGET_FILE_NAME [1/2]

str mbed_lstools.lstools_base.MbedLsToolsBase.RETARGET_FILE_NAME = 'mbedls.json'

static

Definition at line 68 of file lstools_base.py.

## RETARGET_FILE_NAME [2/2]

mbed_lstools.lstools_base.MbedLsToolsBase.RETARGET_FILE_NAME

Definition at line 393 of file lstools_base.py.

## VENDOR_ID_DEVICE_TYPE_MAP

dict mbed_lstools.lstools_base.MbedLsToolsBase.VENDOR_ID_DEVICE_TYPE_MAP

static

Initial value:
= {
'0483': 'stlink',
'0d28': 'daplink',
'1366': 'jlink',
'03eb': 'atmel'
}

Definition at line 72 of file lstools_base.py.

The documentation for this class was generated from the following file:

- mbed_lstools/lstools_base.py