Solved

Modem communication over serial port

Posted on 2006-10-26
3
779 Views
Last Modified: 2011-10-03
Hi Folks,

I'm trying to build a simple application that can dial a phone number of another modem (connected to a PC) or can recieve a call from another modem.

I've expiramented both ways using an instance of HyperTerminal on each PC and it works fine. One dials, the other answers and the connection is established.

I can't get this to happen when on one side I have my C application instead of HyperTerminal. I've used the same settings as with HyperTerminal so it's verified that I have the correct parameters.

The code I use basicaly initializes the port setting and then performs a "WriteFile" function call. After that I'm supposed to hear the modem dial (in case I'm the side that's dialing) but nothing happens.

The code I used is very similar to what's in: http://web6.codeproject.com/system/SerialPortComm.asp?df=100

The only difference is that before WriteFile I have:
strcpy(command, "ATZ\aATD45716\a"); // command for modem

where the number I dial is 45716.

I case I'm trying to pick up a call my command is:
strcpy(command, "ATZ\aATS0=1\a"); // command for modem

Any idea where the problem is and how I can get this to work?

Thanks in advance.
0
Comment
Question by:chayahd99
3 Comments
 
LVL 5

Accepted Solution

by:
daohailam earned 150 total points
ID: 17812922
IMO, it should be \r or \n or both \r\n instead of \a ?
0
 
LVL 22

Expert Comment

by:grg99
ID: 17813696
One big problem is the modem expects the "A" and the "T" to come in with a typing-like pause in between them, so the modem can figure out the baud rate, parity, and number of stop bits.

try writing the characters out ONE at a TIME, with say 1/4 second pause between them.  Might work better.

In general talking to a modem is very iffy-- the exact timing and responses are not all that well defined.

0
 

Author Comment

by:chayahd99
ID: 17897661
The \r did it. Wish I knew this earlier.
Thanks a lot.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I recover data from my iphone 3g 4 54
Having a file "symlink" to a memory location (Windows) 6 169
Convert image to byte array 8 190
delete-remove 14 65
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now