Public Class Form1
Dim mySerialPort As New System.IO.Ports.SerialPort
Delegate Sub DataShow(ByVal myString As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
mySerialPort.Write("at+wmsn" & vbCrLf)
End Sub
Private Sub Form1_Disposed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Disposed
If mySerialPort.IsOpen Then
mySerialPort.Close()
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With mySerialPort
.PortName = "COM3"
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
.Parity = IO.Ports.Parity.None
.BaudRate = 115200
.RtsEnable = True
.ReceivedBytesThreshold = 1
AddHandler mySerialPort.D
VB.net使用SerialPort类访问串口
最新推荐文章于 2024-08-02 10:41:02 发布