from win32com import client
import msvcrt
vspe = client.Dispatch("VSPE.VSPEApi")
activationKey = ''
config_file_path = "1.vspe"
result = False
print(vspe.vspe_getVersionInformation())
result = vspe.vspe_activate(activationKey)
if not result:
print(f"VSPE API activation error: {vspe.vspe_get_activation_error()}")
exit(1)
result = vspe.vspe_initialize()
if not result:
print("Initialization error %s" % str(result))
exit(1)
vspe.vspe_destroyAllDevices()
result = vspe.vspe_stopEmulation()
if not result:
print("Error: emulation cannot be stopped: maybe one of VSPE devices is still used.")
vspe.vspe_release()
exit(1)
deviceId = vspe.vspe_createDevice("Connector", "9;0")
if deviceId == -1:
print("Error: cannot create device")
vspe.vspe_release()
exit(1)
deviceId = vspe.vspe_createDevice("Splitter", "10;9;0;19200,0,8,1,0,0;0;0;0")
if deviceId == -1:
print("Error: cannot create device")
vspe.vspe_release()
exit(1)
deviceId = vspe.vspe_createDevice("Pair", "21;22;0")
if deviceId == -1:
print("Error: cannot create device")
vspe.vspe_release()
exit(1)
result = vspe.vspe_saveConfiguration(config_file_path)
if not result:
print("Error: cannot save configuration")
vspe.vspe_release()
exit(1)
result = vspe.vspe_loadConfiguration(config_file_path)
if not result:
print("Error: cannot load configuration")
vspe.vspe_release()
exit(1)
result = vspe.vspe_startEmulation()
if not result:
print("Error: cannot start emulation")
vspe.vspe_release()
exit(1)
input("Press any key to quit")
result = vspe.vspe_stopEmulation()
if not result:
print("Error: emulation cannot be stopped: maybe one of VSPE devices is still used.")
exit(1)
vspe.vspe_release()