in reply to perl tk and Device::Modem

With the exception of not using warnings and strict, it SEEMS like you are doing it right. Sadly, I have a DSL modem now, and will have to test this later on a different machine. BUT, there are some things you can try.

If you look at the dial method in Modem.pm, it incorporates a timeout, and it probably is "blocking the gui" while it dials and waits for the timeout to connect. So during that time Tk is blocked. A possible solution, is not to use the dial method, and manually send out each digit at a time, and in-between let Tk do a 1-loop, to see if you hit the cancel button. Something like:

use Tk::Event qw(DONT_WAIT); sub push_button { $txt -> insert ('end',"Dialing $number\n"); #$modem->dial($number); my (@n) = $number =~ /\d/g; foreach my $d (@n){ $modem->atsend( 'ATDT'. $d . Device::Modem::CR ); DoOneEvent(DONT_WAIT); } }

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: perl tk and Device::Modem
by strange1 (Initiate) on Apr 25, 2006 at 20:22 UTC
    Thanks for the reply.
    Really, I would like the option to hangup after dialing (when ringing/answer phone). It seems that the gui is locked until the modem has finished dialing and an answer is returned.
      You might want to experiment with the timeout setting, like setting it to 1 (it defaults to 30 seconds ). There is a way to do what you want, you may have to resort to manually accessing the modem thru directly opening it and writing AT commands to it. If you read the Modem.pm file, it shows exactly what it sends. Also try $modem->reset() instead of $modem->$hangup().

      People are starting to forget how to use the old phone-line modems. :-)

      Instead of using Device::Modem, you can use Device::SerialPort directly. There are some example in the eg directory of Device::SerialPort, and you should be able to do what you want. As a matter of fact the demo7.plx is a Tk script to dial out on a modem

      If my memory servers me correctly, I recall that you can send modem dialing commands with shell commands, like

      echo 'ATH0' > /dev/ttyS0 #go offhook echo 'ATDT123456789' > /dev/ttyS0 # dial
      There is a hangup command too, but I can't recall it offhand. So you could rewrite your script to use a more manual method of dialing.

      I'm not really a human, but I play one on earth. flash japh