我正在尝试开发一个模块,从我的应用程序发送短信。问题是,当我向连接的手机发送AT命令时,我的应用程序就停止了响应。我使用的是诺基亚6720 C,我已经安装了Pc套件。它也出现在Com港口。
我的密码在下面。我做错了什么?
Imports System
Imports System.IO.Ports
Imports System.Threading
Imports System.ComponentModel
Public Class Form1
Delegate Sub SetTextCallback(ByVal [text] As String)
Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
With SerialPort1
.PortName = "COM14"
.DataBits = 8
.Parity = IO.Ports.Parity.None
.StopBits = StopBits.One
End With
SerialPort1.Open()
SerialPort1.Write("AT" & vbCr)
SerialPort1.Close()
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())
End Sub
Private Sub ReceivedText(ByVal [text] As String)
'compares the ID of the creating Thread to the ID of the calling Thread
If Me.TxtResponse.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.TxtResponse.Text &= [text]
End If
End Sub发布于 2013-01-03 17:55:33
在at命令的末尾,您必须添加Chr(13)和Chr(10),您只使用Chr(13) (即"vbCr"),尝试将其替换为vbCrLf (回传"Chr(13)“和Line Feed "Chr(10)")。我认为这就是问题所在(命令字符串没有完成)。
如果问题仍然存在,请尝试以下方法来测试您的工作:
希望这能帮上忙祝你好运。
https://stackoverflow.com/questions/13511670
复制相似问题