1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/usr/bin/perl
#
# Simple test program that executes a modem `shell'
# to monitor AT command results.
#
# ******************************************
# If it does not work, try with baud = 9600
#
# $Id: shell.pl,v 1.6 2005-04-30 21:45:47 cosimo Exp $
use strict;
use Device::Modem;
if( $> && $< ) {
print "\n*** REMEMBER to run this program as root if you cannot connect on serial port!\n";
sleep 3;
}
print "Your serial port? [/dev/ttyS0]\n";
my $port = <STDIN>;
chomp $port;
$port ||= '/dev/ttyS0';
print "Your baud rate? [19200]\n";
my $baud = <STDIN>;
chomp $baud;
$baud ||= 19200;
my $modem = Device::Modem->new( port => $port );
my $stop;
die "Could not connect to $port!\n" unless $modem->connect( baudrate => $baud );
print "Connected to $port.\n\n";
while( not $stop ) {
print "insert AT command (`stop' to quit)\n";
print "> ";
my $AT = <STDIN>;
chomp $AT;
if( $AT eq 'stop' ) {
$stop = 1;
} else {
$modem->atsend( $AT . "\r\n" );
print $modem->answer(), "\n";
}
}
print "Done.\n";
|