在 C# 中更改波特率而不关闭连接 [英] Change baud rate in C# without closing connection

查看:127
本文介绍了在 C# 中更改波特率而不关闭连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了与以下链接类似的问题.如何在不关闭连接的情况下更改波特率?.但我使用 C# 代替 java.我从波特率 300 开始.然后在握手后我必须将波特率更改为 4800.我向设备发送命令来执行此操作.我更改了串行端口的波特率.在那之后,我永远无法继续与设备进行通信.(如果我保持在 300 波特并向设备发送 300 波特的命令,我可以继续通信)

I have a similar problem to the following link. How to change baud rate without closing the connection?. But i use C# in stead of java. I am beginning with baud rate 300. Then after a hand shake i have to change my baud rate to 4800. I send a command to the device to do this. And I change my serialport's baud rate. After that i can never continue the communication with the device. (If i stay in 300 baud and send command to the device for 300 baud i can continue the communication)

我有一个第三方软件也可以从该设备读取数据.当该软件运行时,我正在侦听端口.它发送与我发送到设备相同的命令.它向设备发送设置 4800 波特的命令,并可以从设备获得应答.它不会在波特率更改期间关闭或重新打开端口.我必须做同样的事情.但是,当我发送更改为 4800 波特的命令时,我始终没有得到设备的答复.

I have a third party software which also reads from this device. I am listening the port when that software is running. It sends the same commands that i am sending to the device. It sends command to set 4800 baud to the device and can get the answer from the device. It does not close or reopen the port during baud change. I have to do the same thing. But when i send command to change to 4800 baud i get no answer from the device ever.

我在等你的答案.谢谢,联邦调查局

I am waiting for your answers. Thank you, FERDA

这是串口监控程序的输出进程ReadY.vshost.exe"打开的端口(PID:2608)

This is the output from serial port monitoring program Port opened by process "ReadY.vshost.exe" (PID: 2608)

01 42 30 03 71 .B0.q

01 42 30 03 71 .B0.q

答案:09.08.2011 10:55:40.81864(+0.2656 秒)

Answer: 09.08.2011 10:55:40.81864 (+0.2656 seconds)

06.

请求:09.08.2011 10:55:41.06864(+1.2500 秒)

Request: 09.08.2011 10:55:41.06864 (+1.2500 seconds)

2F 3F 31 31 39 39 39 30 30 34 21 0D 0A/?11999004!...

2F 3F 31 31 39 39 39 30 30 34 21 0D 0A /?11999004!..

答案:09.08.2011 10:55:41.58464(+0.5156 秒)

Answer: 09.08.2011 10:55:41.58464 (+0.5156 seconds)

2F 53 54 52 34 5F 42 53 4D 31 33 31 0D 0A/STR4_BSM131..

2F 53 54 52 34 5F 42 53 4D 31 33 31 0D 0A /STR4_BSM131..

请求:09.08.2011 10:55:42.31864(+0.2969 秒)

Request: 09.08.2011 10:55:42.31864 (+0.2969 seconds)

06 30 34 31 0D 0A .041..

06 30 34 31 0D 0A .041..

推荐答案

根据我的经验,波特率开关需要关闭并重新打开串行端口硬件:我建议尝试这样做.发送波特率切换命令关闭端口,设置波特率后重新打开端口.打开/关闭端口应该对另一端的设备透明(除非您使用 CTS/RTS/DTR/DSR 线路).

In my experience baud rate switches require closing and reopening the serial port hardware: I would suggest trying that. Send the baud rate switch command then close the port, set the baud rate and then re-open the port. Opening/closing the port should be transparent to the device on the other side (unless you are using the CTS/RTS/DTR/DSR lines).

这篇关于在 C# 中更改波特率而不关闭连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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