如何在通过串口从称重机读取时停止连续流

编程入门 行业动态 更新时间:2024-10-09 15:14:52
本文介绍了如何在通过串口从称重机读取时停止连续流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好,

使用C#我通过串口读取称重机的读数。

Using C# I read the readings from a weighing machine through serial port.

读数为

我调试并看到它接受/ n / r

While I debug and saw it taking /n/r

在文本框中我可以看到如下连续流。但是我只需要将重量作为单个数字,并且它必须根据重量机器波动。

In the textbox I can see like the below continuous streams. But I need to get only the weight as single number and also it must fluctuate according to the weight machine.

请帮助我如何实现这个

我使用了SerialPort.ReadExisting()来捕获这个,我得到如下所示

I used SerialPort.ReadExisting() to capture this and I am getting like below

0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0

谢谢

记住过去的挑战未来"

推荐答案

看来每个weigt的结尾都是一个返回。所以一次读一行

It appears the end of each weigt is a return. So read one line at a time

port.ReadLine() ;

port.ReadLine();

更多推荐

如何在通过串口从称重机读取时停止连续流

本文发布于:2023-06-03 07:02:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/471194.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连续流   串口   重机   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!