reference

Python package for controlling Vector CANoe tool

CANoe(py_canoe_log_dir='', user_capl_functions=tuple())

The CANoe class represents the CANoe application. The CANoe class is the foundation for the object hierarchy. You can reach all other methods from the CANoe class instance.

Examples:

>>> # Example to open CANoe configuration, start measurement, stop measurement and close configuration.
>>> canoe_inst = CANoe(py_canoe_log_dir=r'D:\.py_canoe')
>>> canoe_inst.open(r'D:\py_canoe\demo_cfg\demo.cfg')
>>> canoe_inst.start_measurement()
>>> wait(10)
>>> canoe_inst.stop_measurement()
>>> canoe_inst.quit()
Parameters:
  • py_canoe_log_dir (str, default: '' ) –

    directory to store py_canoe log. example 'D:.py_canoe'

  • user_capl_functions (tuple, default: tuple() ) –

    user defined CAPL functions to access. on measurement init these functions will be initialized.

add_offline_source_log_file(absolute_log_file_path)

this method adds offline source log file.

Parameters:
  • absolute_log_file_path (str) –

    absolute path of offline source log file.

Returns:
  • bool( bool ) –

    returns True if log file added or already available. False if log file not available.

break_measurement_in_offline_mode()

Interrupts the playback in Offline mode.

call_capl_function(name, *arguments)

Calls a CAPL function. Please note that the number of parameters must agree with that of the CAPL function. not possible to read return value of CAPL function at the moment. only execution status is returned.

Parameters:
  • name (str) –

    The name of the CAPL function. Please make sure this name is already passed as argument during CANoe instance creation. see example for more info.

  • arguments (tuple, default: () ) –

    Function parameters p1…p10 (optional).

Returns:
  • bool( bool ) –

    CAPL function execution status. True-success, False-failed.

check_j1939_signal_online(bus, channel, message, signal, source_addr, dest_addr)

Checks whether the measurement is running and the signal has been received.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • source_addr (int) –

    The source address of the ECU that sends the message.

  • dest_addr (int) –

    The destination address of the ECU that receives the message.

Returns:
  • bool( bool ) –

    TRUE: if the measurement is running and the signal has been received. FALSE: if not.

check_j1939_signal_state(bus, channel, message, signal, source_addr, dest_addr)

Returns the state of the signal.

Returns:
  • int( int ) –

    State of the signal. possible values are: 0: The default value of the signal is returned. 1: The measurement is not running; the value set by the application is returned. 3: The signal has been received in the current measurement; the current value is returned.

check_signal_online(bus, channel, message, signal)

Checks whether the measurement is running and the signal has been received.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

Returns:
  • bool

    TRUE if the measurement is running and the signal has been received. FALSE if not.

check_signal_state(bus, channel, message, signal)

Checks whether the measurement is running and the signal has been received.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

Returns:
  • int

    State of the signal. 0- The default value of the signal is returned. 1- The measurement is not running; the value set by the application is returned. 2- The measurement is not running; the value of the last measurement is returned. 3- The signal has been received in the current measurement; the current value is returned.

clear_write_window_content()

Clears the contents of the Write Window.

compile_all_capl_nodes()

compiles all CAPL, XML and .NET nodes.

control_replay_block(block_name, start_stop)

Method for setting CANoe replay block file.

Parameters:
  • block_name (str) –

    CANoe replay block name

  • start_stop (bool) –

    True to start replay block. False to Stop.

control_tester_present(diag_ecu_qualifier_name, value)

Starts/Stops sending autonomous/cyclical Tester Present requests to the ECU.

Parameters:
  • diag_ecu_qualifier_name (str) –

    Diagnostic Node ECU Qualifier Name configured in "Diagnostic/ISO TP Configuration".

  • value (bool) –

    True - activate tester present. False - deactivate tester present.

copy_write_window_content()

Copies the contents of the Write Window to the clipboard.

define_system_variable(sys_var_name, value)

