how to create a program that receives messages using at commands in vb 2010?
hey guys i really need some help.
i tried this codes below that i created but it cant receive messages. and if it can i like to read it directly in Richtextbox.
here is the code:
Public Sub receive()
If srPort.IsOpen = True Then
Try
With srPort
.WriteLine("AT")
.WriteLine("AT+CMGF=1" & Chr(34) & vbCrLf)
.WriteLine("AT+CSCS=""PCCP437""" & Chr(34) & vbCrLf)
.WriteLine("AT+CPMS=""SM""" & Chr(34) & vbCrLf)
.WriteLine("AT+CMGL=""REC UNREAD""" & receiveRT.Text & vbCrLf)
End With
Catch ex As Exception
End Try
End If
End Sub
Re: how to create a program that receives messages using at commands in vb 2010?
You're trying to read yet....:-
Code:
.WriteLine("AT+CSCS=""PCCP437""" & Chr(34) & vbCrLf)
You seriously don't expect a function named "WriteLine" to do any thing like reading, do you ?
Re: how to create a program that receives messages using at commands in vb 2010?
A couple of suggestions.
1) Don't use WriteLine. Use Write. For example
.WriteLine("AT+CMGF=1" & Chr(34) & vbCrLf)
would be
.Write("AT+CMGF=1" & Chr(34) & ControlChars.Cr)
Note that the string is concatenated with CR because this is the default modem end-of-command character. Sending linefeeds is not required.
2) After each write put a readline to read the results.
I'd not use the With style. Try it like this
Code:
Dim s As String
srPort.Write("AT" & ControlChars.Cr)
s = srPort.ReadLine
Debug.WriteLine(s)
srPort.Write("AT+CMGF=1" & Chr(34) & ControlChars.Cr)
s = srPort.ReadLine
Debug.WriteLine(s)
If the command returns more that one line you will need multiple readlines to get the results.
Use code tags when you post code.
Re: how to create a program that receives messages using at commands in vb 2010?
Quote:
Originally Posted by
dbasnett
A couple of suggestions.
1) Don't use WriteLine. Use Write. For example
.WriteLine("AT+CMGF=1" & Chr(34) & vbCrLf)
would be
.Write("AT+CMGF=1" & Chr(34) & ControlChars.Cr)
Note that the string is concatenated with CR because this is the default modem end-of-command character. Sending linefeeds is not required.
2) After each write put a readline to read the results.
I'd not use the With style. Try it like this
Code:
Dim s As String
srPort.Write("AT" & ControlChars.Cr)
s = srPort.ReadLine
Debug.WriteLine(s)
srPort.Write("AT+CMGF=1" & Chr(34) & ControlChars.Cr)
s = srPort.ReadLine
Debug.WriteLine(s)
If the command returns more that one line you will need multiple readlines to get the results.
Use code tags when you post code.
sir will i be able to read my sms directly in textbox?
Re: how to create a program that receives messages using at commands in vb 2010?
Start with the code I posted. Do the debug statements show the output? If they do then 's' will contain the responses and since a TextBox.Text is a string you should be able to set the .Text with variable 's'. If you have multiple strings set the MultLine property of the textbox to true and use AppendText.