473,800 Members | 2,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with AT send with GSM modem

2 New Member
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="+351nn nnnnnnn" <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) & "+ "+351nnnnnn nnn" & 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.
Jan 29 '07
17 12494
sirsnorklingtayo
26 New Member
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) & "+351nnnnnn nnn" & 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) & "+351nnnnnn nnn" & 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(MS Comm1.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/
Jan 31 '07 #11
Killer42
8,435 Recognized Expert Expert
[quote=sirsnorkl ingtayo]
Expand|Select|Wrap|Line Numbers
  1. ...
  2.     'wait for 1 second or 2
  3.     Sleep 1
  4. ...
Is this a routine of your own? I don't think VB6 has a Sleep statement. Mine doesn't, anyway.
Jan 31 '07 #12
sirsnorklingtayo
26 New Member
[quote=Killer42]
Expand|Select|Wrap|Line Numbers
  1. ...
  2.     'wait for 1 second or 2
  3.     Sleep 1
  4. ...
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:
Expand|Select|Wrap|Line Numbers
  1. 'You can place this in Form, Module Class etc but indicate the declration scope
  2. 'like Global,Public,Private
  3.  
  4. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  5.  
  6. 'to use this
  7.  
  8. Private Sub StopForAWhile(byval milliseconds as Integer)
  9.  
  10.   Sleep 1000 ' stop for 1 second
  11.  
  12. 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
Feb 1 '07 #13
Killer42
8,435 Recognized Expert Expert
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.
Feb 1 '07 #14
willakawill
1,646 Top Contributor
In the interests of clarity for those scouring these pages for tidbits, perhaps you mean:
Expand|Select|Wrap|Line Numbers
  1. Private Sub StopForAWhile(byval milliseconds as Integer)
  2.  
  3. Sleep milliseconds ' stop for (milliseconds/1000) seconds
  4.  
  5. end sub
This is also a useful way to call sleep:
Expand|Select|Wrap|Line Numbers
  1. Private Sub WaitSec(ByVal secs as Integer)
  2.  
  3. Sleep secs * 1000 ' stop for secs seconds
  4.  
  5. end sub
Feb 1 '07 #15
UmDois
2 New Member
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.OutputBu fferSize = 0
MSComm.Output = "the real string tou want to send"

And it works.
Feb 2 '07 #16
Killer42
8,435 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. Private Sub WaitSec(ByVal secs as Integer)
  2.   Sleep secs * 1000 ' stop for secs seconds
  3. 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.
Feb 2 '07 #17
sirsnorklingtayo
26 New Member
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
Feb 3 '07 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3243
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 fixed to 9600 bps ? sometimes, the modem has a different DTE speed, i have to disconnect the
1
1202
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 don't work - anyone knows what the problem is, at what to do about it? Thx in advance
0
1296
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!
5
3464
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 modem dial?
11
4811
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 to programming api/lib to send sms. Regards Hoe
17
3375
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 the hard drive and modify it to automatically retrieve the PC's date/time. I could then add the hacked JS page to my browser's bookmarks. I've already successfully modified and adapted other modem menus, but I don't know how to go about this...
1
1659
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 modem. After establishing the connection I am getting a message like "Enter numeric message after beep". 1) How can I find whether connection is established or not?
0
1483
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 GSM modem. THe app cycles to poll the modem for incoming SMS as well as pausing this cycle to send... Working absolutely fine... except....
5
1948
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 GSM modem. THe app cycles to poll the modem for incoming SMS as well as pausing this cycle to send... Working absolutely fine... except....
2
2396
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. "AT E0 V1 X4 N1 &D0 &K0 S0=2" Then i connects the modem and transfer the data.
0
9691
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7582
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4150
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.