winIDEA SDK
advanced_winidea_launching.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7# It is not required to connect to winIDEA for enumeration, so
8# ConnectionMgr() object is all we need.
9connectionMgr = ic.ConnectionMgr()
10
11# Let's connect to winIDEA with known ID
12connectionConfig = ic.CConnectionConfig()
13connectionConfig.instanceId('myID')
14
15
16try:
17 connectionConfig.start_existing()
18 connectionMgr.connect(connectionConfig)
19 port = connectionConfig.getUdpDiscoveryPort()
20 connectionMgr.disconnect_close(bSaveAll=False)
21 print('winIDEA found at port: ', port)
22except IOError:
23 print('No winIDEA with the specified ID found: ', connectionConfig.toString())
24
25# Now we'll start new instance with the given workspace and ID:
26connectionConfig.instanceId('myID').workspace('../../../targetProjects/SampleSTM32.xjrf')
27connectionMgr.connect(connectionConfig.start_always())
28# port = connectionMgr.startNewInstance(connectionConfig)
29port = connectionConfig.getUdpDiscoveryPort()
30print('New instance of winIDEA started. Port: ', port)
31connectionMgr.disconnect_close(bSaveAll=False)
32
33# Most often we want to start a new instance of winIDEA only
34# if the workspace is not already opened:
35connectionMgr.connect(connectionConfig.start_if_required())
36port = connectionConfig.getUdpDiscoveryPort()
37print('winIDEA available at port: ', port)
38connectionMgr.disconnect_keep()
39connectionMgr.connect(ic.CConnectionConfig().host('').udpDiscoveryPort(port))
40port = connectionConfig.getUdpDiscoveryPort()
41print('winIDEA closed: ', port)
42connectionMgr.disconnect_close(bSaveAll=False)
43
44
45# Let's start invisible winIDEA - you can control it only via isystem.connect
46invisibleConnectionConfig = ic.CConnectionConfig()
47invisibleConnectionConfig.visibility(ic.IConnect.lfShowHidden).workspace('../../../targetProjects/SampleSTM32.xjrf')
48connectionMgr.connect(invisibleConnectionConfig.start_always())
49port = invisibleConnectionConfig.getUdpDiscoveryPort()
50print('New instance of winIDEA started. Port: ', port)
51connectionMgr.disconnect_keep()
52
53# connect to new instance of winIDEA
54connectionMgr.connect(ic.CConnectionConfig().host('').udpDiscoveryPort(port).start_always())
55
56debugCtrl = ic.CDebugFacade(connectionMgr)
57print('downloading to invisible winIDEA')
58debugCtrl.download()
59print('Downloading finished')
60print('main_loop_counter = ', debugCtrl.evaluate(ic.IConnectDebug.fMonitor, 'main_loop_counter').getResult())
61
62# shut down the invisible winIDEA
63connectionMgr.disconnect_close(bSaveAll=False)
64print('Invisible winIDEA has been shut down')