|
From: J. S. <js...@gm...> - 2017-09-13 10:04:20
|
Hi Dave,
thank you very much for that short working example.
I will try that as soon as my system is setup properly again.
(Could take some time though :-( )
As you are the second person with a working *** wait( SRQ ) *** example i think it should be a problem with my setup.
Just out of curiosity, is it just for your convenience that you use the 1<<12 and 1<<14 as a value for the mask parameter?
Will that be transferred via the binding/c-wrapping exactly like the hex values ( 0x800 / 0x1000 ) ?
Anyway, i will try both when my system is up again.
Thanks a lot for looking at this!
Joerg
> On 10. Sep 2017, at 21:11, dave penkler <dpe...@gm...> wrote:
>
> Hi Joerg,
> I have tried this little program on a vanilla 4.0.3 with a BEIMING adaptor which behaves like an Agilent 82357a
>
> Below is the code and the log running it once when pressing a function key and the other time without.
> Note that the wait function is on the board and not the device.
> Hope this helps.
> cheers,
> -Dave
>
> $ cat srq.py
> import sys
> sys.path.append('/usr/local/lib64/python2.7/site-packages')
> import gpib
>
> board = 2
> device = 1
> SRQI = (1<<12)
> TIMO = (1<<14)
>
> # Shamelessly borrowed from cfo
> def query(handle, command, numbytes=100):
> gpib.write(handle,command)
> response = gpib.read(handle,numbytes)
> response = response.rstrip("\r\n")
> return response
>
> print gpib.version() # Show package version
> t = gpib.dev(board,device) # Open the HP9111A Graphics tablet
> gpib.clear(t) # Start out clean
> print query(t,"OI") # Output ID
> gpib.write(t,"DF") # Default mode
> gpib.write(t,"IM 7,128,0") # Assert SRQ on special function key
> gpib.wait(board, TIMO | SRQI) # Wait for special function key
> sta = gpib.ibsta() # Get status
> if (sta & TIMO) != 0:
> print "Timed out"
> else:
> print "SRQ asserted"
> print query(t, "RS") # Request special function key index
> gpib.close(t)
> $ python srq.py
> 4.0.3
> 9111T
> SRQ asserted
> 1
> $ python srq.py
> 4.0.3
> 9111T
> Timed out
> $
>
>
> On Mon, Sep 4, 2017 at 10:18 PM, J. Sommersberg <js...@gm... <mailto:js...@gm...>> wrote:
> Hello Wilhelm,
>
> thank you for answering.
>
> It doesn’t work for me ( i described it in my first post )
>
> I will get an error about invalid arguments.
>
> I can do it with the supplied ibtest tool.
> I found out that this tool is written in C.
> So it seems like my implementation of the Python-C interface is broken at this point.
>
> I am digging deep into all docs of C and Python and try to understand how the wrapping is done in detail.
>
> I tried to make a quick hack with gpinter.c which seems to be the place where the magic Python-C glueing is done.
>
> I did some copy&paste with the declartion of gpib_wait function.
>
> My copy looks like this
>
> /* joerg 1.9.2017 try to use waitsrq */
>
>
>
>
> static char gpib_waitsrq__doc__[] =
> "waitsrq -- wait for the SRQ event (board)\n"
> "waitsrq(handle)";
>
> static PyObject* gpib_waitsrq(PyObject *self, PyObject *args)
> {
> int device;
> int mask = SRQI;
> int result;
>
> if (!PyArg_ParseTuple(args, "i:waitsrq", &device))
> return NULL;
>
> Py_BEGIN_ALLOW_THREADS
> sta = ibwait(device, mask);
> Py_END_ALLOW_THREADS
>
> if(sta & ERR) {
> _SetGpibError("waitsrq");
> return NULL;
> }
>
> return PyInt_FromLong(sta);
> }
>
>
>
>
> /* waitsrq joerg */
>
> ./configure
> make
> make install
>
> i am getting no errors.
>
>
> But when i try to use the „new“ function:
> gpib.waitsrq(interface)
>
> i am getting an error
>
> AttributeError: 'module' object has no attribute 'waitsrq'
>
> I admit, that would have been too easy :-)
>
>
> So i need to dig some more….
>
>
> Any help is highly appreciated!
>
> Thanks
>
> Joerg
>
>
>
>> On 2. Sep 2017, at 16:03, Wilhelm Kusian <ku...@t-... <mailto:ku...@t-...>> wrote:
>>
>> Hi Joerg,
>>
>> I recognized that you are using Python to program your DMM. I do the same with a DMM Prema 6031 that also understands IEEE488.1 only.
>>
>> In order to wait for the SRQ I'm using the following commands:
>>
>> def measure():
>> gpib.serial_poll(DMM) # reset SRQ-Bit
>> gpib.write(DMM,"MR") # start measurement and display result (special for Prema 6031)
>> gpib.wait(interface, 0x1000) # wait for SRQ-Bit
>> x = gpib.read(DMM,13) # readout measurement result (13 characters are special for Prema 6031)
>> gpib.wait(interface, 0x100) # wait for I/O-Operation complete
>> return float(X)
>>
>> This function is called with
>> x = measure()
>>
>> In my case this works perfect. Hope that this will help you.
>>
>> Best regards
>> Wilhelm
>>
>>
>>
>> Am 30.08.2017 um 19:43 schrieb ve...@mi... <mailto:ve...@mi...>:
>>> What gpib card are you using?
>>>
>>> For waiting on SRQ, I usually do either this:
>>>
>>> -------------------------------
>>> ii = iblines(gpib,&clines);
>>> if(ii & ERR) {
>>> fprintf(stderr,"an error (%d) occurred in iblines.\n",iberr);
>>> }
>>>
>>> if(clines & BusSRQ)
>>> return 1;
>>>
>>> else
>>> return 0;
>>> -------------------------------
>>>
>>>
>>> or this:
>>>
>>>
>>> -------------------------------
>>> ss = 0;
>>> adr[0] = dev;
>>> adr[1] = NOADDR;
>>> ReadStatusByte(gpib,adr[0],&ss);
>>> fprintf(stderr,"ONE ADR: %d, Status: 0x%x\nibcnt: %d\n",
>>> adr[0],(int)ss,ibcnt);
>>>
>>> fprintf(stderr,"error variable: %d\nibsta: 0x%x\n",
>>> iberr,ibsta);
>>>
>>> if(iberr & 20) {
>>> fprintf(stderr,"No SRQ requested\n");
>>> return 0;
>>> }
>>> return (int)ss;
>>> -------------------------------
>>>
>>> The second one didn't work with some cards, mainly the non-NI cards.
>>>
>>> Vince.
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> i am trying to log data from an old DMM.
>>>> That device can only do IEEE488.1 standard.
>>>>
>>>> I am able to do almost all functions.
>>>>
>>>> I can send the ASCII strings to configure the device ( function, range ,
>>>> integration time, …. ) with gpib.write(instrument,“COMMAND“).
>>>>
>>>> I can read the result of a measurement with gpib.read(instrument).
>>>>
>>>> What i can not do ( at least on my linux-box ) is the programming to wait
>>>> for the SRQ ( service request ) event of the device.
>>>>
>>>> I need it because i am using long integration times ( 20s, 40s, 80s ) and
>>>> i dont want to set the timeout variable to such a long time.
>>>> So i think the cleanest way to program this is the wait_for_srq() function
>>>> which is not available in linux-gpib.
>>>>
>>>> On my winows notebook i have the pyvisa modul ( package? ) installed and i
>>>> can program it very nicely.
>>>>
>>>> while TRUE:
>>>> instrument.wait_for_srq()
>>>> print (instrument.read())
>>>>
>>>> It works perfectly.
>>>>
>>>> I thought that the wait() function of linux-gpib should give a similar
>>>> result when used properly.
>>>>
>>>> So i tried it in the Python shell:
>>>>
>>>> gpib.wait(interface,0x1000)
>>>> gpib.GpibError: wait() failed: One or more arguments to the function call
>>>> were invalid.
>>>>
>>>> gpib.wait(instrument,0x800)
>>>> ( this call will never return, i have to send CTRL-C )
>>>>
>>>> I checked with the ibtest tool and it looks like the bit is set
>>>>
>>>> get bus line status returns:
>>>> DAV off
>>>> NDAC on
>>>> NRFD off
>>>> IFC off
>>>> REN on
>>>> SRQ on
>>>> ATN on
>>>> EOI off
>>>> gpib status is:
>>>> ibsta = 0x1174 < SRQI CMPL REM CIC ATN LACS >
>>>>
>>>> when i serial poll the instrument the SRQ bit gets cleared.
>>>>
>>>> Am i having a very basic misunderstanding on how to implement this in
>>>> Python ( without Pyvisa )?
>>>>
>>>> Or is it just a bug in the Python version of linux-gpib?
>>>>
>>>> Any help is very much appreciated.
>>>>
>>>>
>>>> Best regards
>>>>
>>>> Joerg------------------------------------------------------------------------------
>>>> Check out the vibrant tech community on one of the world's most
>>>> engaging tech sites, Slashdot.org <http://slashdot.org/>!
>>>> http://sdm.link/slashdot_______________________________________________ <http://sdm.link/slashdot_______________________________________________>
>>>> Linux-gpib-general mailing list
>>>> Lin...@li... <mailto:Lin...@li...>
>>>> https://lists.sourceforge.net/lists/listinfo/linux-gpib-general <https://lists.sourceforge.net/lists/listinfo/linux-gpib-general>
>>>>
>>
>> ------------------------------------------------------------------------------
>> Check out the vibrant tech community on one of the world's most
>> engaging tech sites, Slashdot.org <http://slashdot.org/>! http://sdm.link/slashdot_______________________________________________ <http://sdm.link/slashdot_______________________________________________>
>> Linux-gpib-general mailing list
>> Lin...@li... <mailto:Lin...@li...>
>> https://lists.sourceforge.net/lists/listinfo/linux-gpib-general <https://lists.sourceforge.net/lists/listinfo/linux-gpib-general>
>
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot <http://sdm.link/slashdot>
> _______________________________________________
> Linux-gpib-general mailing list
> Lin...@li... <mailto:Lin...@li...>
> https://lists.sourceforge.net/lists/listinfo/linux-gpib-general <https://lists.sourceforge.net/lists/listinfo/linux-gpib-general>
>
>
|