rjdfernando
asked on
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!
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!
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?
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?
ASKER
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..
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..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
Please post a question in the GSM area.
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?
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?
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