pyx2cscope.utils.config

Read the settings of config.ini in the current working directory.

Functions:

get_config_file() -> ConfigParser: Retrieves the configuration file. get_elf_file_path(key=”path”) -> str: Gets the path to the ELF file from the configuration. get_com_port(key=”com_port”) -> str: Gets the COM port from the configuration. get_host_address(key=”host_ip”) -> str: Gets the host IP address from the configuration. get_can_config() -> dict: Gets the CAN interface configuration parameters.

Module Contents

Functions

get_config_file(→ configparser.ConfigParser)

Retrieves the configuration file. If the configuration file does not exist, it creates one with default values.

get_elf_file_path(→ str)

Gets the path to the ELF file from the configuration.

get_com_port(→ str)

Gets the COM port from the configuration.

get_host_address(→ str)

Gets the Host IP Address from the configuration.

get_can_config(→ dict)

Gets the CAN interface configuration parameters from the configuration file.

pyx2cscope.utils.config.get_config_file() → configparser.ConfigParser[source]

Retrieves the configuration file. If the configuration file does not exist, it creates one with default values.

Returns:

ConfigParser: The configuration parser object.

pyx2cscope.utils.config.get_elf_file_path(key='path') → str[source]

Gets the path to the ELF file from the configuration.

Args:

key (str): The key for the ELF file path in the configuration. Default is “path”.

Returns:

str: The path to the ELF file.

pyx2cscope.utils.config.get_com_port(key='com_port') → str[source]

Gets the COM port from the configuration.

Args:

key (str): The key for the COM port in the configuration. Default is “com_port”.

Returns:

str: The COM port.

pyx2cscope.utils.config.get_host_address(key='host_ip') → str[source]

Gets the Host IP Address from the configuration.

Args:

key (str): The key for the Host IP Address in the configuration. Default is “host_ip”.

Returns:

str: The IP address.

pyx2cscope.utils.config.get_can_config() → dict[source]

Gets the CAN interface configuration parameters from the configuration file.

Returns a dictionary with all CAN interface parameters including bustype, channel, baud_rate, id_tx, id_rx, and mode. If values are not properly configured, returns default values.

Returns:
dict: Dictionary containing CAN configuration parameters:
  • bustype (str): CAN interface type (default: ‘pcan_usb’)

  • channel (int): CAN channel number (default: 1)

  • baud_rate (int): CAN baud rate in bps (default: 500000)

  • id_tx (int): TX arbitration ID (default: 0x110)

  • id_rx (int): RX arbitration ID (default: 0x100)

  • mode (str): CAN ID mode ‘standard’ or ‘extended’ (default: ‘standard’)

Example:
>>> can_config = get_can_config()
>>> x2c = X2CScope(elf_file="firmware.elf", **can_config)