Posted Tue, 13 Feb 2024 11:33:59 GMT by RU, Rmj
I have a function to get Osciloscope screenshot.
Following is my code segment:
                    string visaRsrcAddr = "TCPIP0::" + IP.ToString() + "::inst0::INSTR";
                    var scope = GlobalResourceManager.Open(visaRsrcAddr) as IMessageBasedSession;
                    using (scope)
                    {
                        scope.TimeoutMilliseconds = 60000;
                        scope.FormattedIO.WriteLine("SAVE:IMAGe \"eval.png\"");

                        scope.FormattedIO.WriteLine("*OPC?");

                        ((IMessageBasedSession)(scope)).TerminationCharacterEnabled = false;
                        scope.FormattedIO.WriteLine("FILESystem:READFile \"eval.png\"");

                        byte[] imgData = new byte[30000000];
                        // Giving a large value for count to make sure all bytes are read.
                        imgData = scope.RawIO.Read(30000000);
                        scope.FormattedIO.WriteLine("*OPC?");

This is throwing Timeout exception very often. What could be the reason?

Thanks in advance,
Reena
                        // Save image data to local disk
                        File.WriteAllBytes(fileName, imgData);

                        // Image data has been transferred to PC and saved. Delete image file from instrument's hard disk.
                        scope.FormattedIO.WriteLine("FILESystem:DELEte \"eval.png\"");
 
Posted Tue, 27 Feb 2024 23:06:56 GMT by Teles, Afonso
Hi,

A long read inherently takes a long time, so you'll want to either increase your timeout time or handle the error and keep reading (or both).

You must be signed in to post in this forum.