winIDEA SDK
test_call.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# This Python example demonstrates the usage of the winIDEA SDK
4# CExecutionController class to connect to a target device, and
5# CLoaderController to download a program, execute functions
6# on the target device, and how to call functions with parameters
7# of various data types in a list.
8
9# (c) TASKING Germany GmbH, 2023
10
11import isystem.connect as ic
12
13
14winidea_id = ''
15
16
17def test_call():
18 connMgr = ic.ConnectionMgr()
19 connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
20
21 execCtrl = ic.CExecutionController(connMgr)
22 sessCtrl = ic.CSessionCtrl(connMgr)
23 sessCtrl.begin_program()
24
25 execCtrl.runUntilFunction('main')
26 execCtrl.waitUntilStopped()
27
28 print("Executing function 'fibonacci' via `call()` method...")
29 retVal = execCtrl.call("fibonacci", "12")
30 print(f"\tReturn value: {retVal}")
31 print(f"\tFunction prototpe: 'int fibonacci(int param)'")
32
33 print("Executing function 'return_smaller' via `call()` method...")
34 retVal = execCtrl.call("return_smaller", "123", "456")
35 print(f"\tReturn value: {retVal}")
36 print(f"\tFunction prototype: 'int return_smaller(int param1, int param2)'")
37
38 print("Executing function 'get_random' via `call()` method...")
39 retVal = execCtrl.call("get_random")
40 print(f"\tReturn value: {retVal}")
41 print(f"\tFunction prototype: 'int get_random(void)'")
42
43 # call with parameters in a list
44 params = ic.StrVector()
45 params.push_back('4')
46 params.push_back('5')
47 params.push_back('6')
48 params.push_back('6000')
49 params.push_back('1.62')
50 params.push_back('2.4')
51
52 print('sum_different_types(4, 5, 6, 6000, 1.62, 2.4) = ',
53 int(execCtrl.call('sum_different_types', params), 0))
54
55
56if __name__ == "__main__":
57 test_call()