如何将从串口接收到的数据流式传输到C#表单
我想将我的 arduino 给出的数据打印成 C# 形式(可能是 Richtextbox)。我能够连接串行端口,但我当前的代码仅给出最后的打印值。我想以垂直流的方式打印它,就像arduino软件的串行监视器中显示的那样。怎么做呢?
我目前的代码:
private void settext(string val)
{
richTextBox1.Text = val;
}
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string incomstring = serialPort1.ReadLine();
settext(incomstring);
}
我试图以 C# 形式实现的图像(检查串行监视器):
I want to print into c# form (into Richtextbox maybe) the data being given by my arduino. I am able to connect tjhe serial port, but my current code is giving just the last printed value. I want to print it in the vertical stream the way it is shown in Serial Monitor of arduino software. How to do it?
My code presently:
private void settext(string val)
{
richTextBox1.Text = val;
}
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string incomstring = serialPort1.ReadLine();
settext(incomstring);
}
The image (check the serial monitor) of what I am trying to achieve in my C# form:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论