Commit 141b2752 authored by auke.klazema's avatar auke.klazema

extracted default plaform values to a method

parent 73ce0a2a
......@@ -22,16 +22,8 @@ class PrologixGpibUsb(PortDevice):
def __init__(self, port="", timeout=1, portFormat="%d", maxDeviceNum=9, verbose=False,
findDevices=False):
if port == "":
if platform.system() == "Linux":
port = "/dev/ttyUSB0"
portFormat = "%d"
maxDeviceNum = 99
elif platform.system() == "Darwin":
port = "/dev/ttys000"
portFormat = "%03d"
maxDeviceNum = 999
else:
raise NotImplementedError("Windows is not supported")
maxDeviceNum, port, portFormat = self._set_default_platform_values()
if verbose:
print "Looking for ports such as %s in range %d on %s" % \
( port, maxDeviceNum, platform.system() )
......@@ -73,6 +65,19 @@ class PrologixGpibUsb(PortDevice):
self._devices = "Not scanned."
self._hpib_address = -1
def _set_default_platform_values(self):
if platform.system() == "Linux":
port = "/dev/ttyUSB0"
port_format = "%d"
max_device_num = 99
elif platform.system() == "Darwin":
port = "/dev/ttys000"
port_format = "%03d"
max_device_num = 999
else:
raise NotImplementedError("Windows is not supported")
return max_device_num, port, port_format
def command(self, hpib_address, command):
if hpib_address != self._hpib_address:
command = "++addr " + str(hpib_address) + chr(10) + command
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment