I need to use autopolling so my instrument can
call back and tell me when it has finished a measurement. I had code
to do this that worked fine, but it now seems to have stopped working.
Not being sure what all I might of changed, I've contructed the
following simple example (in VB.NET) to demonstrate the problem. When
I run this, the dataReady function never gets called. I've run a
concurrent session of the interactive control tool so I can do manual
serial polls, and found that the instrument is indeed issuing a service
request, but this is somehow not causing dataReady to get called. It
seems like automatically serial polling isn't happening, but the board
properties form in MAX shows that autopolling is supposedly enabled. I
have tried restarting the intrument, my computer, and running the
repair on the NI .NET libraries and NI-488.2 2.4 drivers from the
installer. I'm at a complete loss as to what is wrong. Any
suggestions would be much appreciated.
Weirdly,
I've found that if I let the program complete and the waitOne call
timeout, when I run the program again, the dataReady function is called
as soon as I call Notify and before the measurement is even started.
(Not sure if this is the appropriate forum for this question)
Module Module1 Sub Main() Dim dataReadyD As New NotifyCallback(AddressOf dataReady) Dim lock As New AutoResetEvent(False)
Dim analyser As New Device(0, 17) analyser.Write("*CLS") analyser.Notify(GpibStatusFlags.DeviceServiceRequest, dataReadyD, lock) analyser.Write("*ESE 1") 'Enable reporting of operation complete in standard event status analyser.Write("*SRE 32") 'Trigger SRQ when a standard event status event occurs analyser.Write("AGE:SCON:SING") 'Trigger measurement analyser.Write("*OPC") 'Raise operation complete event in standard event status register 'when measurement completes lock.WaitOne(100000, False) End Sub
Private Sub dataReady(ByVal sender As Object, ByVal notifyData As NotifyData) Dim theDevice As Device = CType(sender, Device) theDevice.SerialPoll() Dim theLock As AutoResetEvent = CType(notifyData.UserData, AutoResetEvent) theLock.Set() End Sub End Module