winIDEA SDK
show_connection_status.py
1# This script is licensed under BSD License, see file LICENSE.txt.
2#
3# (c) TASKING Germany GmbH, 2023
4
5import time
6import sys
7import isystem.connect as ic
8
9
10# It is not required to connect to winIDEA for enumeration, so
11# ConnectionMgr() object is all we need.
12connectionMgr = ic.ConnectionMgr()
13
14connectionConfig = ic.CConnectionConfig()
15
16winIDEAInstances = ic.VectorWinIDEAInstanceInfo()
17
18hostAddress = '' # enumerate instances on local host. You may also specify remote host
19 # here, for example as IP address: '10.1.2.91'
20connectionMgr.enumerateWinIDEAInstances(hostAddress, connectionConfig, winIDEAInstances)
21
22for instance in winIDEAInstances:
23 print('Workspace: ', instance.getWorkspace())
24 print('Inst. Id : ', instance.getInstanceId())
25 print('TCP port : ', instance.getTcpPort(), '\n')
26
27
28emulators = ['iC3000 HS (SN 39457) : 5313', 'iC3000 HS (SN 37412) : 5313']
29
30# Now we'll connect to each of found winIDEA instances, and do
31# some visible actions!
32for instance in winIDEAInstances:
33 instanceCMgr = ic.ConnectionMgr()
34 cfg = ic.CConnectionConfig()
35 cfg.host(hostAddress)
36 cfg.udpDiscoveryPort(instance.getTcpPort())
37 instanceCMgr.connect(cfg)
38
39 debugCtrl = ic.CDebugFacade(instanceCMgr)
40 status = debugCtrl.getCPUStatus()
41
42 ideCtrl = ic.CIDEController(instanceCMgr)
43 emulatorCommunicationMode = ideCtrl.getOptionStr('/IOPEN/Communication.Mode')
44 emulatorUSBDeviceName = ideCtrl.getOptionStr('/IOPEN/Communication.USBDeviceName')
45 emulatorIPAddress = ideCtrl.getOptionStr('/IOPEN/Communication.IPAddress')
46
47 print('communication mode: ', emulatorCommunicationMode)
48 print('ip address: ', emulatorIPAddress)
49 print('USB device name: ', emulatorUSBDeviceName)
50
51 isConnected = (not status.isMustInit())
52 print('is connected: ', isConnected)
53 if isConnected:
54 if emulatorIPAddress in emulators:
55 emulators.remove(emulatorIPAddress)
56 else:
57 print('Emulator not in the list: ', emulatorIPAddress)
58
59 instanceCMgr.disconnect_close(bSaveAll=False)
60 print('Finished for port: ', instance.getTcpPort())
61
62print('Available emulators:', emulators)