Skip to content
Snippets Groups Projects
Commit 019414d0 authored by auke.klazema's avatar auke.klazema
Browse files

extracted port name validation to a method

parent 141b2752
Branches
Tags
No related merge requests found
......@@ -24,13 +24,11 @@ class PrologixGpibUsb(PortDevice):
if port == "":
maxDeviceNum, port, portFormat = self._set_default_platform_values()
self._validate_port(port)
if verbose:
print "Looking for ports such as %s in range %d on %s" % \
( port, maxDeviceNum, platform.system() )
self._rematch=re.search(r"(/dev/tty.*[^0-9])([0-9]+$)",port)
if not self._rematch:
raise ValueError(port)
while int(self._rematch.group(2)) < maxDeviceNum:
if verbose:
......@@ -65,6 +63,11 @@ class PrologixGpibUsb(PortDevice):
self._devices = "Not scanned."
self._hpib_address = -1
def _validate_port(self, port):
self._rematch = re.search(r"(/dev/tty.*[^0-9])([0-9]+$)", port)
if not self._rematch:
raise ValueError(port)
def _set_default_platform_values(self):
if platform.system() == "Linux":
port = "/dev/ttyUSB0"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment