Hi All,
We decided to rewrite our huge calibration program to NI-VISA .NET platform. Before start I created simple Project which has only one Counter (Keysight 53230A). We want to use ServiceRequest event of MessageBasedSession object.
We use below code for creating counter object.
counter = (MessageBasedSession)ResourceManager.GetLocalManager().Open("GPIB0::17::INSTR"); counter.Timeout = GpibInterface.InfiniteTimeout; counter.ServiceRequest += Counter_ServiceRequest; counter.EnableEvent(MessageBasedSessionEventType.ServiceRequest, EventMechanism.Handler);
//this starts new measurement and trigger SRQ when finish counter.Write("*CLS; *ESE 1; *SRE 32; INIT:IMM; *OPC");
When I run the program it reaches Service Request sub program and freezes at ReadStatusByte() line. If I omit this line, program reads data from counter and starts new measurements but ServiceRequest sub program does not call again.
private void Counter_ServiceRequest(object sender, MessageBasedSessionEventArgs e) { MessageBasedSession mb = sender as MessageBasedSession; if (mb != null) { //Program freezes this point //If omit this line, service request function does not run again StatusByteFlags sb = mb.ReadStatusByte(); listBox1.Items.Add(mb.Query("FETCH?")); mb.Write("*CLS; INIT:IMM; *OPC"); //Restart measurement... } }
I tried AutoSerialPoll On or Off and results are same. I updated NI-VISA to 17.5 which is latest version.
Any idea?
Best regards,
Adem