如何使用Lxi spci_raw和TcpClient发送二进制数据 [英] How to send binary data using Lxi spci_raw with TcpClient

查看:97
本文介绍了如何使用Lxi spci_raw和TcpClient发送二进制数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能不是一个纯粹的c#问题,但也许有人也有类似的问题。



我使用Lxi( http://www.lxistandard.org/About/LXI-Protocols.aspx )与安捷伦电源,示波器等进行通信......



有几种方法可以做到这一点,但最简单的方法是使用SPCI(一种简单的命令协议),在我的情况下使用TcpClient。



所以我在端口5025上使用TcpClient和NetworkStream我可以用字符串命令(例如* IDN?)来做到这一点。

我也可以从设备请求二进制数据(一大块XML数据),但发回它似乎不起作用。 (这例如与范围一起用作设置字符串学习字符串)



因此,如果有人有这方面的经验并且已经使它已经工作了对我来说会有很大的帮助。



谢谢。

彼得

解决方案

< blockquote>我现在正在使用它。我早一点发布了我的问题。 :-)



但无论如何它的解决方案:

似乎有必要在需要的二进制数据之后发送换行符要发送。所以SPCI命令就是完整的形式:



[SPCI命令] [空间] [BINARY HEADER] [二进制数据] [Linefeed]



一个例子是:



:SYST:SET#800083042< setup prod =InfiniiVision ver =02.35.2013061800srver =2.0> ...模式数据... 





定义的标题大小必须是最后排除Linefeed的二进制数据的长度。

(标题信息请参阅: http://cp.literature .agilent.com / litweb / pdf / ads2001 / vee6at / appxA10.html



将整个字符串转换为8位字节数组并发送。



我不知道这是否适用于所有Lxi设备,但它适用于DSO 3034A。

所以我学到的是基本上你将带有标题的整个二进制数据块封装到SPCI字符串命令中,这意味着在结尾处包含指示命令结束的换行符。


This may not be a pure c# question but maybe someone also has a similar problem.

I use Lxi (http://www.lxistandard.org/About/LXI-Protocols.aspx) to communicate with for example Agilent power supplies, scopes etc...

There are several ways to do this, but the most easy way is to use SPCI (a "simple" commands protocol) and in my case using a TcpClient.

So I use a TcpClient and a NetworkStream on port 5025 I can do that with string commands (for example "*IDN?").
I can also request "binary" data (A big chunk of XML data) from the device, but sending it back seems not to work. (This is for example used with scopes as a settings string "learn string")

So if there are people who have experience with this and have made this already work it would be a great help for me.

Thanks.
Peter

解决方案

I had it working now. I posted my question a little to early. :-)

But anyway here it the solution :
It seemed that it is necessary to send a linefeed after the binary data that needs to be send. So the SPCI command would be in it's complete form :

[SPCI COMMAND][Space][BINARY HEADER][BINARY DATA][Linefeed]

An example would be :

:SYST:SET  #800083042<setup prod="InfiniiVision" ver="02.35.2013061800" srver="2.0"> ...mode data... 



The defined header size must be the length of the binary data excluded the Linefeed at the end.
(header info see : http://cp.literature.agilent.com/litweb/pdf/ads2001/vee6at/appxA10.html)

Convert the whole string then to a 8bit bytes array and send it.

I don't know if this will work for all Lxi devices but it did work for a DSO 3034A.
So what I learned is that basically you enclose the whole binary data block with header into a SPCI "string" command, that means including the linefeed at the end that indicates the end of the command.


这篇关于如何使用Lxi spci_raw和TcpClient发送二进制数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