亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码

標(biāo)題: 原創(chuàng)-visual basic net串口樣板架構(gòu) [打印本頁(yè)]

作者: xjbworld    時(shí)間: 2023-9-5 11:41
標(biāo)題: 原創(chuàng)-visual basic net串口樣板架構(gòu)
visual basicnet其實(shí)比visual C#更好用,作為嵌入式開(kāi)發(fā)人員,用basic入門更簡(jiǎn)單,可以很快做出調(diào)試產(chǎn)品工具。附件是完整項(xiàng)目
這個(gè)是電腦串口尋找子函數(shù)
   Private Sub com_channel_get(ByVal getcom1 As Integer)

        Dim getcom As Integer
        Dim ports As String() = SerialPort.GetPortNames() '必須用命名空間,用SerialPort,獲取計(jì)算機(jī)的有效串口
        Dim port As String

        For Each port In ports
            Console.WriteLine(port)
        Next port

        ComboBox1.Items.Clear()
        ComboBox1.Text = ""
        For Each port In ports
            ComboBox1.Items.Add(port) '向combobox中添加項(xiàng)
        Next port
        getcom = ComboBox1.Items.Count '讀ComboBox1的數(shù)值


        Dim comnum As Integer
        Dim textcom As String
        ComboBox1.Enabled = False


        '     Exit Sub

        Dim mBaudRate As Integer
        Dim mParity As IO.Ports.Parity
        Dim mDataBit As Integer
        Dim mStopbit As IO.Ports.StopBits
        Dim mPortName As String = "COM1"


        mBaudRate = 9600   '比特率
        mParity = Parity.None  '校驗(yàn)位檢查設(shè)定
        mDataBit = 8    '數(shù)據(jù)位設(shè)定值
        mStopbit = StopBits.One  '停止位設(shè)定值



        For comnum = 0 To getcom - 1 Step 1
            ComboBox1.SelectedIndex() = comnum '第一個(gè)端口為默認(rèn)
            mPortName = ComboBox1.GetItemText(ComboBox1.SelectedItem) '欲開(kāi)啟的通訊端口  
            '     mPortName = "COM3"
        Next comnum

        RS232 = New IO.Ports.SerialPort(mPortName, mBaudRate, mParity, mDataBit, mStopbit)

        If RS232.IsOpen = True Then  '尚未開(kāi)啟
            RS232.Close()  '開(kāi)啟通訊端口
        End If

        Threading.Thread.Sleep(50)

        Try
            If RS232.IsOpen = False Then  '尚未開(kāi)啟
                RS232.Open()  '開(kāi)啟通訊端口
                RS232.ReceivedBytesThreshold = 1        '設(shè)置引發(fā)事件的門限值
            End If
        Catch
            Try

                If RS232.IsOpen = True Then  '尚未開(kāi)啟
                    RS232.Close()  '開(kāi)啟通訊端口
                End If
            Catch
            End Try
        End Try

        Exit Sub

        Dim hexBytes(3) As Byte

        hexBytes(0) = &H6A
        'RS232.Write(hexBytes, 0, 1)
        RS232.Write("AT+DISC" + Chr(&HD) + Chr(&HA))
        Threading.Thread.Sleep(500)

        '   Dim rxdata As String = RS232_Data(3)
        Label1.Text = "通信未連接"
        Label1.ForeColor = Color.Red
        Dim textcompare As String = ""
        If (Len(gl_string) > 4) Then
            textcompare = Mid(gl_string, 1, 5)
        End If
        'ERROR OR OK+DISC
        If ((textcompare = "ERROR") Or (textcompare = "OK+DI")) Then
            Label1.Text = "通信已連接"
            Label1.ForeColor = Color.Green
            setrxnum = 4

        End If
        '    If (RS232.BytesToRead >= 5) Then
        'setrxnum = 8 '打開(kāi)串口自動(dòng)讀取
        '   Exit For
        '    End If


        If RS232.IsOpen = True Then  '尚未開(kāi)啟
            RS232.Close()  '開(kāi)啟通訊端口
        End If


    End Sub
prj_Vbnet.zip (509.89 KB, 下載次數(shù): 1)




作者: heicad    時(shí)間: 2024-1-22 02:43
好資料,51黑有你更精彩!!!




歡迎光臨 (http://www.denmoz.com/bbs/) Powered by Discuz! X3.1