AnsweredAssumed Answered

VEE's WRITE BINBLOCK in c

Question asked by ceken on Aug 23, 2010
Latest reply on Aug 24, 2010 by changmeikuan
Hi All,
I don't know is this forum correct  for my question, sorry for taking time but I need help for the following question:

I have been trying to download IQ data to E4438C over LAN using C#. If I use vee(There is an example in vee's example folder) and MATLAB, download is OK, but when I try to download using c# download is not successful. Because, although there is a data download UI on Signal Generator, Progress Bar remains at %0 and some time later it disappears without completing the download.
I think I have to implement MATLAB's "binblockwrite(...)" or VEE's "WRITE BINBLOCK Int16" command in C#. Is anyone out there who did that before?
Here is my C# Code
StreamWriter sr = new StreamWriter(Directory.GetCurrentDirectory() + "/IQData.txt");
            const int NUMSAMPLES = 500;
            byte[] iqBuffer = new byte[NUMSAMPLES * 4];
            short[] idata = new short[NUMSAMPLES];
            short[] qdata = new short[NUMSAMPLES];
            short ivalue;
            short qvalue;

            int numsamples = NUMSAMPLES;
            for (int index = 0; index < numsamples; index++)
            {
                idata&#91;index&#93; = (short)(23000 * Math.Sin((2 * 3.14 * index) / numsamples));
                qdata&#91;index&#93; = (short)(23000 * Math.Cos((2 * 3.14 * index) / numsamples));
            }


            for (int index = 0; index < numsamples; index++)
            {
                sr.Write(idata&#91;index&#93; + " ");
                sr.WriteLine(qdata&#91;index&#93;);
                sr.Flush();
            }
            sr.Close();

            for (int index = 0; index < numsamples; index++)
            {
                ivalue = idata&#91;index&#93;;
                qvalue = qdata&#91;index&#93;;
                iqBuffer&#91;index * 4&#93; = (byte)((ivalue >> 8) & 0xFF);
                iqBuffer&#91;index * 4 + 1&#93; = (byte)(ivalue & 0xFF);
                iqBuffer&#91;index * 4 + 2&#93; = (byte)((qvalue >> 8) & 0xFF);
                iqBuffer&#91;index * 4 + 3&#93; = (byte)(qvalue & 0xFF);
            }
           
           String iqBufferStr = System.Text.Encoding.UTF8.GetString(iqBuffer);
           
            write(":MMEM:DATA \"WFM1:myDataDosya\",#" + iqData.Length.ToString().Length + iqData.Length + g);


Regards
Cengiz EKEN  

Outcomes