是德科技
直播中

孙榕

7年用户 216经验值
私信 关注
[问答]

怎么将文件从ENA复制到PC(VC ++)

嗨,我正在使用Agilent ENA5061B网络分析仪。
我正在使用从PC到ENA的远程GPIB-USB-B连接,我使用Visual C ++将它们连接起来。
一切正常,我能够测量我的S11数据并将其写入ENA硬盘D:驱动器上的.csv文件。
我需要为我的项目做两件事:1)测量完成后,将.csv文件从ENA直接写到我的电脑上。
2)将写在ENA硬盘上的.csv文件传输到我的PC。
任何人都可以帮我一个VC ++代码,可以做到这一点?
我可以将代码附加到我的代码中。
提前致谢。

以上来自于谷歌翻译


     以下为原文

  Hi,

I am using the Agilent ENA5061B Network analyzer. I am using a remote GPIB-USB-B connection from my PC to ENA and I am using Visual C++ to connect them both. Everything works fine and I am able to measure my S11 data and write it into a .csv file on the ENA's hardisk D: drive. I need to be able to do two things for my project:

1) Write the .csv file directly onto my PC from the ENA when the measurement is done.

2) Transfer the .csv file written on the ENA's hardrive to my PC.

Can anyone help me with a VC++ code which can do this? I can append the code to mine.

Thanks in advance.  

回帖(9)

孙榕

2018-12-12 16:16:13
我已经开始尝试使用:MMEM:TRAN和:MMEM:COPY但它似乎不起作用。
它看起来像这样://测量viWrite(vi,(ViBuf)“:CALC1:PAR1:DEF S11  n”,20,& retcnt);
//存储测量数据viWrite(vi,(ViBuf)“:MMEM:STOR:FDAT'ramtry.csv' n”,33,& retcnt);
viWrite(vi,(ViBuf)“:MMEM:COPY'ramism.csv','C: ram1.csv' n”,38,& retcnt);
/ *关闭会话* / viClose(vi);
viClose(defaultRM);

以上来自于谷歌翻译


     以下为原文

  I have already gone ahead and tried using :MMEM:TRAN and :MMEM:COPY but it does not seem to work. It looks like this:

//Measurement 
viWrite(vi,(ViBuf)":CALC1:PAR1:DEF S11n",20, &retcnt);
//Storing measurement data
viWrite(vi,(ViBuf)":MMEM:STOR:FDAT 'ramtry.csv'n",33, &retcnt);

viWrite(vi, (ViBuf)":MMEM:COPY 'ramtry.csv','C:ram1.csv'n",38,&retcnt);
/* Close session */
viClose (vi);
viClose (defaultRM);
举报

郑静东

2018-12-12 16:35:50
引用: hfjydz2013 发表于 2018-12-12 08:20
我已经开始尝试使用:MMEM:TRAN和:MMEM:COPY但它似乎不起作用。
它看起来像这样://测量viWrite(vi,(ViBuf)“:CALC1:PAR1:DEF S11  n”,20,& retcnt);
//存储测量数据viWrite(vi,(ViBuf)“:MMEM:STOR:FDAT'ramtry.csv' n”,33,& retcnt);

嗨,我有一个例子来转储图像文件并从PNA复制它,ENA的命令非常相似。
FileStream output = new FileStream(filePath,FileMode.Create);
BinaryWriter writer = new BinaryWriter(output);
string str6 = @“C: tmppnascreen.png”;
string str =“DISP:ANN:MESS:STAT OFF”;
ioDmm.WriteString(STR);
str =“HCOP:FILE ”“+ str6 +”“”;
//从PNA转储图像,您应该更改代码以将数据文件保存到ENA ioDmm.WriteString(str);
OPC();
str =“MMEM:TRAN?”“+ str6 +”“”;
ioDmm.WriteString(STR);
string str5 = ioDmm.IO.ReadString(1);
int count = Convert.ToInt32(ioDmm.IO.ReadString(1));
int num2 = Convert.ToInt32(ioDmm.IO.ReadString(count));
byte [] buffer = new byte [num2 + 1];
buffer =(byte [])ioDmm.IO.Read(num2);
writer.Write(缓冲液);
writer.Close();
output.Close();
str =“DISP:ANN:MESS:STAT ON”;
ioDmm.WriteString(STR);

以上来自于谷歌翻译


     以下为原文

  Hi, I have an example to dump image file and copy it from the PNA, the command for ENA is very similar.

FileStream output = new FileStream(filePath, FileMode.Create);
            BinaryWriter writer = new BinaryWriter(output);
            string str6 = @"C:tmppnascreen.png";
            string str = "DISP:ANN:MESS:STAT OFF";
            ioDmm.WriteString(str);

            str = "HCOP:FILE "" + str6 + """; //dump image from PNA, you should change your code to save the data file to ENA
            ioDmm.WriteString(str);

            OPC();

            str = "MMEM:TRAN? "" + str6 + """;
            ioDmm.WriteString(str);

            string str5 = ioDmm.IO.ReadString(1);
            int count = Convert.ToInt32(ioDmm.IO.ReadString(1));
            int num2 = Convert.ToInt32(ioDmm.IO.ReadString(count));
            byte[] buffer = new byte[num2 + 1];
            buffer = (byte[])ioDmm.IO.Read(num2);
            writer.Write(buffer);
            writer.Close();
            output.Close();
            str = "DISP:ANN:MESS:STAT ON";
            ioDmm.WriteString(str);