define_system_variable Create a system variable with an initial value Args: sys_var_name (str): The name of the system variable. Ex- "sys_var_demo::speed" value (Union[int, float, str]): variable value. Default value 0.

Returns:
  • object( object ) –

    The new Variable object.

disable_write_window_output_file(tab_index=None)

Disables logging of all outputs of the Write Window.

Parameters:
  • tab_index (int, default: None ) –

    The index of the page, for which logging of the output is to be activated. Defaults to None.

enable_write_window_output_file(output_file, tab_index=None)

Enables logging of all outputs of the Write Window in the output file.

Parameters:
  • output_file (str) –

    The complete path of the output file.

  • tab_index (int, default: None ) –

    The index of the page, for which logging of the output is to be activated. Defaults to None.

execute_all_test_environments()

executes all test environments available in test setup.

execute_all_test_modules_in_test_env(env_name)

executes all test modules available in test environment.

Parameters:
  • env_name (str) –

    test environment name. avoid duplicate test environment names in CANoe configuration.

execute_test_module(test_module_name)

use this method to execute test module.

Parameters:
  • test_module_name (str) –

    test module name. avoid duplicate test module names in CANoe configuration.

Returns:
  • int( int ) –

    test module execution verdict. 0 ='VerdictNotAvailable', 1 = 'VerdictPassed', 2 = 'VerdictFailed',

get_bus_databases_info(bus)

returns bus database info(path, channel, full_name).

Parameters:
  • bus (str) –

    bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

Returns:
  • dict

    bus database info {'path': 'value', 'channel': 'value', 'full_name': 'value'}

get_bus_nodes_info(bus)

returns bus nodes info(path, full_name, active).

Parameters:
  • bus (str) –

    bus (str): The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

Returns:
  • dict

    bus nodes info {'path': 'value', 'full_name': 'value', 'active': 'value'}

get_can_bus_statistics(channel)

Returns CAN Bus Statistics.

Parameters:
  • channel (int) –

    The channel of the statistic that is to be returned.

Returns:
  • dict

    CAN bus statistics.

get_canoe_version_info()

The Version class represents the version of the CANoe application.

Returns:
  • dict

    "full_name" - The complete CANoe version.

  • dict

    "name" - The CANoe version.

  • dict

    "build" - The build number of the CANoe application.

  • dict

    "major" - The major version number of the CANoe application.

  • dict

    "minor" - The minor version number of the CANoe application.

  • dict

    "patch" - The patch number of the CANoe application.

get_environment_variable_value(env_var_name)

returns a environment variable value.

Parameters:
  • env_var_name (str) –

    The name of the environment variable. Ex- "float_var"

Returns:
  • Union[int, float, str, tuple, None]

    Environment Variable value.

get_j1939_signal_full_name(bus, channel, message, signal, source_addr, dest_addr)

Determines the fully qualified name of a signal.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • source_addr (int) –

    The source address of the ECU that sends the message.

  • dest_addr (int) –

    The destination address of the ECU that receives the message.

Returns:
  • str( str ) –

    The fully qualified name of a signal. The following format will be used for signals: ::::

get_j1939_signal_value(bus, channel, message, signal, source_addr, dest_addr, raw_value=False)

get_j1939_signal Returns a Signal object.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • source_addr (int) –

    The source address of the ECU that sends the message.

  • dest_addr (int) –

    The destination address of the ECU that receives the message.

  • raw_value (bool, default: False ) –

    return raw value of the signal if true. Default(False) is physical value.

Returns:
  • Union[float, int]

    signal value.

get_measurement_index()

gets the measurement index for the next measurement.

Returns:
  • int

    Measurement Index.

get_measurement_running_status()

Returns the running state of the measurement.

Returns:
  • bool

    True if The measurement is running.

  • bool

    False if The measurement is not running.

get_signal_full_name(bus, channel, message, signal)

Determines the fully qualified name of a signal.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

