2011-08-31 15 views
0

我在線獲取了一個通過rs232使用串口讀取的代碼,代碼使用readExisting()獲取數據(將數據組成一個MettlerToledo數據格式連接到com3,9600, 8,N,1)現在的問題是,我將其更改爲ReadLine(),但它捕獲了一次重量,我需要始終更新重量!有任何想法嗎?使用串口捕獲Mettler Toledo卡車秤的重量

回答

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 
相關問題