winIDEA SDK
Loading...
Searching...
No Matches
test_call.py
# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
# (c) TASKING Germany GmbH, 2023
#
# This Python example demonstrates how to to connect to a target device, and
# download a program, execute functions
# on the target device, and how to call functions with parameters
# of various data types in a list.
import isystem.connect as ic
winidea_id = ''
def test_call():
connMgr = ic.ConnectionMgr()
connMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
execCtrl = ic.CExecutionController(connMgr)
sessCtrl = ic.CSessionCtrl(connMgr)
sessCtrl.begin_program()
execCtrl.runUntilFunction('main')
execCtrl.waitUntilStopped()
print("Executing function 'timesTwo' via `call()` method...")
retVal = execCtrl.call("timesTwo", "12")
print(f"\tReturn value: {retVal}")
print(f"\tFunction prototpe: 'int timesTwo(int num)'")
print("Executing function 'returnSmaller' via `call()` method...")
retVal = execCtrl.call("returnSmaller", "123", "456")
print(f"\tReturn value: {retVal}")
print(f"\tFunction prototype: 'int returnSmaller(int a, int b)'")
print("Executing function 'getNumber' via `call()` method...")
retVal = execCtrl.call("getNumber")
print(f"\tReturn value: {retVal}")
print(f"\tFunction prototype: 'int getNumber(void)'")
# call with parameters in a list
params = ic.StrVector()
params.push_back('4')
params.push_back('5')
params.push_back('6')
params.push_back('6000')
params.push_back('1.62')
params.push_back('2.4')
print('sumDifferentTypes(4, 5, 6, 6000, 1.62, 2.4) = ',
int(execCtrl.call('sumDifferentTypes', params), 0))
if __name__ == "__main__":
test_call()