Solved

Serial Com

Posted on 2006-10-26
3
959 Views
Last Modified: 2012-08-13
Hi
I'm trying to establish GPRS connection in winxp via my phone used as modem on COM3.
I have used CreateFile, ReadFile, WriteFile for sending and receiving AT-commands and it seems to work as expected. However part of the response i get after sending a command is not returned before i send the next command.

Example:
Send1: ATZ\r
Receive1: ATZ\r
Send2: AT+CGATT=1\r
Receive2: \r\nOK\r\nAT+CGATT=1\r

The \r\nOK\r\n part i would like to be returned at the end of first reception, but not sure how to do this. I sniffed winxp dialup to see how it is done and it seems to use IOCTL_SERIAL_GET_COMMSTATUS: Retrieve COM status, in order to get last bytes. However I'm not sure how to do this in my program

Thanks in advance
0
Comment
Question by:connerdk
3 Comments
 
LVL 16

Accepted Solution

by:
PaulCaswell earned 250 total points
ID: 17821737
Hi connerdk,

You need to give time for the OK to come through after Receive1:ATZ\r.

The ATZ is a command to the modem. The modem will echo every character you type/send. When it receives the \r it begins to execute the command. When you read what is in the comms buffer after you send the \r you are reading the characters it has already echoed. If you wait, perhaps up to about one second, checking for the 'OK' to come back it should arrive. You should do this for all commands you send.

Paul
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question