同时读取多个串口

时间:2015-06-05 06:55:33

标签: mysql vb.net arduino rfid

我正在研究基于RFID通过arduino通过串口发送到VB.net的数据的考勤系统项目

 Private Sub connect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connect.Click
    connect.Enabled = False
    disconnect.Enabled = True
    myPort = IO.Ports.SerialPort.GetPortNames()
    SerialPort1.PortName = myPort(0)
    'Set SerialPort1 to the selected COM port at startup
    SerialPort1.BaudRate = 9600
    'Set Baud rate to the selected value on
    'Other Serial Port Property
    SerialPort1.Parity = IO.Ports.Parity.None
    SerialPort1.StopBits = IO.Ports.StopBits.One
    SerialPort1.DataBits = 8            'Open our serial port
    Try                     ' Start of exception handling 
        If SerialPort1.IsOpen = True Then        ' Port has been opened 

            Exit Sub
        End If
        SerialPort1.Open()            ' Opens the port 
    Catch ex As Exception           ' Exception handling 
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
    SerialPort1.RtsEnable = True
    If Not TextBoxID.Text Is Nothing Then
        Timer2.Enabled = True
    End If
End Sub

如何编写代码,帮助我在同一个vb项目中同时处理两个串口(串行发送入口数据和一个发送出口数据)

0 个答案:

没有答案