Hayes AT Commands: Detect Remote Hangup?

前端 未结 2 1803
死守一世寂寞
死守一世寂寞 2020-12-20 06:39

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/ttyS

相关标签:
2条回答
  • 2020-12-20 06:59

    This is a hardware signal on modems, the Carrier Detect (CD) line. You'll need to monitor it to know that the connection was lost. Basics in linux are described in this how-to, you obtain the signal state with ioctl() using the TIOCM_CAR command.

    0 讨论(0)
  • 2020-12-20 07:04

    Testing for NO CARRIER as 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.

    0 讨论(0)
提交回复
热议问题