StreamReader.ReadLine() hang when AT+CMGS=<destination num> is sent to modem

i have been able to send AT commands to my gsm modem and got their response using streams.. im accessing serial communication port to connect to my gsm modem..

my problem now is when i issue the AT+CMGS="<destination number>" command my app hangs and the modem does not respond the '>' character.. it is as if it does not end reading the stream(???).. i dont know what's the problem with this one. i run it before in .NET 2003 and it works fine. when i upgraded to .NET 2005 beta, thats the time when i started encountering this problem..

added to that.. i think the problem also is with the response of AT+CMGS="<destination number>" command. it seems that the streamreader.readline() did not encounter an end of line or maybe an end of file(??? not sure) because i tried issuing the command in the hyperterminal and the modem's response is '>' and it waits for user input, which in this case is the message...

can anybody help me with this? thank u so much!
rjdfernandoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ianmharperCommented:
The Difference Between Hyperterm and your program is that hyperterm insert's a <cr><lf>
at the time you enter, your need to add at least a <cr> carriage return ater your string eg
AT+CMGS="<destination number>"<cr> send the command then your message followed by a
<cntrl Z> to terminate the message then a <cr> the terminal should repsoned with +CMGS:21
or something like that
FismanCommented:
A readline from a stream will wait for a <CR> or <CR><LF> from the port. The GSM modem will only send back "> " without a <CR> after it to prompt for the message.

Your app will hang waiting for the <CR> which will never come. Maybe try to use read instead of readline? Alternatively peek the stream to see if there is data before you read it?

rjdfernandoAuthor Commented:
since i use c# in developing this app.. i use the following command:

string command = "AT+CGMS=\"<destination number>\"" + ((char) 13).ToString();

where 13 is the ascii value of carriage return/feed <cr>... well i also read about StreamReader.Read() but still it will look for <CR>. added to that, i already used StreamReader.Peek().

well, last friday.. after posting this thread.. i dont know what i did to my program that it worked.. this time it returns the '>' character and asked for the message. it's really weird.. the problem now is that after sending the following message..

string message = "test sms" + ((char) 26).ToString() +  ((char) 13).ToString();

the reply will only display the message plus an unknown character which represents the ctrl+z (ascii value 26).

after which, i need to issue any string or command to the modem to get the +CMS: <value> response.. any help? what should i do to automatically get the response without issuing any string to the modem..

 
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

BigRatCommented:
It seems as if you are reading back the text you are sending. Did you turn echoing off with ATE0 before starting sending messages?

The actual GSM standard requires CR/LF as terminator, ie: you and it should always be using hex 0D0A sequences.

I have found by experience that some phones/GSM modmes throw in an extra blank line, so I made a line read routine which returns non-blank lines.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nainskum2Commented:
Sir

I have stuck with CTRL-Z problem
I follow the same steps, disabled echo
still the mobile will not send sms and return ok
it presents the following screen in hyper terminal
at+cmgs="phone"


I typer message and pressed ctrl-z, it does not respond to ctrl-z
please help me
BigRatCommented:
Please post a question in the GSM area.
nainskum2Commented:
I am using a sammsung mobile connected through usb. I want to send text mode sms through java. I have tried all. I tried to use hyper terminal to check the interactions from modem. Both java code and hypter terminal, gets stuck after sending ctrl-z. No response from the mobile. The sms was not send. The mobile waits indefinitely, both in hyper terminal. I joinde your forum specifically for getting a break through. I have spent a week time. Any noble heart may please help me at senthilkumar@rbi.org.in.
please, what am i missing? I have tried all possible options mentioned with regard to CR LF CTRL-Z characters. but the mobile simply would not respond. However the same mobile is sending sms through a Samsung PC Studio software. I am wondering what we are missing?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Wireless Networking

From novice to tech pro — start learning today.