Solved

Modem communication over serial port

Posted on 2006-10-26
3
778 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
Comment Utility
IMO, it should be \r or \n or both \r\n instead of \a ?
0
 
LVL 22

Expert Comment

by:grg99
Comment Utility
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
Comment Utility
The \r did it. Wish I knew this earlier.
Thanks a lot.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
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…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

771 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

11 Experts available now in Live!

Get 1:1 Help Now