|
-
January 30th, 2012, 02:05 AM
#1
Problem with modem response for AT commands
Hello,
I'm writing a code in C++ to send AT commands to a Maestro 100 GSM modem. According to the modem manual, these are the settings that should be entered in hyperterminal:
Bits per second: 115200
Data bits: 8
Parity: None
Stop bits: 1
Flow control: Hardware
In my code, these are the dcb settings for the COM port that I put:
m_comport.dcb.BaudRate = 115200;
m_comport.dcb.ByteSize = 8;
m_comport.dcb.Parity = NOPARITY;
m_comport.dcb.StopBits = ONESTOPBIT;
m_comport.dcb.fDtrControl = DTR_CONTROL_ENABLE;
m_comport.dcb.fOutxCtsFlow = TRUE;
m_comport.dcb.fTXContinueOnXoff = TRUE;
m_comport.dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
m_comport.dcb.fAbortOnError = TRUE;
m_comport.dcb.XonLim = 80;
m_comport.dcb.XoffLim = 200;
My problem is that when I start the modem for the first time of the day, or after a long period of time of not using it, when I run my code, there is no response from the modem (buffer empty). But when I run using hyperterminal, it comes out fine (I get "OK" as the response for my AT command). Then, when I run my code after that only will I get response from the modem, as expected. I've been experiencing this problem for some days.
Another problem is that sometimes there are some weird characters, instead of the correct characters, are mixed in the response. But they are not random characters. Every time the weird characters come in the response, they are the same ones. For example, if I send ATE0, in the response, instead of the letter 'O' for OK, there is another character in its place, but the 'K' comes out correct. This problem is hard to be reproduced because I'm not sure why it happens, but it happens quite often, usually when there is a problem with the previous sending of command, I think.
Any help would be much appreciated.
Thanks
-
February 3rd, 2012, 12:37 PM
#2
Re: Problem with modem response for AT commands
The description you provide sounds like, maybe, invalid line settings with the modem. Try commenting out the lines below and see what happens.
m_comport.dcb.fOutxCtsFlow = TRUE;
m_comport.dcb.fTXContinueOnXoff = TRUE;
m_comport.dcb.fRtsControl = RTS_CONTROL_HANDSHAKE;
m_comport.dcb.fAbortOnError = TRUE;
m_comport.dcb.XonLim = 80;
m_comport.dcb.XoffLim = 200;
Also double check some additional stuff
is the modem internal? If so, make sure it is not configured for a com port that might already exist, in other words, make sure you don't have 2 pieces of hardware configured for the same serial port.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|