HalNineThousand has asked for the wisdom of the Perl Monks concerning the following question:

I have a program that communicates with a US Robotics external serial modem,
which has worked great until recently.  I've changed some hardware, or,
actually just moved it around, but it is not out of the question that the
boot sequence has changed some settings.

I've used this in a module that communicates with the modem:

my $device = "/dev/ttyS0";
our $spdev = Device::SerialPort->new($device);

And later I have the following routine:

sub checkonline {
        my ($state);
        $state = 0;
        if ($spdev->modemlines & $spdev->MS_RLSD_ON) {
                $state = 1;
        } else {
                $state = 0;
        }
        slog("DEBUG Online check, state: $state");
        return $state;
}

I do not know the internals, but my understanding is that this will tell if
a carrier is detected.  Many programs use this modem and the system it
connects to is hard to reach, so I have a management program that queues up
all the programs that need to use the modem to communicate with the
(difficult to reach) system on the other end.  Once one program finishes
using the modem, the next in the queue runs.  One of the first things it
does is call checkonline() (see above) to see if there is a connection.
Until this past week, that worked perfectly, but now it rarely detects the
connection.

The entire point of this routine is that, when a new program is running, I
need a way to detect quickly if it is online.  If it is, then I can call
the main menu of the remote system.  If not, then I have to redial.
Otherwise, I'd have to try to get the menu and examine all the returned
input to see if I am online or getting messages from the modem.

Are there conditions under which the above routine can't be relied on to
detect a carrier?  Are there settings I can specify that will make sure it
works every time?  Is there another way that is 100% reliable to detect if
there is a carrier?  Even detecting if the modem is on or off hook might
help, but ideally I need to know if it is online with another system.

I know some AT commands, but I do not have a very deep understanding of the
actual serial port communication and what I can trust as being true for all
(or most) modems and what is modem specific.

Thanks for any help on this!


Hal
  • Comment on Problems with Device::SerialPort (Modem Carrier Detection)

Replies are listed 'Best First'.
Re: Problems with Device::SerialPort (Modem Carrier Detection)
by zentara (Cardinal) on Dec 09, 2005 at 12:38 UTC
    I've changed some hardware, or, actually just moved it around, but it is not out of the question that the boot sequence has changed some settings.

    Your question probably contains your answer.

    Things you might look for, which could cause intermittent carrier are:

    Bad wires. Can you change the phone line? Those wires are very small and you may have damaged them (or the connector jack) when moving. Same goes for the serial port cable to the modem. Does the modem work well in other apps? If not maybe the power supply is going flaky....or maybe where it is plugged into the AC power is marginal due to a microwave or something else sharing the circuit. Have you changed the actual phone line location? 56 K modems need a good connection, make sure the line is direct to the connection box. You can try to drop your connect speed to 9600 and see if it becomes solid. If it does, the phone wire needs attention.

    It is also possible that your serial irqs got shared somehow, if you changed around cards in their slots. Sound cards like to do that.


    I'm not really a human, but I play one on earth. flash japh
      Those are some good points, and I'm looking into them. I should have specified that when I said I moved it around, I did not mean in the system itself, but outside (I had to relocate systems so they could be plugged into a UPS). So I can be sure it isn't an IRQ problem.

      I am looking into all the other possible hardware problems, but, in the meanwhile, it would help a LOT if I could rule out software and config problems. (It's really hard pursuing this problem on 2 fronts and I'm hoping to narrow it down.) If I could be sure that the function I mentioned will always work, it would help -- or if I knew that the method I'm using in calling the function in Device::SerialPort was unreliable, it would help me a LOT in my troubleshooting.

      In the meanwhile, I'm still working on the hardware issue. I'd just like to see if I can rule out the software/config end or find out if there are things I can check there. Thanks.