473,788 Members | 2,744 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 #1
17 12492
willakawill
1,646 Top Contributor
Hi. You could try this
Expand|Select|Wrap|Line Numbers
  1. Const quote As String = """"
  2. MsComm.Output = "AT+CMGS=" & quote & "+351nnnnnnnnn" & quote & vbCr
Jan 30 '07 #2
Killer42
8,435 Recognized Expert Expert
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.
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).
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) & "+ "+351nnnnnn nnn" & chr(34) & chr(13)
    seems to have quotes in the wrong places. It probably should have been
    MSComm.Output = "AT+CMGS=" & chr(34) & "+351nnnnnn nnn" & 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.)
Jan 30 '07 #3
willakawill
1,646 Top Contributor
Yeah. Get with it down there. You're supposed to be 13 hours ahead of me :)
Jan 30 '07 #4
iburyak
1,017 Recognized Expert Top Contributor
It looks like your error is here:


[PHP]"+ "+351nnnnnn nnn" [/PHP]

You have "+ twice.
Jan 30 '07 #5
iburyak
1,017 Recognized Expert Top Contributor
Try this:

MSComm.Output = "AT+CMGS=""+351 nnnnnnnnn""" & chr(13)

MsComm.Output = "text to send in the message" & chr(26).
Jan 30 '07 #6
willakawill
1,646 Top Contributor
Try this:

MSComm.Output = "AT+CMGS=""+351 nnnnnnnnn""" & 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
Jan 30 '07 #7
Killer42
8,435 Recognized Expert Expert
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. ;)
Jan 30 '07 #8
sirsnorklingtayo
26 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.

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
Jan 31 '07 #9
sirsnorklingtayo
26 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  3.  
  4.  
  5. Private Sub Command1_Click()
  6. Dim strSMS As String
  7. 'set contact number
  8. 'buffer you message here
  9. strSMS = "Hello World!"
  10. 'Before sending command
  11. MSComm1.Output = "+++" & vbCrLf
  12. 'wait a second
  13. Sleep 1
  14. 'send at commands
  15. MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
  16.  
  17. 'There are some GSM modems that after sending "AT+CMGS"
  18. 'it will response before buffering the message
  19.  
  20. 'Ex.
  21. ' step 1: MSComm1.Output = "AT+CMGS=" & Chr(34) & "+351nnnnnnnnn" & Chr(34) & vbCrLf
  22. ' step 2: MSComm1.Input is equal to OK/ERROR
  23. ' step 3: then > insert your message
  24.  
  25. 'In this case the GSM is allowing you to check first if the AT command is valid or not
  26. 'before buffering the message to GSM
  27.  
  28. 'I dont know if this is your case but you can check.
  29.  
  30. While 1
  31.     'wait for 1 second or 2
  32.  
  33.     Sleep 1  'this is depend on how fast your GSM communicate with MSCOMM
  34.  
  35.     'Always wait this > sign to come out, because this the signal that the GSM is ready
  36.     'to get the Message
  37.  
  38.     'if MSComm1.Input = ">" send your Message to GSM
  39.  
  40.     'note: make it sure that no other chr(s) in MSComm1.Input except ">"
  41.     'The last thing to remember is do not ever try to use the DOEVENTS
  42.  
  43.     If StrComp(Left(MSComm1.Input, 1), ">", vbBinaryCompare) = 0 Then
  44.         MSComm1.Output = strSMS & Chr(26)
  45.         Sleep 2
  46.         'Before you do this pls remove the chr(26)
  47.         If StrComp(Replace(MSComm1.Input, Chr(26), ""), "OK", vbBinaryCompare) = 0 Then
  48.             'place your flag
  49.             GoTo ExitWhile
  50.         ElseIf StrComp(Replace(MSComm1.Input, Chr(26), ""), "ERROR", vbBinaryCompare) = 0 Then
  51.             'place your flag
  52.             GoTo ExitWhile
  53.         Else
  54.     End If
  55. Wend
  56.  
  57. ExitWhile:
  58.     'do your valdations here etc
  59.     'Check your falg here if error is true or false
  60.     Sleep 2
  61.  
  62.  
  63. End Sub
Jan 31 '07 #10

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

Similar topics

1
3241
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
1201
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
4809
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
3373
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
1657
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
1481
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
1947
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
9656
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
9498
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
10177
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
9969
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8995
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
7519
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
5403
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...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.