Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C prog to talk to modem in UNIX

Posted on 1998-09-01
7
Medium Priority
?
232 Views
Last Modified: 2010-04-15
I'm trying to communicate with my modem hanging from /dev/ttyS1 on my Linux machine.  I'm trying to write something to talk to the modem in C/C++ and I can write data to it, I just can't read the response.  For example if I send down an ATDT1234 I can hear the modem go off the hook and dial (then hangup) however I can't get the response back  from the modem to manipulate in my program.

I'd like some sample code if anyone has got it, on how to send an AT command to the modem and monitor the modem for its response, and no DOS/Win code please, only code suitable for Linux/*nix.

Thanks in advance
0
Comment
Question by:carterl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 2

Expert Comment

by:kellyjj
ID: 1252447
how did you open the port and send data to it???
0
 

Author Comment

by:carterl
ID: 1252448
I basically tried all three approaches that are in the Linux Serial Port Programming Howto (a copy of which can be found at http://www.caldera.com/LDP/HOWTO/Serial-Programming-HOWTO.html)

I cut and paste the the example 3.3 for Async input and the only alteration was to put above the while loop a write statement dumping a char array which held "ATDT123\r".  It sent the command out, and generated the events however when it displayed the data read back in the input buffer held the same "ATDT123\r" text and nothing else.  This seems the case no matter what I send to the modem.

Thanks for your reply, it's greatly appreciated.
0
 
LVL 2

Expert Comment

by:kellyjj
ID: 1252449
did you try to send anything else??   YOu should try to send just 'AT'  and see if you get 'OK' back.  Also, what kind of init string are you sending.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:carterl
ID: 1252450
I've tried just AT on it's own, and other AT commands with the same lack of response.  I've tried sending the same init string that minicom (a Unix procomm lookalike) sends, and that doesn't seem to do anything either.  If I use something like seyon or minicom I can enter AT and get and OK back.
0
 
LVL 2

Expert Comment

by:JYoungman
ID: 1252451
You may want to set the serial port's mode to "raw".
How to do this is explained in the manpage for termios.

This question belongs in the "Unix Programming" forum, not this one.

0
 

Accepted Solution

by:
mweilguni earned 300 total points
ID: 1252452
This is easy, just get the pppd source code from
http://sunsite.unc.edu/pub/Linux/system/network/serial/ppp/
and untar it. There is a subdirectory "chat" containing the source for the chat-program (typically /usr/sbin/chat). The source code contains all informations you need for your task.

You might also download kppp, a dialer for Linux/KDE from my homepage http://homepage.sime.com/mweilguni and take a look into connect.cpp and modem.cpp.


0
 

Author Comment

by:carterl
ID: 1252453
Thanks, I've got the source somewhere on one of my Slackware CD's I'll check it out :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
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 and use structures in the C programming language.
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.

618 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