亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rs232.vb

?? 使用vb.net實現串口通訊的過程
?? VB
?? 第 1 頁 / 共 3 頁
字號:
Option Strict On

Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Threading

' This class provides all the necessary support for communicating
'   with the Comm Port (otherwise known as the Serial Port, or 
'   RS232 port).
Public Class Rs232
    ' Declare the necessary class variables, and their initial values.		
    Private mhRS As Integer = -1   ' Handle to Com Port									
    Private miPort As Integer = 1   ' Default is COM1	
    Private miTimeout As Integer = 70   ' Timeout in ms
    Private miBaudRate As Integer = 9600
    Private meParity As DataParity = 0
    Private meStopBit As DataStopBit = 0
    Private miDataBit As Integer = 8
    Private miBufferSize As Integer = 512   ' Buffers size default to 512 bytes
    Private mabtRxBuf As Byte()   ' Receive buffer	
    Private meMode As Mode  ' Class working mode	
    Private mbWaitOnRead As Boolean
    Private mbWaitOnWrite As Boolean
    Private mbWriteErr As Boolean
    Private muOverlapped As OVERLAPPED
    Private muOverlappedW As OVERLAPPED
    Private muOverlappedE As OVERLAPPED
    Private mabtTmpTxBuf As Byte()  ' Temporary buffer used by Async Tx
    Private moThreadTx As Thread
    Private moThreadRx As Thread
    Private miTmpBytes2Read As Integer
    Private meMask As EventMasks

#Region "Enums"

    ' This enumeration provides Data Parity values.
    Public Enum DataParity
        Parity_None = 0
        Pariti_Odd
        Parity_Even
        Parity_Mark
    End Enum

    ' This enumeration provides Data Stop Bit values.
    '   It is set to begin with a one, so that the enumeration values
    '   match the actual values.
    Public Enum DataStopBit
        StopBit_1 = 1
        StopBit_2
    End Enum

    ' This enumeration contains values used to purge the various buffers.
    Private Enum PurgeBuffers
        RXAbort = &H2
        RXClear = &H8
        TxAbort = &H1
        TxClear = &H4
    End Enum

    ' This enumeration provides values for the lines sent to the Comm Port
    Private Enum Lines
        SetRts = 3
        ClearRts = 4
        SetDtr = 5
        ClearDtr = 6
        ResetDev = 7   '	 Reset device if possible
        SetBreak = 8   '	 Set the device break line.
        ClearBreak = 9   '	 Clear the device break line.
    End Enum
    ' This enumeration provides values for the Modem Status, since
    '   we'll be communicating primarily with a modem.
    ' Note that the Flags() attribute is set to allow for a bitwise
    '   combination of values.
    <Flags()> Public Enum ModemStatusBits
        ClearToSendOn = &H10
        DataSetReadyOn = &H20
        RingIndicatorOn = &H40
        CarrierDetect = &H80
    End Enum

    ' This enumeration provides values for the Working mode
    Public Enum Mode
        NonOverlapped
        Overlapped
    End Enum

    ' This enumeration provides values for the Comm Masks used.
    ' Note that the Flags() attribute is set to allow for a bitwise
    '   combination of values.
    <Flags()> Public Enum EventMasks
        RxChar = &H1
        RXFlag = &H2
        TxBufferEmpty = &H4
        ClearToSend = &H8
        DataSetReady = &H10
        ReceiveLine = &H20
        Break = &H40
        StatusError = &H80
        Ring = &H100
    End Enum
#End Region

