내 응용 프로그램에서 SMS를 보내는 모듈을 개발하려고합니다. 문제는 연결된 휴대 전화에 AT 명령을 보낼 때 내 앱이 응답하지 않는다는 것입니다. Nokia 6720C를 사용하고 있으며 PC Suite를 설치했습니다. Com 포트에도 나타납니다.USB GSM 모뎀을 통해 SMS 보내기
내 코드는 다음과 같습니다. 내가 도대체 뭘 잘못하고있는 겁니까? ("vbCr"입니다)
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
어디에서'SerialPort1'을 정의합니까? – Basic
내 양식 designview에 SerialPort1을 사용합니다 .. – Malik
감사합니다. 다음 질문은 응용 프로그램이 어떤 행에 매달려 있습니까? 각 코드 행에서'SerialPort1.Open()'과 'Step Over'에 중단 점을 넣으면'End Sub'에 도착합니까? 또한 정확한 COM 포트가 있는지 확인하십시오. – Basic