Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Config Class Reference

Config Class Reference

Public Member Functions

def __init__
def add_config_files
def has_regions
def regions
def get_target_config_data
def get_lib_config_data
def get_app_config_data
def get_config_data
def parameters_to_macros
def config_macros_to_macros
def config_to_macros
def get_config_data_macros
def get_features
def validate_config
def load_resources
def config_to_header
def get_config_data_header

Detailed Description

'Config' implements the mbed configuration mechanism

Definition at line 346 of file config/__init__.py.


Constructor & Destructor Documentation

def __init__ (   self,
  tgt,
  top_level_dirs = None,
  app_config = None 
)
Construct a mbed configuration

Positional arguments:
target - the name of the mbed target used for this configuration
 instance

Keyword argumets:
top_level_dirs - a list of top level source directories (where
         mbed_app_config.json could be found)
app_config - location of a chosen mbed_app.json file

NOTE: Construction of a Config object will look for the application
configuration file in top_level_dirs. If found once, it'll parse it.
top_level_dirs may be None (in this case, the constructor will not
search for a configuration file).

Definition at line 375 of file config/__init__.py.


Member Function Documentation

def add_config_files (   self,
  flist 
)
Add configuration files

Positional arguments:
flist - a list of files to add to this configuration

Definition at line 446 of file config/__init__.py.

def config_macros_to_macros (   macros )
Return the macro definitions generated for a dictionary of
ConfigMacros (as returned by get_config_data).

Positional arguments:
params - a dictionary mapping a name to a ConfigMacro instance

Return: a list of strings that are the C pre-processor macros

Definition at line 808 of file config/__init__.py.

def config_to_header (   config,
  fname = None 
)
Convert the configuration data to the content of a C header file,
meant to be included to a C/C++ file. The content is returned as a
string.

Positional arguments:
config - configuration data as (ConfigParam instances, ConfigMacro
 instances) tuple (as returned by get_config_data())

Keyword arguments:
fname -  also write the content is to the file called "fname".
 WARNING: if 'fname' names an existing file, it will be
 overwritten!

Definition at line 904 of file config/__init__.py.

def config_to_macros (   config )
Convert the configuration data to a list of C macros

Positional arguments:
config - configuration data as (ConfigParam instances, ConfigMacro
 instances) tuple (as returned by get_config_data())

Definition at line 820 of file config/__init__.py.

def get_app_config_data (   self,
  params,
  macros 
)
Read and interpret the configuration data defined by the target. The
target can override any configuration parameter, as well as define its
own configuration data.

Positional arguments.
params - the dictionary with configuration parameters found so far (in
 the target and in libraries)
macros - the list of macros defined in the configuration

Definition at line 745 of file config/__init__.py.

def get_config_data (   self )
Return the configuration data in two parts: (params, macros)
params - a dictionary with mapping a name to a ConfigParam
macros - the list of macros defined with "macros" in libraries and in
 the application (as ConfigMacro instances)

Arguments: None

Definition at line 764 of file config/__init__.py.

def get_config_data_header (   self,
  fname = None 
)
Convert a Config instance to the content of a C header file, meant
to be included to a C/C++ file. The content is returned as a string.

Keyword arguments:
fname - also write the content to the file called "fname".
WARNING: if 'fname' names an existing file, it will be
overwritten!

Definition at line 943 of file config/__init__.py.

def get_config_data_macros (   self )
Convert a Config object to a list of C macros

Arguments: None

Definition at line 832 of file config/__init__.py.

def get_features (   self )
Extract any features from the configuration data

Arguments: None

Definition at line 839 of file config/__init__.py.

def get_lib_config_data (   self )
Read and interpret configuration data defined by libraries. It is
assumed that "add_config_files" above was already called and the library
configuration data exists in self.lib_config_data

Arguments: None

Definition at line 723 of file config/__init__.py.

def get_target_config_data (   self )
Read and interpret configuration data defined by targets.

We consider the resolution order for our target and sort it by level
reversed, so that we first look at the top level target (the parent),
then its direct children, then the children of those children and so on,
until we reach self.target
TODO: this might not work so well in some multiple inheritance scenarios
At each step, look at two keys of the target data:
  - config_parameters: used to define new configuration parameters
  - config_overrides: used to override already defined configuration
              parameters

Arguments: None

Definition at line 674 of file config/__init__.py.

def has_regions (   self )
Does this config have regions defined?

Definition at line 483 of file config/__init__.py.

def load_resources (   self,
  resources 
)
Load configuration data from a Resources instance and expand it
based on defined features.

Positional arguments:
resources - the resources object to load from and expand

Definition at line 874 of file config/__init__.py.

def parameters_to_macros (   params )
Encode the configuration parameters as C macro definitions.

Positional arguments:
params - a dictionary mapping a name to a ConfigParameter

Return: a list of strings that encode the configuration parameters as
C pre-processor macros

Definition at line 795 of file config/__init__.py.

def regions (   self )
Generate a list of regions from the config

Definition at line 496 of file config/__init__.py.

def validate_config (   self )
Validate configuration settings. This either returns True or
raises an exception

Arguments: None

Definition at line 856 of file config/__init__.py.