Solved

Modem communication over serial port

Posted on 2006-10-26
3
782 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
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 and use conditional statements in the C programming language.

790 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