本文介绍了我正在尝试使用realterm与硬件流量控制设置为“RS 485-rts”来通信控制板。如何在Windows串口实现它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码,
port.Parity = Parity.None;
port.DataBits = 8;
port.StopBits = StopBits.One;
port.Encoding = System.Text.Encoding.ASCII;
port.Name =COM1;
port.BaudRate = 9600;
port.DataReceived + = Port_DataReceived;
在向Board发送命令时,
port.RtsEnable = true;
port.Write(System.Text.Encoding.ASCII.GetBytes(dataToSend),0,dataToSend.Length);
Thread.Sleep(15);
port.RtsEnable = false;
我尝试过:
我尝试过使用RealTerm,而且我一直得到正确的响应,我也从上面的代码得到了正确的答案,但有些时候它的返回垃圾不是从RealTerm发送时的情况。
解决方案
I'm using below codes,
port.Parity = Parity.None; port.DataBits = 8; port.StopBits = StopBits.One; port.Encoding = System.Text.Encoding.ASCII; port.Name ="COM1"; port.BaudRate=9600; port.DataReceived += Port_DataReceived;
And while sending commands to Board,
port.RtsEnable = true; port.Write(System.Text.Encoding.ASCII.GetBytes(dataToSend), 0, dataToSend.Length); Thread.Sleep(15); port.RtsEnable = false;
What I have tried:
I have tried using RealTerm, and I'm getting correct response all the time, I'm also getting correct response from above codes but some of the time its returning garbage which is not a case while sending from RealTerm.
解决方案
这篇关于我正在尝试使用realterm与硬件流量控制设置为“RS 485-rts”来通信控制板。如何在Windows串口实现它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!