-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
gpib: send the proper byte when using command #276
base: main
Are you sure you want to change the base?
Conversation
Nah. This still doesn't work. I don't much like the looks of Line 434 in 0651114
The boolean logic here is pretty opaque to me, so I don't exactly know what the idea is with this. I do think that what comes out of that line when I step through this code is not something that .command() should be called on later though and I think that's why this isn't working atm.
If I change that line to There are a bunch of these |
@greyltc in your testcase are you calling |
Actually in that particular case the or is wrong and we should be using self.controller always. This comes from my confusion of thinking that commands could be sent by INSTR (they cannot) so we must always use the controller (global) rather than the interface (device specific). I pushed a change, if you can check before tomorrow it would be great ! |
I'm just gonna open a new issue to answer that question so as not to combine two different bugs here :-) |
@@ -430,12 +430,12 @@ def gpib_control_ren(self, mode: constants.RENLineOperation) -> StatusCode: | |||
): | |||
return constants.StatusCode.error_nonsupported_operation | |||
|
|||
# INTFC don't have an interface so use the controller | |||
ifc = self.interface or self.controller | |||
# Commands and remote enable operation are common to the whole bus and |
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.
Should this even be allowed? (writing specifically about the 0x01 command here, but I guess this applies to most of the other stuff this function does) The user might not expect every instrument on their GPIB bus to go into local mode when they call a function on a single instrument. I think it's better to only expose gpib_control_ren()
for bus controller objects. This way the user is forced to understand that they're doing something that impacts the whole bus. See #278 for a problem with that today.
I think sending a single instrument to local mode should be done with ibloc()
because that's a device action, not a bus action. I don't see ibloc()
exposed anywhere in pyvisa-py right now though.
It does seem I have been confused by the wording of the documentation that suggest using GTL but for a single device (since I thought command could be per device it kind of made sense) https://documentation.help/NI-VISA/viGpibControlREN.html . Indeed ibloc seems like a higher level alternative to fiddling to much with commands. I will try to push another patch tonight.
|
@LongnoseRob @tivek if you get a chance to test things over this GPIB, this PR could use some testing. I do not have access to GPIB at the moment but I hope to solve this issue over the summer. |
I gave it a qucik spin, but could not use the gpib_command() feature. is there also a special branch of gpib-ctypes if have to use? |
It has been some since I last looked at it but I do not think you need a new gpib-ctypes for this. Note that this PR focuses on fixing control_ren on pyvisa-py and the code could be nicer when pyvisa/pyvisa#552 lands, so it may be worth testing this one first. |
Just getting my bearings around the code first. I reran the steps @LongnoseRob did and got the same results. Not surprising of course as the unsupported is returned in line 517 of sessions.py. The gist of my script and its output is here. Now on to the control_ren stuff. |
Okay, that was faster than I expected. Test script and output are here. And I can confirm the device goes in remote for about a second and than returns to local. Others devices on the bus do not go to local. |
Thanks for testing @dirkjankrijnders !!! Can I take from your last answer I can merge ? |
I only tested the GTL command, the other one would take some time to time test as I do not complete understand what their effects would be. If you're happy with that you can merge indeed. |
I will give this another read before doing anything else since this PR is old. If I need to change anything I may ping you to test again what you can easily test. |
Just to see what it does I tried sending
and that resulted in an error:
Next tried
And that did not cause error, but also no visible change to the device. The latter can be that it is not in the correct mode. This is all the testing I can do now. I can probably test more tomorrow. |
f41bfae
to
4051354
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #276 +/- ##
==========================================
- Coverage 24.89% 24.85% -0.04%
==========================================
Files 25 25
Lines 3515 3524 +9
Branches 490 490
==========================================
+ Hits 875 876 +1
- Misses 2622 2630 +8
Partials 18 18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I rebased and hopefully fixed the issues you encountered. |
Hi, the rebase did introduce a mismatch between PyVISA and pyvisa-py. Pyvisa-py now depends on pyvisa>=1.13.0 and the |
The PyVISA branch has been rebased @dirkjankrijnders can you test again ? |
45f70de
to
933ed7e
Compare
I rebased this on latest main and modified it to make use of the GPIBCommand definition of PyVISA. @dirkjankrijnders could you give this another spin and then I will merge and make new releases of pyvisa and pyvisa-py both. |
black . && isort -c . && flake8
with no errors