所以我试图使用AT命令与gsm调制解调器通信,我正在尝试进行基本测试,通过发送命令AT并接收OK来确保调制解调器正常。问题是我收到“AT Blank Line OK”,有什么办法,所以当我发送AT时,我只看好了吗?
Imports System.IO.Ports
Public Class GUI
Dim Device As New System.IO.Ports.SerialPort()
Private Sub GUI_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Port.Text = "Select Port"
For Each item As String In IO.Ports.SerialPort.GetPortNames
Port.Items.Add(item)
Next
Device.BaudRate = 9600
Device.Parity = Parity.None
Device.StopBits = StopBits.One
Device.DataBits = 8
Device.Handshake = Handshake.RequestToSend
Device.DtrEnable = True
Device.RtsEnable = True
Device.NewLine = vbCrLf
Device.WriteTimeout = 5000
End Sub
Private Sub Port_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Port.SelectedIndexChanged
Device.PortName = Port.SelectedItem.ToString
End Sub
Private Sub Send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Send.Click
Try
Device.Open()
Dim msg As String
msg = Message.Text
Device.DiscardInBuffer()
Device.DiscardOutBuffer()
Device.Write("AT" & vbCrLf)
MsgBox(Device.ReadExisting())
Catch ex As Exception
MsgBox("Error!")
End Try
Device.Close()
End Sub
End Class