IO.Ports.SerialPort 连接失败
我使用.net框架(2.0)开发一个软件。我使用串行端口与多个设备进行通信,没有任何问题。
但是,我尝试与新的通信,但无法写入或读取任何命令。
在尝试使用我的软件进行任何通信之前,我会使用 Hilgraeve 的超级终端对其进行测试。因此,使用此软件,如果我发送*IDN?抛出串行端口,设备会切换到远程模式并回答类似ANRITSU,MS9710A,V1.20383的内容。所以使用的参数看起来不错。
但是,当我尝试使用 .net 框架中的 IO.Ports.SerialPort 时,无法进行通信。经过多次测试,我可以说:
问题似乎出在 Write 函数上,因为当我使用MyPort.Write("*IDN?") 时,缓冲区上似乎没有写入任何内容。我这么说是因为设备没有切换到远程模式。
超级终端和我的 IO.Ports.SerialPort 之间的所有(可见)参数都相同:9600 bps,8-N-1,无握手。 IO.Ports.SerialPort 的缓冲区大小具有默认值。
我已经通过谷歌测试了其他几个.net应用程序,但没有人能够与设备通信,在MS将IO.Ports.SerialPort添加到框架之前,我还使用框架1.1测试了软件。
所以我的结论是问题来自 IO.Ports.SerialPort,但我不知道问题是什么。我有一些线索:
当速度低于 19200bps(在我的情况下最大为 9600bps)时,IO.Ports.SerialPort 无法进行通信。我想因为与我通信没有任何问题的所有其他设备的速度至少为 19200bps(编辑:我发现了一个以 9600bps 工作的其他设备,并且我使用我的软件与它进行通信,所以问题来自另一点)
有一个参数我没见过可以解决问题
下一个版本的框架吗(3.0、3.5 或 4.0)可能有帮助吗?我没有找到任何有关用上一个版本更新 IO.Ports.SerialPort 类的文档。
那么您对这个问题有什么想法吗?以前有人遇到过这种问题吗?
更多信息:该软件是在 Win 7 上使用 vb.net 和 VS 2010 开发的。我还在有问题的设备上测试了 GPIB 通信,没有问题,但如果可能的话,我宁愿不使用 GPIB 协议。
感谢您的帮助。
I develop a software using .net framework (2.0). I communicate with several devices using serial port without any problem.
However, I try to communicate with a new one, but impossible to write or read any command.
Before try any communication using my software, I test it before with HyperTerminal from Hilgraeve. So with this soft if I send *IDN? throw the serial port, the device switch to remote mode and answer something like ANRITSU,MS9710A,V1.20383. So parameters used seem good.
But, when I try to use IO.Ports.SerialPort from the .net framework, impossible to communicate. After many test I can say :
It seem the problem comes from the Write function, because nothing seems to be written on the buffer when I use MyPort.Write("*IDN?"). I say that because the device doesn't switch to remote mode.
All (visible) parameters are the same between HyperTerminal and my IO.Ports.SerialPort : 9600 bps, 8-N-1, no handshaking. Buffers size of IO.Ports.SerialPort have the default value.
I've tested several other .net application find with google and no one are able to communicate with the device, I've also tested soft using framework 1.1 before MS add the IO.Ports.SerialPort to the framework.
So my conclusion is the problem come from the IO.Ports.SerialPort, but I don't know what is the problem. I have some clue :
IO.Ports.SerialPort are not able to communicate when the speed is lower than 19200bps (9600 max in my case). I suppose that because all other devices with which I communicate without any problem have a speed of 19200bps minimum (edit : I've found an other device which work at 9600bps, and I arrive to communicate with it using my software, the problem comes from an other point)
There is one parameter that I haven't seen which can solve the problem
Does next version of the framework (3.0, 3.5 or 4.0) may help ? I don't find any documentation about update of IO.Ports.SerialPort class with last version.
So have you any idea about this problem ? Anybody have been had this kind of problem before ?
More some information : the soft is developed using vb.net with VS 2010 on Win 7. I've also tested GPIB communication on the problematic device without problem, but I prefer not use GPIB protocol if possible.
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论