#Region "Structures"
    ' This is the DCB structure used by the calls to the Windows API.
    <StructLayout(LayoutKind.Sequential, Pack:=1)> Private Structure DCB
        Public DCBlength As Integer
        Public BaudRate As Integer
        Public Bits1 As Integer
        Public wReserved As Int16
        Public XonLim As Int16
        Public XoffLim As Int16
        Public ByteSize As Byte
        Public Parity As Byte
        Public StopBits As Byte
        Public XonChar As Byte
        Public XoffChar As Byte
        Public ErrorChar As Byte
        Public EofChar As Byte
        Public EvtChar As Byte
        Public wReserved2 As Int16
    End Structure

    ' This is the CommTimeOuts structure used by the calls to the Windows API.
    <StructLayout(LayoutKind.Sequential, Pack:=1)> Private Structure COMMTIMEOUTS
        Public ReadIntervalTimeout As Integer
        Public ReadTotalTimeoutMultiplier As Integer
        Public ReadTotalTimeoutConstant As Integer
        Public WriteTotalTimeoutMultiplier As Integer
        Public WriteTotalTimeoutConstant As Integer
    End Structure

    ' This is the CommConfig structure used by the calls to the Windows API.
    <StructLayout(LayoutKind.Sequential, Pack:=1)> Private Structure COMMCONFIG
        Public dwSize As Integer
        Public wVersion As Int16
        Public wReserved As Int16
        Public dcbx As DCB
        Public dwProviderSubType As Integer
        Public dwProviderOffset As Integer
        Public dwProviderSize As Integer
        Public wcProviderData As Byte
    End Structure

    ' This is the OverLapped structure used by the calls to the Windows API.
    <StructLayout(LayoutKind.Sequential, Pack:=1)> Public Structure OVERLAPPED
        Public Internal As Integer
        Public InternalHigh As Integer
        Public Offset As Integer
        Public OffsetHigh As Integer
        Public hEvent As Integer
    End Structure
#End Region

#Region "Exceptions"

    ' This class defines a customized channel exception. This exception is
    '   raised when a NACK is raised.
    Public Class CIOChannelException : Inherits ApplicationException
        Sub New(ByVal Message As String)
            MyBase.New(Message)
        End Sub
        Sub New(ByVal Message As String, ByVal InnerException As Exception)
            MyBase.New(Message, InnerException)
        End Sub
    End Class

    ' This class defines a customized timeout exception.
    Public Class IOTimeoutException : Inherits CIOChannelException
        Sub New(ByVal Message As String)
            MyBase.New(Message)
        End Sub
        Sub New(ByVal Message As String, ByVal InnerException As Exception)
            MyBase.New(Message, InnerException)
        End Sub
    End Class

#End Region

#Region "Events"
    ' These events allow the program using this class to react to Comm Port
    '   events.
    Public Event DataReceived(ByVal Source As Rs232, ByVal DataBuffer() As Byte)
    Public Event TxCompleted(ByVal Source As Rs232)
    Public Event CommEvent(ByVal Source As Rs232, ByVal Mask As EventMasks)
#End Region

#Region "Constants"
    ' These constants are used to make the code clearer.
    Private Const PURGE_RXABORT As Integer = &H2
    Private Const PURGE_RXCLEAR As Integer = &H8
    Private Const PURGE_TXABORT As Integer = &H1
    Private Const PURGE_TXCLEAR As Integer = &H4
    Private Const GENERIC_READ As Integer = &H80000000
    Private Const GENERIC_WRITE As Integer = &H40000000
    Private Const OPEN_EXISTING As Integer = 3
    Private Const INVALID_HANDLE_VALUE As Integer = -1
    Private Const IO_BUFFER_SIZE As Integer = 1024
    Private Const FILE_FLAG_OVERLAPPED As Integer = &H40000000
    Private Const ERROR_IO_PENDING As Integer = 997
    Private Const WAIT_OBJECT_0 As Integer = 0
    Private Const ERROR_IO_INCOMPLETE As Integer = 996
    Private Const WAIT_TIMEOUT As Integer = &H102&
    Private Const INFINITE As Integer = &HFFFFFFFF


#End Region

