Skip to content

Commit

Permalink
Fixed URI handling of gpib+usb scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
cgranade committed Apr 16, 2013
1 parent ebcc6bf commit 9c8d45c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 9 additions & 8 deletions python/src/instruments/abstract_instruments/instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,16 @@ def open_from_uri(cls, uri):
host, port = parsed_uri.netloc.split(":")
port = int(port)
return cls.open_tcpip((host, port), **kwargs)
elif parsed_uri.scheme == "gpib+usb" or scheme == "gpib+serial":
elif parsed_uri.scheme == "gpib+usb" or parsed_uri.scheme == "gpib+serial":
# Ex: gpib+usb://COM3/15
# scheme="gpib+usb", netloc="COM3", path="/15"
# FIXME: does not work if the serial location contains a "/",
# as is the case on Linux.
return cls.open_serial(
parsed_uri.netloc,
# Drop the leading / from the address.
int(parsed_uri.path[1:]),
# Make a new device path by joining the netloc (if any)
# with all but the last segment of the path.
uri_head, uri_tail = os.path.split(parsed_uri.path)
dev_path = os.path.join(parsed_uri.netloc, uri_head)
return cls.open_gpibusb(
dev_path,
int(uri_tail),
**kwargs)
elif parsed_uri.scheme == "visa":
# Ex: visa://USB::{VID}::{PID}::{SERIAL}::0::INSTR
Expand All @@ -258,7 +259,7 @@ def open_from_uri(cls, uri):
# device.
return cls.open_visa(parsed_uri.netloc, **kwargs)
else:
return NotImplementedError("Invalid scheme or not yet implemented.")
raise NotImplementedError("Invalid scheme or not yet implemented.")

@classmethod
def open_tcpip(cls, host, port):
Expand Down
2 changes: 2 additions & 0 deletions python/src/instruments/srs/srs345.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class SRS345Function(Enum):

class SRS345(SCPIInstrument):
# TODO: docstring
# FIXME: need to add OUTX 1 here, but doing so seems to cause a syntax
# error on the instrument.

@property
def amplitude(self):
Expand Down

0 comments on commit 9c8d45c

Please sign in to comment.