我在网上通过rs232使用串口读取代码,代码使用readExisting()来获取数据(在com3,9600,8,N,1处连接MettlerToledo规模的数据)问题现在是我将它改为ReadLine(),但它捕获了一次重量,我需要一直更新重量!有任何想法吗?
答案 0 :(得分:0)
您可以使用某种形式的循环
While someBoolean
'Read the serial port
End While
我建议把它放在BackGroundWorker上,以免中断主线程
或者您可以使用计时器
Dim weightTimer As Timer = new Timer(100) 'pick either the threading or the Forms timer depending
'Using the Forms timer for the example
'Handle the timer tick event
Private Sub weightTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles weightTimer.Tick
'Read the Serial Port
End Sub