LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-14-2004, 01:20 PM   #1
rohan208
Member
 
Registered: May 2004
Posts: 75

Rep: Reputation: 15
modem talk... anyone?


hello,
does anyone know how do i connect and send AT commands to a modem on ttyUSB0 without using the kppp or minicommn applications..? I am willing to write a C program to do that,, I need to know how to get started.. any oen has doen this?

Sincerely,
Rohan
 
Old 07-14-2004, 01:37 PM   #2
hoarenet
LQ Newbie
 
Registered: Jun 2004
Distribution: Mandrake 10
Posts: 29

Rep: Reputation: 15
Do you know all your modems commands and how to switch it to command mode?

I suspect you use the pipe symbol "|" and point your command to the modem port. Like this.

echo "m0" | tty0 /* Switch off the modem speaker
If your modem is on that port. That is. */

You will probably have to be in SU mode to do this.

I hope you get a more informative post than mine but I think this will put you in the right direction for now.
 
Old 07-14-2004, 01:44 PM   #3
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
all io in unix is done through file descriptors hence the saying "Everything in unix is a file" so you need do nothing more than to open your device node and start writing to it(assuming the serial port is set up)

something like:
Code:
main()
{
 int fd;
 char *x = "command for modem"; //dont forget to remove the \0 if you dont want it

 fd = open("/dev/ttyUSB0", O_RDRW);
 write(fd, x, sizeof(x));

 ...
 ...
}
you could of course just use cat or echo to send your command to the modem but it sounded like you wanted some C code so there you go.

<edit>

by hoarenet
I suspect you use the pipe symbol "|" and point your command to the modem port.

you dont want to use | cos that passes the output to the next command you would use > to redirect stdout of cat/echo to the device node. eg

echo "modem command" > /dev/ttyUSB0

</edit>

Last edited by kev82; 07-14-2004 at 01:48 PM.
 
Old 07-14-2004, 02:03 PM   #4
rohan208
Member
 
Registered: May 2004
Posts: 75

Original Poster
Rep: Reputation: 15
Thanks a lot for prompt replies guys.. really appriicate that.
Back to the topic.. That was the first hitng i had tried..
echo "ATDT 9982239" > /dev/usb/ttyACM0

my modem is my motorola phone and thats the location. But now my question is how do i know what the phone has replied with? i tried

tail -f /dev/usb/ttyACM0
but the output didnt change..
any ideas any one?

Thanks a lot for ur help.
Rohan
 
Old 07-14-2004, 02:38 PM   #5
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
im afraid i know nothing about modems but i think you'll need to write your own c program that sends stdin to the device and maps stuff from the device to stdout. there is most likely some info on this sort of stuff in the modem howto here
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
want to talk to serial modem Xanadu Linux - Software 3 01-12-2005 03:44 PM
talk talk daemon configuration ananthkrk Red Hat 1 10-16-2004 11:45 AM
Mandrake 6.5, Modem Working but linux wont talk to it SilverRock Mandriva 1 08-30-2004 08:38 PM
why cannot "talk" to others,since mesg is yes and disable = no(in /etc/xinetd.c/talk) whepin Linux - Newbie 0 12-31-2001 02:04 AM
Network Navigator won't talk to my modem rdaves@earthlink.net Linux - Networking 4 06-16-2001 11:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration