serialport 简单的串口通信 的例子 求
本人 ,, 刚刚开始学 求教
[解决办法]
'触发接收事件
Public Sub Sp_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Me.Invoke(New EventHandler(AddressOf Sp_Receiving)) '调用
End Sub
'接收数据
Private Sub Sp_Receiving(ByVal sender As Object, ByVal e As EventArgs)
Dim strIncoming As String
Try
If SerialPort1.BytesToRead > 0 Then
'strIncoming = SerialPort1.ReadExisting.ToString '读取缓冲区中的数据
strIncoming = SerialPort1.ReadLine.ToString
SerialPort1.DiscardInBuffer()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
[解决办法]
我也是急需啊,大神们快来啊^_^