37 lines
728 B
VB.net
37 lines
728 B
VB.net
|
|
Imports System.IO.Ports
|
|||
|
|
|
|||
|
|
Public Class UartServer
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 串口句柄
|
|||
|
|
''' </summary>
|
|||
|
|
Public Uart As SerialPort
|
|||
|
|
|
|||
|
|
Sub New(UartPort As String, UartBaud As Long, Uartdata As Long, UartParity As Parity, dataBits As Integer, UartStop As Integer)
|
|||
|
|
Uart = New SerialPort(UartPort, UartBaud, UartParity, dataBits, UartStop)
|
|||
|
|
End Sub
|
|||
|
|
''' <summary>
|
|||
|
|
''' 打开串口
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function UartOPen() As Boolean
|
|||
|
|
Try
|
|||
|
|
Uart.Open()
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
|
|||
|
|
End Try
|
|||
|
|
Return Uart.IsOpen
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
Public Function UartSenddata(sendbuff() As Byte)
|
|||
|
|
' Uart.s
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Class
|