举报

孙榕

2018-12-12 16:41:15
引用: 平凡的世界12 发表于 2018-12-12 08:40
嗨,我有一个例子来转储图像文件并从PNA复制它,ENA的命令非常相似。
FileStream output = new FileStream(filePath,FileMode.Create);
BinaryWriter writer = new BinaryWriter(output);

Hi Ningchen,

Thank you for the help. When I run your code what changes do I probably have to make because it says the following errors. Is there like a separate function named 'Filestream' and 'Binarywriter' that you wrote which it is referrring to? If so can you add that as well? Thanks in advance.

Cheers
Ram


gpibinternew.cpp(136): error C2065: 'FileStream' : undeclared identifier
1>gpibinternew.cpp(136): error C2146: syntax error : missing ';' before identifier 'output'
1>gpibinternew.cpp(136): error C2065: 'output' : undeclared identifier
1>gpibinternew.cpp(136): error C2061: syntax error : identifier 'FileStream'
1>gpibinternew.cpp(137): error C2065: 'BinaryWriter' : undeclared identifier
1>gpibinternew.cpp(138): error C2065: 'string' : undeclared identifier
1>gpibinternew.cpp(138): error C2146: syntax error : missing ';' before identifier 'str6'
1>gpibinternew.cpp(138): error C2065: 'str6' : undeclared identifier
1>gpibinternew.cpp(138): error C2018: unknown character '0x40'
1>gpibinternew.cpp(138): warning C4129: 'h' : unrecognized character escape sequence
1>gpibinternew.cpp(139): error C2065: 'string' : undeclared identifier
1>gpibinternew.cpp(139): error C2146: syntax error : missing ';' before identifier 'str'
1>gpibinternew.cpp(139): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(140): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(140): error C2228: left of '.WriteString' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(140): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(142): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(142): error C2065: 'str6' : undeclared identifier
1>gpibinternew.cpp(143): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(143): error C2228: left of '.WriteString' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(143): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(145): error C3861: 'OPC': identifier not found
1>gpibinternew.cpp(147): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(147): error C2065: 'str6' : undeclared identifier
1>gpibinternew.cpp(148): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(148): error C2228: left of '.WriteString' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(148): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(150): error C2065: 'string' : undeclared identifier
1>gpibinternew.cpp(150): error C2146: syntax error : missing ';' before identifier 'str5'
1>gpibinternew.cpp(150): error C2065: 'str5' : undeclared identifier
1>gpibinternew.cpp(150): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(150): error C2228: left of '.IO' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(150): error C2228: left of '.ReadString' must have class/struct/union
1>gpibinternew.cpp(151): error C2065: 'Convert' : undeclared identifier
1>gpibinternew.cpp(151): error C2228: left of '.ToInt32' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(151): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(151): error C2228: left of '.IO' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(151): error C2228: left of '.ReadString' must have class/struct/union
1>gpibinternew.cpp(152): error C2065: 'Convert' : undeclared identifier
1>gpibinternew.cpp(152): error C2228: left of '.ToInt32' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(152): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(152): error C2228: left of '.IO' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(152): error C2228: left of '.ReadString' must have class/struct/union
1>gpibinternew.cpp(153): error C2065: 'byte' : undeclared identifier
1>gpibinternew.cpp(153): error C2059: syntax error : ']'
1>gpibinternew.cpp(154): error C2065: 'buffer' : undeclared identifier
1>gpibinternew.cpp(154): error C2065: 'byte' : undeclared identifier
1>gpibinternew.cpp(154): error C2059: syntax error : ']'
1>gpibinternew.cpp(155): error C2065: 'writer' : undeclared identifier
1>gpibinternew.cpp(155): error C2228: left of '.Write' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(155): error C2065: 'buffer' : undeclared identifier
1>gpibinternew.cpp(156): error C2065: 'writer' : undeclared identifier
1>gpibinternew.cpp(156): error C2228: left of '.Close' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(157): error C2065: 'output' : undeclared identifier
1>gpibinternew.cpp(157): error C2228: left of '.Close' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(158): error C2065: 'str' : undeclared identifier
1>gpibinternew.cpp(159): error C2065: 'ioDmm' : undeclared identifier
1>gpibinternew.cpp(159): error C2228: left of '.WriteString' must have class/struct/union
1>          type is ''unknown-type''
1>gpibinternew.cpp(159): error C2065: 'str' : undeclared identifier
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
举报

郑静东

2018-12-12 17:00:51
引用: hfjydz2013 发表于 2018-12-12 08:45
Hi Ningchen,

Thank you for the help. When I run your code what changes do I probably have to make because it says the following errors. Is there like a separate function named 'Filestream' and 'Binarywriter' that you wrote which it is referrring to? If so can you add that as well? Thanks in advan ...

嗨,代码在C#中。
您可以在C#控制台应用程序中尝试它。
之后您可能需要将其转换为C ++。

以上来自于谷歌翻译


     以下为原文

  Hi, the code is in C#. You can try it in C# console application. You may need to translate it to C++ after that.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分