I have a GSM modem, Wavecom.
When I connect to it using HyperTerminal, i can send SMS with the standard AT comands, like this:
AT+CMGS="+351nnnnnnnnn" <CR>
> text to send in the message <Control-Z>
and the SMS goes on.
Note: <CR> means ENTER
Note: <CR> is ASCII 13, and Control-Z is ASCII 26.
When I use VisualBasic, the SAME AT sequence does not work.
And I get an ERROR (twice).
The manual says to do the following:
MSComm.Output = "AT+CMGS=" & chr(34) & "+ "+351nnnnnnnnn" & chr(34) & chr(13)
MsComm.Output = "text to send in the message" & chr(26).
Note: chr(34) is the character for the commas(").
What is wrong?
Many thanks for any help.
17 12428
Hi. You could try this - Const quote As String = """"
-
MsComm.Output = "AT+CMGS=" & quote & "+351nnnnnnnnn" & quote & vbCr
I have a GSM modem, Wavecom.
When I connect to it using HyperTerminal, i can send SMS with the standard AT comands, like this:
AT+CMGS="+351nnnnnnnnn" <CR> > text to send in the message <Control-Z>
and the SMS goes on.
When I use VisualBasic, the SAME AT sequence does not work.
And I get an ERROR (twice).
The manual says to do the following:
MSComm.Output = "AT+CMGS=" & chr(34) & "+ "+351nnnnnnnnn" & chr(34) & chr(13)
MsComm.Output = "text to send in the message" & chr(26).
A couple of questions... - Are you certain that it's only a CR which is sent after the AT command?
- What error are you getting?
- What does the ">" represent on the second line? (I ask mainly because it is not present in the VB version.)
- Are you sure you're in command mode? I seem to recall (from more than 10 years ago, I think) that you have to pause for at least a second, then send "+++" then another pause, to go into command mode. But this probably only applies if you are online at the time, right?
- Is this code copied/pasted, or typed in here? Because
MSComm.Output = "AT+CMGS=" & chr(34) & "+ "+351nnnnnnnnn" & chr(34) & chr(13)
seems to have quotes in the wrong places. It probably should have been MSComm.Output = "AT+CMGS=" & chr(34) & "+351nnnnnnnnn" & chr(34) & chr(13)
You can also make the code much more compact and readable by using CONST values as willakawill suggested. (Oops! Didn't realise you'd also fixed the mixed-up quotes, Will.)
Yeah. Get with it down there. You're supposed to be 13 hours ahead of me :)
It looks like your error is here:
[PHP]"+ "+351nnnnnnnnn" [/PHP]
You have "+ twice.
Try this:
MSComm.Output = "AT+CMGS=""+351nnnnnnnnn""" & chr(13)
MsComm.Output = "text to send in the message" & chr(26).
Try this:
MSComm.Output = "AT+CMGS=""+351nnnnnnnnn""" & chr(13)
MsComm.Output = "text to send in the message" & chr(26).
You are posting the same answer that has already been posted by 2 others
Yeah. Get with it down there. You're supposed to be 13 hours ahead of me :)
Yeah, well it's hard to forecast accurately what someone is going to say in 13 hours. ;)
I have a GSM modem, Wavecom.
When I connect to it using HyperTerminal, i can send SMS with the standard AT comands, like this:
AT+CMGS="+351nnnnnnnnn" <CR>
> text to send in the message <Control-Z>
and the SMS goes on.
Note: <CR> means ENTER
Note: <CR> is ASCII 13, and Control-Z is ASCII 26.
When I use VisualBasic, the SAME AT sequence does not work.
And I get an ERROR (twice).
The manual says to do the following:
MSComm.Output = "AT+CMGS=" & chr(34) & "+ "+351nnnnnnnnn" & chr(34) & chr(13)
MsComm.Output = "text to send in the message" & chr(26).
Note: chr(34) is the character for the commas(").
What is wrong?
Many thanks for any help.
Hi friend,
I've been in that kind of situation before and I used VB6 too, I developed a computer program that will keep all the SMS to my database and reply back with some information.
Ok here is the answer, before i tried that using chr(13) because this is the equivalent for the new line but unfortunately i dont know why this chr(13) is not working in MSCOM, but the only thing left is the constant value of VBCRLF you can use this as a substitute in chr(13)
Inshort
chr(13) = VBCRLF
and dont forget to send +++ it means that you will set the GSM in Command mode. Some1 already post this one, you better be careful in sending AT Command always keep in mind that before sending another batch of command you need to wait just for a second or 2, just use Sleep function in VB6.
Actually, after I solved that problem reagrading GSM and MSCOMM I realized that ANSI C is the much better language to use beacuse it is very easy to communicate with Devices like GSM. I am just telling you this because I experienced that before, but it will work fine in VB6 with MSCOMM
Norman
Hi friend,
I've been in that kind of situation before and I used VB6 too, I developed a computer program that will keep all the SMS to my database and reply back with some information.
Ok here is the answer, before i tried that using chr(13) because this is the equivalent for the new line but unfortunately i dont know why this chr(13) is not working in MSCOM, but the only thing left is the constant value of VBCRLF you can use this as a substitute in chr(13)
Inshort
chr(13) = VBCRLF
and dont forget to send +++ it means that you will set the GSM in Command mode. Some1 already post this one, you better be careful in sending AT Command always keep in mind that before sending another batch of command you need to wait just for a second or 2, just use Sleep function in VB6.
Actually, after I solved that problem reagrading GSM and MSCOMM I realized that ANSI C is the much better language to use beacuse it is very easy to communicate with Devices like GSM. I am just telling you this because I experienced that before, but it will work fine in VB6 with MSCOMM
Norman
EXAMPLE: - Option Explicit
-
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
-
Private Sub Command1_Click()
-
Dim strSMS As String
-
'set contact number
-
'buffer you message here
-
strSMS = "Hello World!"
-
'Before sending command
-
MSComm1.Output = "+++" & vbCrLf
-
'wait a second
-
Sleep 1
-
'send at commands
-
MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
-
-
'There are some GSM modems that after sending "AT+CMGS"
-
'it will response before buffering the message
-
-
'Ex.
-
' step 1: MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
-
' step 2: MSComm1.Input is equal to OK/ERROR
-
' step 3: then > insert your message
-
-
'In this case the GSM is allowing you to check first if the AT command is valid or not
-
'before buffering the message to GSM
-
-
'I dont know if this is your case but you can check.
-
-
While 1
-
'wait for 1 second or 2
-
-
Sleep 1 'this is depend on how fast your GSM communicate with MSCOMM
-
-
'Always wait this > sign to come out, because this the signal that the GSM is ready
-
'to get the Message
-
-
'if MSComm1.Input = ">" send your Message to GSM
-
-
'note: make it sure that no other chr(s) in MSComm1.Input except ">"
-
'The last thing to remember is do not ever try to use the DOEVENTS
-
-
If StrComp(Left(MSComm1.Input, 1), ">", vbBinaryCompare) = 0 Then
-
MSComm1.Output = strSMS & Chr(26)
-
Sleep 2
-
'Before you do this pls remove the chr(26)
-
If StrComp(Replace(MSComm1.Input, Chr(26), ""), "OK", vbBinaryCompare) = 0 Then
-
'place your flag
-
GoTo ExitWhile
-
ElseIf StrComp(Replace(MSComm1.Input, Chr(26), ""), "ERROR", vbBinaryCompare) = 0 Then
-
'place your flag
-
GoTo ExitWhile
-
Else
-
End If
-
Wend
-
-
ExitWhile:
-
'do your valdations here etc
-
'Check your falg here if error is true or false
-
Sleep 2
-
-
-
End Sub
EXAMPLE:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
Dim strSMS As String
'set contact number
'buffer you message here
strSMS = "Hello World!"
'Before sending command
MSComm1.Output = "+++" & vbCrLf
'wait a second
Sleep 1
'send at commands
MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
'There are some GSM modems that after sending "AT+CMGS"
'it will response before buffering the message
'Ex.
' step 1: MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
' step 2: MSComm1.Input is equal to OK/ERROR
' step 3: then > insert your message
'In this case the GSM is allowing you to check first if the AT command is valid or not
'before buffering the message to GSM
'I dont know if this is your case but you can check.
While 1
'wait for 1 second or 2
Sleep 1 'this is depend on how fast your GSM communicate with MSCOMM
'Always wait this > sign to come out, because this the signal that the GSM is ready
'to get the Message
'if MSComm1.Input = ">" send your Message to GSM
'note: make it sure that no other chr(s) in MSComm1.Input except ">"
'The last thing to remember is do not ever try to use the DOEVENTS
If StrComp(Left(MSComm1.Input, 1), ">", vbBinaryCompare) = 0 Then
MSComm1.Output = strSMS & Chr(26)
Sleep 2
'Before you do this pls remove the chr(26)
If StrComp(Replace(MSComm1.Input, Chr(26), ""), "OK", vbBinaryCompare) = 0 Then
'place your flag
GoTo ExitWhile
ElseIf StrComp(Replace(MSComm1.Input, Chr(26), ""), "ERROR", vbBinaryCompare) = 0 Then
'place your flag
GoTo ExitWhile
Else
End If
Wend
ExitWhile:
'do your valdations here etc
'Check your falg here if error is true or false
Sleep 2
End Sub
In addition, please always use PDU mode in reading and sending TEXT SMS Messages.
MSComm1.Output = "AT+CMGS=0"
AT+CMGF: Message Format:
Command Possible response(s) +CMGF=[<mode>] +CMGF?+CMGF: <mode> +CMGF=?+CMGF: (list of supported <mode>s)
<mode>: 0: PDU mode;
<mode>: 1: TEXT mode;
check out about PDU encryption/Decryption methods http://www.activexperts.com/activsms/sms/pdu/
[quote=sirsnorklingtayo] - ...
-
'wait for 1 second or 2
-
Sleep 1
-
...
Is this a routine of your own? I don't think VB6 has a Sleep statement. Mine doesn't, anyway.
[quote=Killer42]
- ...
-
'wait for 1 second or 2
-
Sleep 1
-
...
Is this a routine of your own? I don't think VB6 has a Sleep statement. Mine doesn't, anyway.
Nop, SLEEP is an WIN32 API function it acts like a delay() function in ANSI C
Here is the declaration: - 'You can place this in Form, Module Class etc but indicate the declration scope
-
'like Global,Public,Private
-
-
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
-
-
'to use this
-
-
Private Sub StopForAWhile(byval milliseconds as Integer)
-
-
Sleep 1000 ' stop for 1 second
-
-
end sub
and I admit that I made a mistake instead of Sleep 1 it should be Sleep 1000
Sleep 1 = 1/1000 second stop
Sleep 1000 = 1second stop
Sorry for my mistakes
hehehe
norman
Nop, SLEEP is an WIN32 API function it acts like a delay() function in ANSI C
Ah! Thanks for the reminder. I think I used it, years ago.
In the interests of clarity for those scouring these pages for tidbits, perhaps you mean: - Private Sub StopForAWhile(byval milliseconds as Integer)
-
-
Sleep milliseconds ' stop for (milliseconds/1000) seconds
-
-
end sub
This is also a useful way to call sleep: - Private Sub WaitSec(ByVal secs as Integer)
-
-
Sleep secs * 1000 ' stop for secs seconds
-
-
end sub
There was an error ("+) in the text i posted, but that was not the reason for my problem with GSM modem in VB6.
I found the solution: two more commands BEFORE the real string:
MSComm.Output = ""
MSComm.OutputBufferSize = 0
MSComm.Output = "the real string tou want to send"
And it works.
- Private Sub WaitSec(ByVal secs as Integer)
-
Sleep secs * 1000 ' stop for secs seconds
-
end sub
In a case like this I recommend using Single rather than Integer for the number of seconds. It allows finer control, for example pausing for 1½ seconds.
Congrats to all, I think our efforts paid up. The problem has been solved he he he.
So, good luck with your GSM Modem Project and thanks for the Information about the 2 lines of codes. I don't know about those codes and I never tried that before, but the more important is your program is now up and running. Happy coding with AT Commands
And about SLEEP sleep function, ya you are right SLEEP secs * 1000 I think this is the most clear example than mine.
Sleep secs * 1000 'seconds to wait
And I made a mistake again ha ha ha, Instead of using INTEGER for the Variable (millimseconds) use LONG data type in my last example.
Norman
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kees Bakelaar |
last post by:
Hi all,
This is not really a VB question, however, i am stuck a modem problem
The modem is connected to a cristie teleport with a speed of 9600 bps.
How can i set the modems DTE speed at...
|
by: Anne |
last post by:
Hi NG
I got a problem. I use the following code to print out reports imidiately:
Docmd.openReport "RptCase", acviewNormal
This works fine at the office and at home, but at a customer it...
|
by: Filips Benoit |
last post by:
New attempt: previous discussion 18/09/2004 stopt !
W2000
office2000
Added ref to 'Microsoft CDO for NTS 1.2 Library'
No code error
BUT NO emails send
What's missing?
Please help!
|
by: Cc |
last post by:
hi,
I making a program to control modem , I had follow example from MS website
on how to access serial port but still don't know how to make modem dial .
Is there any example on how I could make...
|
by: tnhoe |
last post by:
Hi,
I am looking for above. Any recommendation ?
The GSM modem is a data card with phone chip in notebook which can send sms directly without going through other sms gateway URL.
I only need...
|
by: Franc Zabkar |
last post by:
My D-Link DSL-302G modem/router has a real-time clock whose settings
are volatile. To avoid hand keying the date/time via the modem's JS
interface, I wonder if there is a way to copy the JS code to...
|
by: vgonepudi |
last post by:
Hi,
Requirement: I want to send numeric message to pager.
For that I have developed an application in VC++. My application takes
pager number as input and dials that number through my local...
|
by: Tym |
last post by:
Not sure this is the right group - but here goes.
I kinda expect Dick Grier to jump in on this one ;-)
I've got a windows app in VB.Net 2005 which sends and receives text messages
via a USM...
|
by: Tym |
last post by:
Not sure this is the right group - but here goes.
I kinda expect Dick Grier to jump in on this one ;-)
I've got a windows app in VB.Net 2005 which sends and receives text messages
via a USM...
|
by: muruganyuva |
last post by:
hi,
in my project i'm sending the data from source to destination with the help of modem.
one modem at the source and other at the destination.
at first i'm initializing the source modem.
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |