In automotive electronic ECU development and testing, joint simulation has become a key means to improve testing efficiency and ensure system stability. And TSMaster, as a comprehensive tool for automotive electronic simulation and testing, combined with ECUTEST's professional testing capabilities, can realize efficient automated testing. In this article, we will introduce in detail how to import TSMaster API plug-ins and explain the core API interface functions.
Keywords:TSMasterAPI, ECUTEST, API Interface
1. TSMasterAPI Plugin
Currently, TSMaster provides programmable TSMaster software and hardware interfaces for the majority of ecutest users, and the corresponding interface names can be viewed in the ECUTEST software.
Program control TSMaster UI interface to realize SIL simulation interface name: TSOUN: TSMaster SIL Kit; program control TOSUN hardware products to realize SIL simulation interface name: TOSUN: Hardware SIL Kit. as shown in the figure below:

1.1 Importing TSMasterAPI
1.1.1 Deploying the plug-in
TOSUN official will provide ECUTEST plug-in environment when installing TSMaster, users can choose whether to install the plug-in or not, the same way as installing C++\Python environment to check the box to install.

Meanwhile, if you want to use the plug-in at the first time, you can contact TOSUN sales or technology at the same time to get the plug-in package, and then manually put it into the ECUTEST software, the location of which is shown in the figure below:

1.1.2 Workspace Import Plugin
When you create ECUTEST workspace, check “Show workspace settings” -> “Copy tutorial files” -> select “TSMasterAPI” -> ‘OK’, you can see “TSOUN: TSMaster SATURDAY” in the workspace. “TSMasterAPI” -> ‘OK’, then you can see “TSOUN: TSMaster SIL Kit” and “TSOUN: Hardware SIL Kit” in the workspace.

1.2 TOSUN: TSMaster SIL Kit
1.2.1 Create test bench configuration
First create “test bench configruation” -> “new create new tool host” -> "Local “; then you can see ”TOSUN: TSMaster SIL Kit" in the tool host window.
Right click “TOSUN: TSMaster SIL Kit” -> “Add tool” -> "TSMaster_project_path In “TSMaster_project_path”, fill in the project path of TSMaster and click save.
(1) Create “test bench configruation”.

(2)“Create new tool host”

(3)“TOSUN: TSMaster SIL Kit”->“Add tool”

(4) “Save”

(5) “Start”

(6)“Connect tool”

(7) Interface call

1.3 TOSUN:Hardware SIL Kit
1.3.1 Creating a test bench configuration
First create “test bench configruation” -> “new create new tool host” -> "Local “; then you can see ”TOSUN: Hardware SIL Kit" in the tool host window. Right click “TOSUN: TSMaster SIL Kit” -> “Add tool” -> “TSMaster_App_Name”. Fill in the application name of TSMaster and click Save.
(1) Create “test bench configruation”.

(2)“Create new tool host”

(3)“TOSUN: TSMaster SIL Kit”->“Add tool”

(4) “Save”

(5) “Start”

(6)“Connect tool”

(7) Interface call

2. TSMasterAPI Interface Description
2.1 TOSUN: TSMaster SIL Kit
2.1.1 start_simulation
Parameter name | start_simulation() |
Function | RPC client startup server TSMaster emulation |
call location | After creating the rpc client, call |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | start_simulation() |
2.1.2 simulation_is_running
Parameter name | simulation_is_running() |
Function | Returns whether the server-side TSMaster has emulation enabled or not |
call location | After creating the rpc client, call |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | ret =simulation_is_running() if ret: print(“Emulation is turned on”) |
2.1.3 stop_simulation
Parameter name | stop_simulation() |
Function | RPC client stops server side TSMaster emulation |
call location | After creating the rpc client, call |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | stop_simulation() |
2.1.4 get_sysvar_value
Parameter name | get_sysvar_value(SysvarName:str)->(errorcode, double) |
Function | Getting system variable values |
call location | Called after activating the rpc client |
Input parameter | SysvarName: System Variable Name |
Return value | ==Ret[0]: error code, ==0 for success, other failures Ret[1]:Signal value |
Typical example | ret,value = get_sysvar_value(‘Var0’) if ret == 0 and value==100: Print(“ok”) |
2.1.5 set_sysvar_value
Parameter name | get_sysvar_value(SysvarName:str, value:double)->errorcode |
Function | Getting system variable values |
call location | Called after activating the rpc client |
Input parameter | SysvarName: System Variable Name Value: Setting value |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | set = set_sysvar_value(‘Var0’ ,100) |
2.1.6 get_cansignal_value
Parameter name | get_cansignal_value(cansignalName:str)->(errorcode, double) |
Function | Getting system variable values |
call location | Called after activating the rpc client |
Input parameter | cansignalName: signal address |
Return value | ==Ret[0]: error code, ==0 for success, other failures Ret[1]:Signal value |
Typical example | ret, value = get_cansignal_value( ‘0/CAN_FD_Powertrain/Engine/ABSdata/CarSpeed’) if ret == 0 and value==100: Print(“ok”) |
2.1.7 set_cansignal_value
Parameter name | set_cansignal_value (cansignal:str, value:double)->errorcode |
Function | Setting system variable values |
call location | Called after activating the rpc client |
Input parameter | cansignalName: signal address Value: Setting value |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | sset_cansignal_value( ‘0/CAN_FD_Powertrain/Engine/ABSdata/CarSpeed, 100) |
2.1.8 get_linsignal_value
Parameter name | get_linsignal_value (linsignalName:str)->(errorcode, double) |
Function | Getting system variable values |
call location | Called after activating the rpc client |
Input parameter | LinsignalName: signal address |
Return value | ==Ret[0]: error code, ==0 for success, other failures Ret[1]:Signal value |
Typical example | ret,value = get_linsignal_value( ‘0/LIN_Powertrain/Engine/ABSdata/CarSpeed) if ret == 0 and value==100: Print(“ok”) |
2.1.9 set_linsignal_value
Parameter name | set_linsignal_value (linsignal:str, value:double)->errorcode |
Function | Setting system variable values |
call location | Called after activating the rpc client |
Input parameter | LinsignalName: signal address Value: Setting value |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | set_linsignal_value( ‘0/LIN_Powertrain/Engine/ABSdata/CarSpeed, 100) |
2.1.10 get_frsignal_value
Parameter name | get_frsignal_value (frsignalName:str)->(errorcode, double) |
Function | Getting system variable values |
call location | Called after activating the rpc client |
Input parameter | frsignalName: signal address |
Return value | ==Ret[0]: error code, ==0 for success, other failures Ret[1]:Signal value |
Typical example | ret,value = get_frsignal_value( ‘0/FR_Powertrain/Engine/ABSdata/CarSpeed) if ret == 0 and value==100: Print(“ok”) |
2.1.11 set_frsignal_value
Parameter name | set_frsignal_value (frsignal:str, value:double)->errorcode |
Function | Setting system variable values |
call location | Called after activating the rpc client |
Input parameter | frsignalName: signal address Value: Setting value |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | set_frsignal_value( ‘0/FR_Powertrain/Engine/ABSdata/CarSpeed, 100) |
2.2 TOSUN: Hardware SIL Kit
2.2.1 set_hardware_config
Parameter name | set_hardware_config()->error_code |
Function | Configuring hardware devices for the current program |
call location | Called before connecting, can be left out if not in the case of modifying the channel configuration |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | set_hardware_config() |
2.2.2 connect
Parameter name | connect()->error_code |
Function | Connecting Hardware Devices |
call location | After configuring the hardware channel |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | connect() |
2.2.3 disconnect
Parameter name | disconnect()->error_code |
Function | Disconnect hardware devices |
call location | After configuring the hardware channel |
Input parameter | None |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | disconnect() |
2.2.4 send_msg
Parameter name | send_msg(AMsg:TLIBCAN|TLIBCANFD|TLIBLIN|TLIBFlexRay)->error_code |
Function | Single-frame transmitter message |
call location | After connecting the hardware |
Input parameter | AMsg: message object |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | AMsg = TLIBCAN(0x123) send_msg(AMsg) |
2.2.5 send_cyclic_can_msg
Parameter name | send_cyclic_can_msg (AMsg:TLIBCAN|TLIBCANFD, ATime)->error_code |
Function | Cyclic transmission of CAN/CANFD messages |
call location | After connecting the hardware |
Input parameter | AMsg: message object ATime: period, time in ms 1 means 1ms 100 means 100ms |
Return value | ==0: function executed successfully Other values: function execution failed |
Typical example | AMsg = TLIBCAN(0x123) send_cyclic_can_msg(AMsg, 100) |
2.2.6 recv_can_msg
Parameter name | recv_can_msg (AChnidx, ACount, IsIncludeTx)->AMsgList |
Function | Cyclic transmission of CAN/CANFD messages |
call location | After connecting the hardware |
Input parameter | AChnidx: Specified channel for incoming messages ACount: Maximum number of received messages IsIncludeTx: Whether or not to include sent messages |
Return value | AMsgList: list of received messages |
Typical example | AMsgs = recv_can_msg(0, 100, False) |
2.2.7 recv_lin_msg
Parameter name | recv_lin_msg(AChnidx, ACount, IsIncludeTx)->AMsgList |
Function | Receive lin messages |
call location | After connecting the hardware |
Input parameter | AChnidx: Specified channel for incoming messages ACount: Maximum number of received messages IsIncludeTx: Whether or not to include sent messages |
Return value | AMsgList: list of received messages |
Typical example | AMsgs = recv_lin_msg(0, 100, False)send_msg(AMsg) |
2.2.8 recv_flexray_msg
Parameter name | recv_flexray_msg(AChnidx, ACount, IsIncludeTx)->AMsgList |
Function | Receive flexray messages |
call location | After connecting the hardware |
Input parameter | AChnidx: Specified channel for incoming messages ACount: Maximum number of received messages IsIncludeTx: Whether or not to include sent messages |
Return value | AMsgList: list of received messages |
Typical example | AMsgs = recv_flexary_msg(0, 100, False) |
Which feature of TSMaster are you most interested in? Or what problems have you encountered in practical applications?
Welcome to share your experience or questions in the comment section, any ideas or suggestions can also be comment section message interaction, will have the opportunity to win the TOSUN mystery gift bag Oh ~!
Tip:
1. Software download:
Click on the software download link below to download and install directly, beta version is recommended:
2. Software upgrades:
You can check for upgrades to the latest version within the software, provided that your computer has an Internet connection.
Note: TOSUN Technical Support Email:support@tosunai.cnWe welcome inquiries! (Company and contact information must be indicated)