CANape#

class pycanape.canape.CANape(project_path: str, fifo_size: int = 128, sample_size: int = 256, time_out: int = 0, clear_device_list: bool = True, modal_mode: bool = False, kill_open_instances: bool = True)#

Initialize and start the CANape runtime environment.

The first parameter sets the project path where the A2L file and the other configuration files are located. The FIFO and sample size buffer are used for the measurement buffer. The whole memory is calculated by the following formula: Size = FIFO * sample.

Parameters:
  • project_path – Sets the path of the working folder

  • fifo_size – Sets the FIFO buffer size for the measurement

  • sample_size – Sets the sample buffer size for the measurement

  • time_out – Sets the timeout in ms

  • clear_device_list – clear_device_list = True -> all devices are cleared clear_device_list = False -> all devices are added, which are described in the CANape.ini

  • modal_mode – Sets the start mode of CANape Value: modal_mode = True -> non-modal (Python Client and CANape) modal_mode = False -> modal (only Python Client)

  • kill_open_instances – If True, close all open CANape instances before start.

create_module(module_name: str, database_filename: str, driver: DriverType, channel: Channels, go_online: bool = True, enable_cache: int = -1) Module#

The create_module function is used for creating a new module/device and for loading an ASAP2 file or a DB file. The function configures the logical communication channel which will be used (like CCP: 1-4 = CAN1-CAN4) and the driver type like KWPOnCAN, or CCP. The return value contains the instance of the Module class.

Example:

module = canape.create_module(
    module_name="CCPSim",
    database_filename="C:\Program Files\CANape\CCPsim\CCPSIM.a2l",
    driver=defines.tDriverType.ASAP3_DRIVER_CCP,
    channel=defines.Channels.DEV_CAN1,
)

Note

If the XCP driver is used, the channel for TCP/IP or UDP has to be set to the value TCP = 255 or UDP = 256 and for FlexRay = 261.

Parameters:
  • module_name – Name of the module to create

  • database_filename – Sets the path and the name of the a2l or db file

  • driver – Set driver type

  • channel – Set the logical communication channel to be used from CANape

  • go_online – indicates, that the new device need to switched ONLINE (allows to create OFFLINE devices)

  • enable_cache – enabled the cache (1) oder disables it (0) if this parameter should be ignored it has to be set to (-1)

Returns:

The instance of the Module class

define_recorder(recorder_name: str, recorder_type: RecorderType = RecorderType.eTRecorderTypeMDF) Recorder#

Creates a new Recorder.

Parameters:
  • recorder_name – the name of the new Recorder

  • recorder_type – recorder type (e.g. eTRecorderTypeMDF, eTRecorderTypeILinkRT or eTRecorderTypeBLF)

Returns:

an instance of the Recorder class

exit(close_canape: bool = True) None#

Shut down ASAP3 connection to CANape with optional termination of CANape.

Parameters:

close_canape – close CANape application if True

get_application_version() AppVersion#

Call this function to get the current version of the server application.

get_cna_filename() str#

Call this function to get the current name of the used CNA file. This name is only available if CANape run in the nonmodal ASAP3 mode.

Returns:

Path to .cna file

static get_dll_version() DllVersion#

Version control

get_measurement_state() MeasurementState#

Get the current state of the measurement.

get_module_by_index(module_index: int) Module#

Get existing module (created by another application) by index.

Parameters:

module_index – index of device

Returns:

an instance of the Module class

get_module_by_name(module_name: str) Module#

Get existing module (created by another application) by name.

Parameters:

module_name – name of device

Returns:

an instance of the Module class

get_module_count() int#

Returns the count of instantiated Modules in the current Project.

Returns:

number of modules

get_project_directory() str#

Get the current project Directory.

get_recorder_by_index(index: int) Recorder#
get_recorder_count() int#

Return count of defined Recorders.

get_selected_recorder() Recorder#

Retrieve the currently selected Recorder

has_mcd3_license() bool#

Check if the MCD option is enabled.

is_network_activated(network_name: str) bool#

Receives the state a given network interface.

Parameters:

network_name – The name of the network as string

Returns:

state of network (True = active) or (False = disactivated)

load_cna_file(cna_file: str) None#

Call this function to load a configuration file (CNA).

popup_debug_window() None#

Trouble shooting: call this function to popup the debug window of the MCD-system.

register_callback(event_code: EventCode, callback_func: Callable[[], Any]) None#
reset_data_acquisition_channels() None#

Clears the data acquisition channel list.

Note

this function only clears these measurement objects from the API-Measurement-List which are defined by API

set_interactive_mode(mode: bool) None#

Enables the Interactive mode of CANape.

Parameters:

mode – Set this parameter to true to enable the interactive mode, otherwise set this paramater to false

start_data_acquisition() None#

Start data acquisition.

stop_data_acquisition() None#

Stop data acquisition.

unregister_callback(event_code: EventCode, callback_func: Callable[[], Any]) None#
class pycanape.canape.AppVersion(main_version, sub_version, service_pack, app_name)#

Create new instance of AppVersion(main_version, sub_version, service_pack, app_name)

app_name: str#

Alias for field number 3

main_version: int#

Alias for field number 0

service_pack: int#

Alias for field number 2

sub_version: int#

Alias for field number 1

class pycanape.canape.DllVersion(dll_main_version, dll_sub_version, dll_release, os_version, os_release)#

Create new instance of DllVersion(dll_main_version, dll_sub_version, dll_release, os_version, os_release)

dll_main_version: int#

Alias for field number 0

dll_release: int#

Alias for field number 2

dll_sub_version: int#

Alias for field number 1

os_release: int#

Alias for field number 4

os_version: str#

Alias for field number 3