Eterlogic virtual serial ports emulator

Python (COM interface)

from win32com import client
import msvcrt

# Create VSPE COM object
vspe = client.Dispatch("VSPE.VSPEApi")
activationKey = '' # <-----  PUT ACTIVATION KEY HERE

config_file_path = "1.vspe"
# Initialize result as False
result = False

# Simulate displaying VSPE API version info
print(vspe.vspe_getVersionInformation()) 

# Simulate activating VSPE API
result = vspe.vspe_activate(activationKey)
if not result:
    print(f"VSPE API activation error: {vspe.vspe_get_activation_error()}")
    exit(1)


# Simulate initializing VSPE components
result = vspe.vspe_initialize()
if not result:
    print("Initialization error %s" % str(result))
    exit(1)

# Simulate removing all existing devices
vspe.vspe_destroyAllDevices()

# Simulate stopping current emulation
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)

# Simulate dynamically creating devices
# Create Connector device (COM9, no baud rate emulation)
deviceId = vspe.vspe_createDevice("Connector", "9;0")
if deviceId == -1:
    print("Error: cannot create device")
    vspe.vspe_release()
    exit(1)

# Create Splitter (COM9 => COM10)
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)

# Create Pair device (COM21 => COM22)
deviceId = vspe.vspe_createDevice("Pair", "21;22;0")
if deviceId == -1:
    print("Error: cannot create device")
    vspe.vspe_release()
    exit(1)

# Working with configuration files
# Save configuration to file
result = vspe.vspe_saveConfiguration(config_file_path)
if not result:
    print("Error: cannot save configuration")
    vspe.vspe_release()
    exit(1)

# Load configuration from file
result = vspe.vspe_loadConfiguration(config_file_path)
if not result:
    print("Error: cannot load configuration")
    vspe.vspe_release()
    exit(1)

# STEP 2 - EMULATION LOOP
# Start emulation
result = vspe.vspe_startEmulation()
if not result:
    print("Error: cannot start emulation")
    vspe.vspe_release()
    exit(1)

# Emulation loop
input("Press any key to quit")

# STEP 3 - EXIT
# Stop emulation before exit
result = vspe.vspe_stopEmulation()
if not result:
    print("Error: emulation cannot be stopped: maybe one of VSPE devices is still used.")
    exit(1)

# Release VSPE
vspe.vspe_release()

2007-2025 Eterlogic Software