#Region "Properties"

    ' This property gets or sets the BaudRate
    Public Property BaudRate() As Integer
        Get
            Return miBaudRate
        End Get
        Set(ByVal Value As Integer)
            miBaudRate = Value
        End Set
    End Property

    ' This property gets or sets the BufferSize
    Public Property BufferSize() As Integer
        Get
            Return miBufferSize
        End Get
        Set(ByVal Value As Integer)
            miBufferSize = Value
        End Set
    End Property

    ' This property gets or sets the DataBit.
    Public Property DataBit() As Integer
        Get
            Return miDataBit
        End Get
        Set(ByVal Value As Integer)
            miDataBit = Value
        End Set
    End Property

    ' This write-only property sets or resets the DTR line.
    Public WriteOnly Property Dtr() As Boolean
        Set(ByVal Value As Boolean)
            If Not mhRS = -1 Then
                If Value Then
                    EscapeCommFunction(mhRS, Lines.SetDtr)
                Else
                    EscapeCommFunction(mhRS, Lines.ClearDtr)
                End If
            End If
        End Set
    End Property

    ' This read-only property returns an array of bytes that represents
    '   the input coming into the Comm Port.
    Overridable ReadOnly Property InputStream() As Byte()
        Get
            Return mabtRxBuf
        End Get
    End Property

    ' This read-only property returns a string that represents
    '   the data coming into to the Comm Port.
    Overridable ReadOnly Property InputStreamString() As String
        Get
            Dim oEncoder As New System.Text.ASCIIEncoding()
            Return oEncoder.GetString(Me.InputStream)
        End Get
    End Property

    ' This property returns the open status of the Comm Port.
    ReadOnly Property IsOpen() As Boolean
        Get
            Return CBool(mhRS <> -1)
        End Get
    End Property

    ' This read-only property returns the status of the modem.
    Public ReadOnly Property ModemStatus() As ModemStatusBits
        Get
            If mhRS = -1 Then
                Throw New ApplicationException("Please initialize and open " + _
                    "port before using this method")
            Else
                ' Retrieve modem status

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国精品自拍自在线| 美国毛片一区二区三区| 丝袜诱惑亚洲看片| 成人性生交大片免费看中文| 欧美一区二区三区性视频| 自拍偷拍国产精品| 国产一区二区三区在线观看精品| 欧洲一区二区三区在线| 国产精品乱码一区二区三区软件| 日韩成人午夜电影| 色中色一区二区| 国产精品理伦片| 国产美女主播视频一区| 91精品国产综合久久精品app| 中文子幕无线码一区tr| 国产一区二区三区免费观看| 91麻豆精品国产91久久久更新时间| 136国产福利精品导航| 国产大陆精品国产| 久久这里只有精品视频网| 日本成人在线不卡视频| 欧美高清你懂得| 一区二区三区四区视频精品免费| 国产91丝袜在线观看| 精品国产乱码91久久久久久网站| 日韩精品电影在线| 欧美伦理电影网| 天天综合网 天天综合色| 在线观看国产一区二区| 成人免费小视频| 91在线精品一区二区| 中文字幕一区在线观看| 99视频一区二区| 亚洲免费三区一区二区| 色综合久久综合| 一区二区高清视频在线观看| 91九色最新地址| 亚洲一区二区视频在线观看| 精品视频一区 二区 三区| 五月婷婷综合激情| 欧美成人精品3d动漫h| 久久国产三级精品| 久久久亚洲综合| 不卡的av在线播放| 一区二区三区四区在线播放 | 日韩av一区二区三区四区| 在线精品视频免费播放| 午夜精品久久久久久久久| 日韩三级视频在线观看| 韩日欧美一区二区三区| 国产精品嫩草久久久久| 欧美亚洲自拍偷拍| 热久久一区二区| 亚洲国产电影在线观看| 色www精品视频在线观看| 亚洲曰韩产成在线| 日韩欧美一级片| 丁香啪啪综合成人亚洲小说| 亚洲精品福利视频网站| 日韩一区二区免费高清| 国产99久久久国产精品| 亚洲精品成人在线| 日韩午夜在线影院| 91丨九色丨尤物| 免费观看30秒视频久久| 国产精品久久久久久久岛一牛影视| 日本久久精品电影| 国产一区二区三区四区在线观看| 亚洲美女淫视频| 欧美成人猛片aaaaaaa| 色综合视频一区二区三区高清| 免费人成在线不卡| 亚洲三级在线播放| 久久综合色一综合色88| 色素色在线综合| 国产精品一区久久久久| 亚洲成人av电影在线| 国产精品女主播av| 日韩女优毛片在线| 91精品办公室少妇高潮对白| 国内精品伊人久久久久av影院 | 日韩va欧美va亚洲va久久| 久久久久免费观看| 欧美精品久久一区| av在线这里只有精品| 久久福利视频一区二区| 亚洲成a人v欧美综合天堂下载| 国产欧美日韩在线视频| 欧美一区二区三区免费视频| 91视频观看视频| 国产精品18久久久久久久网站| 午夜精品久久久| 亚洲精品写真福利| 国产精品美女久久久久aⅴ| 欧美一级高清大全免费观看| 色女孩综合影院| 成人av资源网站| 国产在线精品国自产拍免费| 首页国产欧美久久| 一区二区三区成人| 成人免费在线播放视频| 中文字幕va一区二区三区| 久久久欧美精品sm网站| 欧美成人官网二区| 日韩欧美亚洲国产另类| 欧美一区二区三区视频免费 | 亚洲综合丁香婷婷六月香| 国产清纯在线一区二区www| 久久嫩草精品久久久精品| 日韩视频123| 欧美大肚乱孕交hd孕妇| 日韩欧美激情在线| 欧美不卡一二三| 精品国产乱码久久久久久影片| 欧美成人vr18sexvr| 精品国产免费人成电影在线观看四季| 91精品欧美综合在线观看最新| 欧美丰满美乳xxx高潮www| 911精品国产一区二区在线| 337p亚洲精品色噜噜狠狠| 欧美精品在线一区二区| 日韩欧美一二三| 久久综合久色欧美综合狠狠| 欧美mv日韩mv| 久久亚洲春色中文字幕久久久| 精品国产髙清在线看国产毛片| 精品播放一区二区| 久久精品水蜜桃av综合天堂| 中文字幕精品—区二区四季| 综合激情成人伊人| 亚洲成人7777| 韩国av一区二区三区| 粉嫩av一区二区三区| 色综合咪咪久久| 91精品国产91久久久久久一区二区| 日韩欧美电影一二三| 久久精品视频在线免费观看 | 精品电影一区二区三区| 日本一区二区视频在线观看| 亚洲啪啪综合av一区二区三区| 亚洲午夜精品17c| 精品一二线国产| 成人中文字幕电影| 日本精品一级二级| 欧美久久婷婷综合色| 精品国产麻豆免费人成网站| 国产精品色眯眯| 香蕉成人伊视频在线观看| 国产精品中文有码| 色综合久久88色综合天天免费| 欧美日韩国产精品自在自线| 久久综合久久综合久久综合| 一区二区三区四区五区视频在线观看 | 五月婷婷激情综合网| 国产一区91精品张津瑜| 在线亚洲人成电影网站色www| 日韩欧美综合在线| 自拍偷拍国产精品| 韩国v欧美v日本v亚洲v| 欧美艳星brazzers| 欧美国产欧美亚州国产日韩mv天天看完整| 最近中文字幕一区二区三区| 美女视频黄 久久| 色婷婷综合激情| 日本一区二区三区国色天香 | 亚洲你懂的在线视频| 久久国产福利国产秒拍| 色欧美88888久久久久久影院| 国产亚洲欧美日韩日本| 日韩电影在线一区二区三区| 91香蕉视频污在线| 久久久精品人体av艺术| 日本欧美一区二区| 色88888久久久久久影院按摩| 国产欧美精品一区aⅴ影院| 麻豆久久一区二区| 欧美精品久久99| 一区二区三区精品久久久| 高清不卡一二三区| 精品国产一区二区在线观看| 午夜视频一区二区| 欧美综合天天夜夜久久| 国产精品久久精品日日| 国产91在线观看丝袜| 久久久久久电影| 美女性感视频久久| 欧美一区二区黄色| 亚洲香肠在线观看| 在线免费观看成人短视频| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产亚洲综合在线| 国产尤物一区二区| 欧美不卡在线视频| 韩国一区二区视频| 精品久久人人做人人爱| 国产一区二区三区在线看麻豆 | 欧美日韩日日摸| 亚洲成a天堂v人片| 欧美美女bb生活片| 蜜臀91精品一区二区三区 |