Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RING event on the serial port

Status
Not open for further replies.

ruchika

Programmer
Aug 22, 2003
5
US
Hi,

I have a modem that is connected to the serial port of my RedHat Linux machine and I want to listen for RING events on this port. For this, I open the COM port, select the file descriptor and wait for an event to occur. I get the interrupt when I dial my modem, but how can I make sure that select returned because of RING event and not because of some other activity on the serial port?

Thanks,
Ruchika
 
how do you speak with your modem? your own interrupt drivers? when opening a modem via tty you must then be able to Rx and Tx data... the ring comes as "RING" in the Rx queue, is there another way?

try also some sources from mgetty

petmakris

 
Thanks for replying Victorv and Karoline.
Karoline, you are right .. I get "RING" in the receive queue, so I know that select returned because of RING interrupt, but now i have anther question .. I want to talk to a remote PPP server via a Hayes compatible 1X modem when I get a ring interrupt. The modem is connected to the serial port of the Linux box. Heres what I do - I open the COM port, select the port and wait for an event to occur. If I get RING event, I close the COM port and run a script that establishes a PPP connection (runs pppd and chat). Whats happening now is that the I am not able to talk to my modem. The chat script sends AT command to the modem but does not get response from the modem. After a few secs, I see alarm FAILED in /etc/ppp/connect-errors file. I think that somehow the COM port is not getting released and so PPP script is not able to talk to the modem. But I may be wrong. Any clues on what might be happening?
Victorv, I browsed through the ioctl man pages and realised that the above method might be simpler. Any suggestions?
I used minicom to talk to the modem and that works fine. The same chat script used to work until I added the "listen on Ring interrupt" feature. Thats why I suspect that the problem has to do with the COM port.
BTW, I am running RedHat Linux 9.0 and am using C++ for port handling and a shell script to establish PPP connection.
Thanks for your help.
 
hello ruchika,I have being working the same item as yours,
my problem now is I can dial other phone but can't receive
any other call,that is i can't receive the message "ring".

thanks

toto
 
Hi ruchika,

Heres what I do - I open the COM port, select the port and wait for an event to occur. If I get RING event, I close the COM port and run a script that establishes a PPP connection (runs pppd and chat). Whats happening now is that the I am not able to talk to my modem.

I can't exactly understand what your code (maybe i am missleading you or saying useless stuff) does exactly but why you are closing the COM port and then run a script? ...


I think that somehow the COM port is not getting released and so PPP script is not able to talk to the modem.

should it be released? probably i can help u! :-(
 
Hi,

toto2717, I am not sure what exactly you are doing, but here are a few pointers -

1) Inorder to get "RING", you might have to enable Autoanswer and Answer call options in the modem. For example, the 1X modem that I am using has these settings off by default, so when my application starts, its enables Autoanswer by sending "ATS0=1" and Answer Data call by sending AT$QCVAD=4 to the modem. After enabling these settings, select the COM port on which the modem is connected (Linux select() call), call/ping the modem, select will return, read the RX queue, if you get "RING" in the RX queue means you received a RING.

2) I have configured my chat script to abort if it receives a "RING". But I haven't seen chat abort when I ping the modem. Not sure whats happening. Will have to debug more to find out.

Would anyone know how to get the exit code of chat? I have 2 scripts, a ppp-on script that starts pppd and a ppp-on-dialer that starts chat. The ppp-on script starts ppp-on-dialer script. I run ppp-on script from my C function using system call. Using the following two lines, I can know the exit code of ppp-on.
int ret = system("./ppp-on")
printf("%d", WEXITSTATUS(ret));

But how can I know the return code of chat? This is how my chat script looks.

exec chat -v -s
ABORT 'RING'
ABORT 'NO CARRIER'
'' AT
TIMEOUT 3
OK 'ATS0=1'
OK 'AT$QCVAD=4'
OK ATD$TELEPHONE
TIMEOUT 45
CONNECT ''

In the /var/run/ folder, I see a pppd.tdb file which doesn't go away irrespective of whether pppd is running or not. Would you know what this file is? And should cleanup script remove this file as well? Is there a way of specifying the number of times chat/pppd should try to establish connection before returning failure?

Karoline, the reason I am closing the COM port and then running the script is - The responses to AT commands sent by the PPP script were being picked up by another application that is waiting for a RING to happen on the COM port. Hence, the PPP script keeps looping. As soon as I kill the application that is waiting/listening for an event to happen on the COM port, the PPP script gets the response and establishes the connection.

All responses are highly appreciated.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top