Skip to content

Commit

Permalink
Use PortManager to obtain ports in get_driver()
Browse files Browse the repository at this point in the history
Previously, get_driver was obtaining a (new) port from the
low-level Ports module every time it was called. This led to errors
when the port was already opened, also when combining the same
driver in a SweepMe! module and a CustomFunction Script using
get_driver(). Now, the PortManager is used consistently.
  • Loading branch information
fk3 committed Nov 4, 2024
1 parent a1e55ea commit 9bea6da
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pysweepme/DeviceManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from .Architecture import version_info
from .EmptyDeviceClass import EmptyDevice
from .ErrorMessage import error
from .Ports import get_port
from .PortManager import PortManager


def get_main_py_path(path: str) -> str:
Expand Down Expand Up @@ -121,7 +121,8 @@ def setup_driver(driver: EmptyDevice, name: str, port_string: str) -> None:
"""
if port_string != "":
if driver.port_manager:
port = get_port(port_string, driver.port_properties)
port_manager = PortManager()
port = port_manager.get_port(port_string, driver.port_properties)
driver.set_port(port)

driver.set_parameters({"Port": port_string, "Device": name})
Expand Down

0 comments on commit 9bea6da

Please sign in to comment.