-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gpib addressing to remove redundent ::INSTR. #365
Conversation
@@ -112,7 +112,7 @@ def refreshDevices(self): | |||
elif addr.startswith('TCPIP'): | |||
instName = addr | |||
elif addr.startswith('USB'): | |||
instName = addr + '::INSTR' | |||
instName = addr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the problem that addr
already includes ::INSTR
, so adding this again is not needed? Or is the problem that the instrument identifier doesn't need the suffix ::INSTR
at all?
If we do this, then the three branches can all be collapsed into check:
KNOWN_DEVICE_TYPES = ('GPIB', 'TCPIP', 'USB')
...
if not addr.startswith(KNOWN_DEVICE_TYPES):
continue
instr = rm.get_instrument(addr)
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I learned about passing a tuple of strings to startswith
in #205.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I jut double checked and the the USB scope's address already ends in '::INSTR'.
Is "KNOWN_DEVICE_TYPES" a global? If so, I think I made these changes correctly in the next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was imagining that tuple as being a module-level global, just like you did it.
@@ -62,6 +62,7 @@ | |||
### END NODE INFO | |||
""" | |||
|
|||
KNOWN_DEVICE_TYPES = ('GPIB', 'TCPIP', 'USB') | |||
|
|||
class GPIBBusServer(LabradServer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: two blank lines around top level definitions (https://google.github.io/styleguide/pyguide.html#Blank_Lines)
One formatting nit, then LGTM. |
Breaking up logical chages from #358.
This branch removes a redundant ::INSTR we were adding to USB devices in the gpib server.
I don't know that this is always the correct thing to do, but it definitely is for the two USB scopes I've used: Agilent DSA90804A scope and DSO-X2014A