Returns:
  • str( str ) –

    The fully qualified name of a signal. The following format will be used for signals: ::::

get_signal_value(bus, channel, message, signal, raw_value=False)

get_signal_value Returns a Signal value.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • raw_value (bool, default: False ) –

    return raw value of the signal if true. Default(False) is physical value.

Returns:
  • Union[float, int]

    signal value.

get_system_variable_value(sys_var_name)

get_system_variable_value Returns a system variable value.

Parameters:
  • sys_var_name (str) –

    The name of the system variable. Ex- "sys_var_demo::speed"

Returns:
  • Union[int, float, str, tuple, None]

    System Variable value.

get_test_environments()

returns dictionary of test environment names and class.

get_test_modules(test_env_name)

returns dictionary of test module names and class.

Parameters:
  • test_env_name (str) –

    test environment name. avoid duplicate test environment names in CANoe configuration.

new(auto_save=False, prompt_user=False)

Creates a new configuration.

Parameters:
  • auto_save (bool, default: False ) –

    A boolean value that indicates whether the active configuration should be saved if it has been changed. Defaults to False.

  • prompt_user (bool, default: False ) –

    A boolean value that indicates whether the user should intervene in error situations. Defaults to False.

open(canoe_cfg, visible=True, auto_save=False, prompt_user=False)

Loads CANoe configuration.

Parameters:
  • canoe_cfg (str) –

    The complete path for the CANoe configuration.

  • visible (bool, default: True ) –

    True if you want to see CANoe UI. Defaults to True.

  • auto_save (bool, default: False ) –

    A boolean value that indicates whether the active configuration should be saved if it has been changed. Defaults to False.

  • prompt_user (bool, default: False ) –

    A boolean value that indicates whether the user should intervene in error situations. Defaults to False.

quit()

Quits CANoe without saving changes in the configuration.

read_text_from_write_window()

read the text contents from Write Window.

Returns:
  • str

    The text content.

reset_measurement()

reset the measurement.

Returns:
  • bool

    Measurement running status(True/False).

reset_measurement_in_offline_mode()

Resets the measurement in Offline mode.

save_configuration()

Saves the configuration.

Returns:
  • bool

    True if configuration saved. else False.

save_configuration_as(path, major, minor, create_dir=True)

Saves the configuration as a different CANoe version.

Parameters:
  • path (str) –

    The complete file name.

  • major (int) –

    The major version number of the target version.

  • minor (int) –

    The minor version number of the target version.

  • create_dir (bool, default: True ) –

    create directory if not available. default value True.

Returns:
  • bool

    True if configuration saved. else False.

send_diag_request(diag_ecu_qualifier_name, request, request_in_bytes=True, return_sender_name=False)

The send_diag_request method represents the query of a diagnostic tester (client) to an ECU (server) in CANoe.

Parameters:
  • diag_ecu_qualifier_name (str) –

    Diagnostic Node ECU Qualifier Name configured in "Diagnostic/ISO TP Configuration".

  • request (str) –

    Diagnostic request in bytes or diagnostic request qualifier name.

  • request_in_bytes (bool, default: True ) –

    True if Diagnostic request is bytes. False if you are using Qualifier name. Default is True.

  • return_sender_name (bool, default: False ) –

    True if you user want response along with response sender name in dictionary. Default is False.

Returns:
  • Union[str, dict]

    diagnostic response stream. Ex- "50 01 00 00 00 00" or {'Door': "50 01 00 00 00 00"}

set_environment_variable_value(env_var_name, value)

sets a value to environment variable.

Parameters:
  • env_var_name (str) –

    The name of the environment variable. Ex- "speed".

  • value (Union[int, float, str, tuple]) –

    variable value. supported CAPL environment variable data types integer, double, string and data.

set_j1939_signal_value(bus, channel, message, signal, source_addr, dest_addr, value, raw_value=False)

