Hello,
I am trying to run timed sweeps with an DAQ970A connected via Ethernet using C#. I've included the following libraries:
C:\Program Files (x86)\IVI Foundation\VISA\Microsoft.NET\Framework32\v2.0.50727\VISA.NET Shared Components 5.11.0\Ivi.Visa.dll
C:\Program Files (x86)\IVI Foundation\VISA\Microsoft.NET\Framework32\v4.0.30319\NI VISA.NET 19.0\NationalInstruments.Visa.dll
According to my understanding, the best approach would be using Events from an activated ServiceRequest. However, I cannot get it to work. This is my code (for testing I've connected it to an USB port as I cannot disable the firewall on my dev laptop):
using Ivi.Visa;
using NationalInstruments.Visa;
MessageBasedSession _session;
private void SessionOnServiceRequest(object sender, VisaEventArgs e)
{
StatusByteFlags sb = _session.ReadStatusByte();
Console.WriteLine(sb);
}
void main()
{
_session = new UsbSession("USB0::0x2A8D::0x5001::MY58002830::INSTR", AccessModes.None, 1000);
_session.FormattedIO.WriteLine("*RST");
_session.FormattedIO.WriteLine("*CLS");
_session.FormattedIO.WriteLine("SYSTem:REMote");
_session.FormattedIO.WriteLine("CONF:RES 1E6,DEF, (@101:140)");
_session.FormattedIO.WriteLine("FORM:READ:CHAN ON");
_session.FormattedIO.WriteLine("FORM:READ:TIME OFF");
_session.FormattedIO.WriteLine("FORM:READ:UNIT OFF");
_session.FormattedIO.WriteLine("TRIG:SOUR TIMER");
_session.FormattedIO.WriteLine("TRIG:COUN INF");
_session.FormattedIO.WriteLine("TRIG:TIM 30");
_session.FormattedIO.WriteLine("ROUT:SCAN (@101:140)");
_session.ServiceRequest += SessionOnServiceRequest;
_session.FormattedIO.WriteLine("*SRE 16");
_session.FormattedIO.WriteLine("*SRE?");
var resp = _session.FormattedIO.ReadLine().Trim();
//In Debugger, resp contains "+16"
_session.FormattedIO.WriteLine("INIT");
//endless loop here waiting for user to abort
}
The event is fired two times, the first time sb is set to RequestingService, the second time it is set to 0. That both occurs before the INIT command. However, after that the event is never fired again even after multiple sweeps.
Am I missing something here?
Best regards
Manuel