CANape#
- class pycanape.canape.CANape(project_path: str | Path, 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)[source]#
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 (str | Path) – Sets the path of the working folder
fifo_size (int) – Sets the FIFO buffer size for the measurement
sample_size (int) – Sets the sample buffer size for the measurement
time_out (int) – Sets the timeout in ms
clear_device_list (bool) – 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 (bool) – 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 (bool) – If True, close all open CANape instances before start.
- create_module(module_name: str, database_filename: str | Path, driver: DriverType, channel: Channels, go_online: bool = True, enable_cache: int = -1) Module [source]#
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 (str) – Name of the module to create
database_filename (str | Path) – Sets the path and the name of the a2l or db file
driver (DriverType) – Set driver type
channel (Channels) – Set the logical communication channel to be used from CANape
go_online (bool) – indicates, that the new device need to switched ONLINE (allows to create OFFLINE devices)
enable_cache (int) – 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
- Return type:
- define_recorder(recorder_name: str, recorder_type: RecorderType = RecorderType.eTRecorderTypeMDF) Recorder [source]#
Creates a new Recorder.
- Parameters:
recorder_name (str) – the name of the new Recorder
recorder_type (RecorderType) – recorder type (e.g. eTRecorderTypeMDF, eTRecorderTypeILinkRT or eTRecorderTypeBLF)
- Returns:
an instance of the Recorder class
- Return type:
- exit(close_canape: bool = True) None [source]#
Shut down ASAP3 connection to CANape with optional termination of CANape.
- Parameters:
close_canape (bool) – close CANape application if True
- Return type:
None
- get_application_version() AppVersion [source]#
Call this function to get the current version of the server application.
- Return type:
- get_cna_filename() str [source]#
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
- Return type:
- get_dll_version() DllVersion [source]#
Version control
- Return type:
- get_measurement_state() MeasurementState [source]#
Get the current state of the measurement.
- Return type:
- get_module_by_index(module_index: int) Module [source]#
Get existing module (created by another application) by index.
- get_module_by_name(module_name: str) Module [source]#
Get existing module (created by another application) by name.
- get_module_count() int [source]#
Returns the count of instantiated Modules in the current Project.
- Returns:
number of modules
- Return type:
- is_network_activated(network_name: str) bool [source]#
Receives the state a given network interface.
- load_cna_file(cna_file: str | Path) None [source]#
Call this function to load a configuration file (CNA).
- popup_debug_window() None [source]#
Trouble shooting: call this function to popup the debug window of the MCD-system.
- Return type:
None
- reset_data_acquisition_channels() None [source]#
Clears the data acquisition channel list.
Note
this function only clears these measurement objects from the API-Measurement-List which are defined by API
- Return type:
None
- class pycanape.canape.AppVersion(main_version, sub_version, service_pack, app_name)[source]#
Create new instance of AppVersion(main_version, sub_version, service_pack, app_name)