How are you supposed to programatically detect when the remote modem on your call hangs up? I am writing a C program which interfaces with a SoftModem device /dev/ttySL0 in Ubuntu linux. I am able to configure the modem using Hayes AT commands and communicate with the remote modem. However, I haven’t been able to determine how I’m supposed to detect that the other end has hung up the line.
I have the modem configured so that when the other end hangs up, the device prints NO CARRIER and switches to command mode. However, I can’t use the NO CARRIER string because I can’t guarantee that the modem won’t receive that string while in data mode.
How do you “listen” for remote hang up?
Testing for
NO CARRIERas text will not suffice. This text frequently occurs on sites in the net, even on Q&A sites.Coming from the modem, it should be enclosed in line breaks.
Besides, after you detect that text, you can try to switch to command mode with
+++. If that works, your connection persists and you can reattach it and continue using it. If it doesn’t (because you are already there and+++is an invalid command), the connection has gone.