如何在通过串口从称重机读取时停止连续流 [英] How to stop continuous stream while reading from a weighing machine through serial port

查看:100
本文介绍了如何在通过串口从称重机读取时停止连续流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

使用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();


这篇关于如何在通过串口从称重机读取时停止连续流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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