winIDEA SDK
Loading...
Searching...
No Matches
find_free_emulator.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
import isystem.connect as ic
def main():
winidea_id = ''
connectionMgr = ic.ConnectionMgr()
# Let's connect to the currently running winIDEA. If no winIDEA
# instance is running, one is started.
connectionMgr.connect(ic.CConnectionConfig().instanceId(winidea_id))
ideCtrl = ic.CIDEController(connectionMgr)
debugCtrl = ic.CDebugFacade(connectionMgr)
# It is enough to specify emulator's serial number only. winIDEA
# then finds the right one.
emulatorSerialNumbers = ['#84379']
# emulators use TCP/IP mode. Other possible values for this option
# are 'LPT', 'COM', and 'USB'
ideCtrl.setOption('/IOPEN/Communication.Mode', 'TCP')
isConnected = False
for serialNumber in emulatorSerialNumbers:
ideCtrl.setOption('/IOPEN/Communication.IPAddress', serialNumber)
try:
debugCtrl.download()
isConnected = True
print('Found emulator with serial number: ', serialNumber)
break
except OSError:
print('Emulator with serial number ' + serialNumber + ' is not available.')
if isConnected:
print('Connected!')
else:
print('No free emulators found!')
# restore communication to USB if no free emulators found
ideCtrl.setOption('/IOPEN/Communication.Mode', 'USB')
if __name__ == "__main__":
main()