get_j1939_signal Returns a Signal object.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • source_addr (int) –

    The source address of the ECU that sends the message.

  • dest_addr (int) –

    The destination address of the ECU that receives the message.

  • value (Union[float, int]) –

    signal value.

  • raw_value (bool, default: False ) –

    return raw value of the signal if true. Default(False) is physical value.

Returns:
  • None

    signal value.

set_measurement_index(index)

sets the measurement index for the next measurement.

Parameters:
  • index (int) –

    index value to set.

Returns:
  • int

    Measurement Index value.

set_replay_block_file(block_name, recording_file_path)

Method for setting CANoe replay block file.

Parameters:
  • block_name (str) –

    CANoe replay block name

  • recording_file_path (str) –

    CANoe replay recording file including path.

set_signal_value(bus, channel, message, signal, value, raw_value=False)

set_signal_value sets a value to Signal. Works only when messages are sent using CANoe IL.

Parameters:
  • bus (str) –

    The Bus(CAN, LIN, FlexRay, MOST, AFDX, Ethernet) on which the signal is sent.

  • channel (int) –

    The channel on which the signal is sent.

  • message (str) –

    The name of the message to which the signal belongs.

  • signal (str) –

    The name of the signal.

  • value (Union[float, int]) –

    signal value.

  • raw_value (bool, default: False ) –

    return raw value of the signal if true. Default(False) is physical value.

set_system_variable_array_values(sys_var_name, value, index=0)

set_system_variable_array_values sets array of values to system variable.

Parameters:
  • sys_var_name (str) –

    The name of the system variable. Ex- "sys_var_demo::speed"

  • value (tuple) –

    variable values. supported integer array or double array. please always give only one type.

  • index (int, default: 0 ) –

    value of index where values will start updating. Defaults to 0.

set_system_variable_value(sys_var_name, value)

set_system_variable_value sets a value to system variable.

Parameters:
  • sys_var_name (str) –

    The name of the system variable. Ex- "sys_var_demo::speed".

  • value (Union[int, float, str]) –

    variable value. supported CAPL system variable data types integer, double, string and data.

start_measurement(timeout=60)

Starts the measurement.

Parameters:
  • timeout (int, default: 60 ) –

    measurement start/stop event timeout in seconds. Defaults to 60.

Returns:
  • bool

    True if measurement started. else False.

start_measurement_in_animation_mode(animation_delay=100)

Starts the measurement in Animation mode.

Parameters:
  • animation_delay (int, default: 100 ) –

    The animation delay during the measurement in Offline Mode.

step_measurement_event_in_single_step()

Processes a measurement event in single step.

stop_all_test_environments()

stops execution of all test environments available in test setup.

stop_all_test_modules_in_test_env(env_name)

stops execution of all test modules available in test environment.

Parameters:
  • env_name (str) –

    test environment name. avoid duplicate test environment names in CANoe configuration.

stop_ex_measurement(timeout=60)

StopEx repairs differences in the behavior of the Stop method on deferred stops concerning simulated and real mode in CANoe.

Parameters:
  • timeout (int, default: 60 ) –

    measurement start/stop event timeout in seconds. Defaults to 60.

Returns:
  • bool

    True if measurement stopped. else False.

stop_measurement(timeout=60)

Stops the measurement.

Parameters:
  • timeout (int, default: 60 ) –

    measurement start/stop event timeout in seconds. Defaults to 60.

Returns:
  • bool

    True if measurement stopped. else False.

stop_test_module(env_name, module_name)

stops execution of test module.

Parameters:
  • module_name (str) –

    test module name. avoid duplicate test module names in CANoe configuration.

ui_activate_desktop(name)

Activates the desktop with the given name.

Parameters:
  • name (str) –

    The name of the desktop to be activated.

ui_open_baudrate_dialog()

opens the dialog for configuring the bus parameters. Make sure Measurement stopped when using this method.

write_text_in_write_window(text)

Outputs a line of text in the Write Window. Args: text (str): The text.