Skip to content
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

Merged
merged 3 commits into from
Jul 29, 2016

Conversation

brooksfoxen
Copy link
Contributor

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

@@ -112,7 +112,7 @@ def refreshDevices(self):
elif addr.startswith('TCPIP'):
instName = addr
elif addr.startswith('USB'):
instName = addr + '::INSTR'
instName = addr
Copy link
Contributor

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)
...

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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):
Copy link
Contributor

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)

@maffoo
Copy link
Contributor

maffoo commented Jul 29, 2016

One formatting nit, then LGTM.

@brooksfoxen brooksfoxen merged commit a9ba7d2 into master Jul 29, 2016
@brooksfoxen brooksfoxen deleted the u/Brooks/fix_usb_device_address branch July 29, 2016 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants