winIDEA SDK
Loading...
Searching...
No Matches
find_free_emulator.py
1# This script is licensed under BSD License, see file LICENSE.txt, or search for `License` in the SDK online help.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import isystem.connect as ic
6
7
8def main():
9 winidea_id = ''
10 connectionMgr = ic.ConnectionMgr()
11
12 # Let's connect to the currently running winIDEA. If no winIDEA
13 # instance is running, one is started.
14 connectionMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
15
16 ideCtrl = ic.CIDEController(connectionMgr)
17 debugCtrl = ic.CDebugFacade(connectionMgr)
18
19 # It is enough to specify emulator's serial number only. winIDEA
20 # then finds the right one.
21 emulatorSerialNumbers = ['#84379']
22
23 # emulators use TCP/IP mode. Other possible values for this option
24 # are 'LPT', 'COM', and 'USB'
25 ideCtrl.setOption('/IOPEN/Communication.Mode', 'TCP')
26
27 isConnected = False
28 for serialNumber in emulatorSerialNumbers:
29
30 ideCtrl.setOption('/IOPEN/Communication.IPAddress', serialNumber)
31
32 try:
33 debugCtrl.download()
34 isConnected = True
35 print('Found emulator with serial number: ', serialNumber)
36 break
37 except OSError:
38 print('Emulator with serial number ' + serialNumber + ' is not available.')
39
40
41 if isConnected:
42 print('Connected!')
43 else:
44 print('No free emulators found!')
45 # restore communication to USB if no free emulators found
46 ideCtrl.setOption('/IOPEN/Communication.Mode', 'USB')
47
48
49
50if __name__ == "__main__":
51 main()