[Melbourne-pm] Driving a serial command line device with Perl

Daniel Pittman daniel at rimspace.net
Mon Oct 9 20:01:06 PDT 2006

"Sisyphus" <sisyphus1 at optusnet.com.au> writes:
> From: "Daniel Pittman" <daniel at rimspace.net>
>> When my DESTROY method was called, though, the reference to the expect
>> object was always undef and, with debugging enabled, I could see that it
>> was destroyed immediately prior to my DESTROY method being called.
> Does your DESTROY method try to clean up the Expect object?  Expect
> will call it's own DESTROY method on its own objects - your DESTROY
> should not do that.

Er, no, sorry if that wasn't clear.  What I tried to do was:

    my $self = ...;
    if ($self->{serial}) {
        $self->{serial}->send("exit\n");  # log out of the device
        $self->{serial}->soft_close();    # wait for that to acknowledge

In other words, I tried to use the object that I manage to send the
correct sequence to log out, and wait for the device to do so.

Once my object goes out of scope the Expect object would be cleaned up,
of course, and I wasn't trying to do anything like that -- just to make
sure that my code doesn't need to call an additional method to send that
exit sequence.[1]


[1]  ...and, yes, the lifetime rules do support that, and I am careful
     about tracking manual disconnects as well, and so forth.  
Digital Infrastructure Solutions -- making IT simple, stable and secure
Phone: 0401 155 707        email: contact at digital-infrastructure.com.au

More information about the Melbourne-pm mailing list