Salve,
Ho scaricato un programmino che gestisce la porta seriale rs232
Tutto funziona ma la lettura del buffer di ingresso viene fatta mediante la pressione di un pulsante in questo modo:
Io vorrei sapere come leggere il dato di continuo...Codice PHP:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRx.Click
Try
moRS232.Read(Int32.Parse(txtBytes2Read.Text))
txtRx.Text = moRS232.InputStreamString
txtRx.ForeColor = Color.Black
txtRx.BackColor = Color.White
'// Fills listbox with hex values
Dim aBytes As Byte() = moRS232.InputStream
Dim iPnt As Int32
For iPnt = 0 To aBytes.Length - 1
lbHex.Items.Add(iPnt.ToString & ControlChars.Tab & String.Format("0x{0}", aBytes(iPnt).ToString("X")))
Next
Catch Ex As Exception
txtRx.BackColor = Color.Red
txtRx.ForeColor = Color.White
txtRx.Text = "Error occurred " & Ex.Message & " data fetched: " & moRS232.InputStreamString
End Try
End Sub
o meglio vorrei che quando arriva qualcosa sulla seriale questa stringa viene messa in una textbox
Grazie.
Tony

Rispondi quotando