+3 votes
161 views
in Knowledge Base by Milan Simin (20 points)
reopened ago by Milan Simin

Yes. Typhoon HIL supports XCP over CAN and ETH.

Note: XCP over ETH and CAN is supported from version THCC 2025.4. While on previous THCC versions only XCP over CAN is supported.

XCP in the Typhoon HIL toolchain 

XCP master is supported in the Typhoon HIL toolchain in HIL SCADA, via the Python library pyxcp, while the parsing and importing of the a2l file is supported via the Python library pya2l. XCP slave is not supported in the Typhoon HIL toolchain. 

 Attached below is an example HIL SCADA panel file, where you can open the widget properties and write the Python code you want to execute. For creating properly configurations, you should use xcp-profile utility to convert a legacy .json/.toml file: 

 xcp-profile convert -c <YOUR_FILE_NAME>.json -o pyxcp_conf.py 

Then you can import the libraries and modules for XCP communication and other libraries.

import sys 
from time import sleep 
from pyxcp.cmdline import ArgumentParser 
from pyxcp.daq_stim import DaqToCsv, DaqList, DaqRecorder

To access additional Python scripts in your simulation, you will need to append the path for the script to the system path.

sys.path.append(“d:/path/to/python/file”)
from xcp_script import XCPclass, open_db_session, create_measurement_list, parse_csv

In order to parse the a2l file to retrieve the necessary information, the a2l file must be imported into an opened database. That database need to be open just once and you can do that by calling open_db_session() function before initializing anything: 

db, session = open_db_session(a2l_file_path)

The general idea is to acquire data from a device (ECU or simulator), process the data (either online or offline), and then store it or handle it in different formats. A DAQ list is a collection of measurements and data points to be recorded during the DAQ process. The allocation and optimization of ODTs is done automatically by pyXCP. For demonstration, we initialize DAQ list as follows: 

daq_list = [DaqList(
    name="test",
    event_num=2,
    stim=False,
    enable_timestamps=False,
    measurements=daq_measurements,
    priority=0,
    prescaler=1
)]

The data acquired can be stored in different formats: 

  • CSV: For simple tabular data XMRAW: 
  • A proprietary format for pyXCP to record raw DAQ data 
  • Parquet, MDF, SQLite: Other formats available for processing and storing data 

The measurement parameter should contain a list of the desired measurements for your DAQ process. To construct this list, you can simply create a list of measurement name and then call the create_measurement_list function. This function will automatically generate the compatible list of measurements that can be used in the measurements parameter. 

measurement_names = ["channel_d", "TestDWord_501", "TestDWord_502", "TestWord_992", "TestWord_991", "TestWord_989"]
daq_measurements = create_measurement_list(measurement_names, session)

The flexible callback mechanism in pyXCP allows users to interact with the DAQ process in a more modular and customizable way using policies. This flexibility makes it easier for users to integrate DAQ functionality into their workflow according to their specific needs. Before initializing the master, first we need to initialize policy that we will use: 

daq_parser = DaqToCsv(daq_list)

Then, we need to make an instance of ArgumentParser class which is used to set up the environment for running the DAQ process. Crete a master as follows: 

ap = ArgumentParser()
with ap.run(policy=daq_parser) as xm:
    xcp = XCPclass(master=xm)

After that, you can use the functions defined in the pyxcp library (connect, disconnect, upload, download) to connect and get additional info about the slave device. For unlocking a slave resource, you can implement your own function as it is done in the XCP script attached below if you know the algorithm. Another option is to provide the DLL file for unlocking after calling the get_seed_and_unlock function.

Important note: If you wish to use the DLL method for unlocking the resource, you will need to modify the pyxcp_conf.py file, where you need to uncomment and set the custom_dll_loader parameter.

This part of code is an example of how to use the functions defined in pyxcp and implement the xcp_script. The function get_seed_and_unlock gets the XCP seed key and unlocks the specified resource.

xcp = XCPclass(master=xm)
timestamp_enable = False
conn = xm.connect()
mode_info = xm.getCommModeInfo()
gid = xm.getId(0x1)
status = xm.getStatus()
xm.synch()

xcp.get_seed_and_unlock(xm, 0x04, dll_path)
DAQ_proc_info = xm.getDaqProcessorInfo()
DAQ_res_info = xm.getDaqResolutionInfo()
DAQ_info = xm.getDaqInfo()
for i in range(0, len(DAQ_info["channels"])):
    DAQ_event_info = xm.getDaqEventInfo(i)
    upload_rcv = xm.upload(DAQ_event_info.eventChannelNameLength)

xcp.get_seed_and_unlock(xm, 0x01, dll_path)
scp = xm.setCalPage(0x83, 0, 0)

xcp.build_checksum_for_slave(xm, session)
xcp.set_mta_and_build_checksum(xm, session)
for i in range(0, DAQ_proc_info.maxEventChannel - 1):
    DAQ_event_info = xm.getDaqEventInfo(i)
    upload_rcv = xm.upload(DAQ_event_info.eventChannelNameLength)
pwm = xcp.get_measurement(xm, "PWM", session)
print(pwm)
pwm_filter = xcp.get_measurement(xm, "PWMFiltered", session)
print(pwm_filter)

value = 5
PWM_Level = xcp.get_characteristic_value(xm, "PWM_Level", session)
print(PWM_Level)

xcp.set_characteristic_value(xm, value, "PWM_Level", session)

PWM_Level = xcp.get_characteristic_value(xm, "PWM_Level", session)
print(PWM_Level)

daq_parser.setup()
daq_parser.start()
sleep(1)
daq_parser.stop()
session.close()
xm.disconnect()

get_measurement uploads the specified measurement value from slave to master. set_characteristic_value downloads the specified characteristic value from master to slave. get_characteristic_value uploads the specified characteristic value from slave to master.

Once the DAQ sequence is started, the results are stored in the .csv file in our example. You can parse that file using our custom function as follows: 

data_dict = parse_csv("test.csv")
for i in range(len(data_dict)):
    print(data_dict[measurement_names[i]])

Example XCP scripts are attached. Feel free to adapt the scripts provided to your needs. 

  1. XCP_on_CAN_script
  2. XCP_on_ETH_script

Example HIL SCADA panel file: SCADA_example

Example of config file: config_file_with_dll

Please log in or register to answer this question.

...