Permalink
Browse files

updated autoscan utility with usage

git-svn-id: svn://localhost:81/cpan/perl5-device-gsm/trunk@122 16b0436d-b983-6540-bd0b-04945bd77856
  • Loading branch information...
1 parent 78c6fab commit dcb12359aaba1e68d5541620cdaa1a29f1657e7d @cosimo committed Jan 10, 2004
Showing with 83 additions and 55 deletions.
  1. +83 −55 bin/autoscan
View
@@ -1,55 +1,83 @@
-#!/usr/bin/perl
-#
-# Autoscan utility
-# Creates a log file with all commands
-#
-# Please send the `profile.log' generated file to
-# cosimo@cpan.org with subject "Device::Gsm profile"
-#
-# Usage: autoscan --port=/dev/ttyS0 --baud=19200 --file=profile.log
-#
-# $Id: autoscan,v 1.3 2003-12-15 23:39:04 cosimo Exp $
-
-use Device::Gsm;
-use Getopt::Long;
-
-my $port = '/dev/ttyS1';
-my $baud = 19200;
-my $file = 'profile.log';
-
-GetOptions( 'port:s'=>\$port, 'baud:i'=>\$baud, 'file:s'=>\$file );
-
-my $gsm = new Device::Gsm( port => $port, log=>"file,$file", loglevel=>'info' );
-$gsm->connect( baudrate => $baud ) or die "could not connect!\n";
-
-print "Auto scan of device on $port (\@ $baud bps)\n\n";
-$gsm->log->write('info', "# Autoscan of device on port $port (\@ $baud bps)");
-$gsm->log->write('info', '# Device::Gsm v'.Device::Gsm->VERSION().', Device::Modem v'.Device::Modem->VERSION().', perl version '.$]);
-$gsm->log->write('info', '# Started on '.localtime());
-
-
-my @command = (
- '+CCLK', '+CGMI', '+CGMM', '+CGMR', '+CGSN',
- '+CSCA', '+CSQ', '+CHUP', '+CPIN',
- '+CMGF', '+CMGL', '+CMGS',
- '^SBNR',
-);
-
-testcmd($gsm,$_) foreach @command;
-
-$gsm->datetime();
-$gsm->imei();
-$gsm->manufacturer();
-$gsm->model();
-$gsm->software_version();
-$gsm->service_center();
-$gsm->signal_quality();
-$gsm->messages();
-
-sub testcmd {
- my $gsm = $_[0];
- my $cmd = $_[1];
- $gsm->log->write('info', 'testing command ['.$cmd.']');
- $gsm->test_command($cmd);
-}
-
+#!/usr/bin/perl
+
+#
+# Autoscan utility, creates a log file with all commands
+#
+# Please send the `profile.log' generated file to
+# cosimo@cpan.org with subject "Device::Gsm profile"
+#
+# Usage: autoscan --device=/dev/ttyS0 --baud=19200 --file=my_device.log
+#
+# $Id: autoscan,v 1.4 2004-01-10 21:33:46 cosimo Exp $
+
+use Device::Gsm;
+use Getopt::Long;
+
+
+my $dev = '/dev/nokia6600';
+my $baud = 19200;
+my $file = 'profile.log';
+
+usage() unless @ARGV;
+
+GetOptions( 'device:s'=>\$dev, 'baud:i'=>\$baud, 'file:s'=>\$file );
+
+my $gsm = new Device::Gsm( port => $dev, log=>"file,$file", loglevel=>'info' );
+$gsm->connect( baudrate => $baud ) or die "could not connect!\n";
+print "Auto scan of device on $dev (\@ $baud bps)\n\n";
+$gsm->log->write('info', "# Autoscan of device on device $dev (\@ $baud bps)");
+$gsm->log->write('info', '# Device::Gsm v'.Device::Gsm->VERSION().', Device::Modem v'.Device::Modem->VERSION().', perl version '.$]);
+$gsm->log->write('info', '# Started on '.localtime());
+
+my @command = (
+ '+CCLK', '+CGMI', '+CGMM', '+CGMR', '+CGSN',
+ '+CSCA', '+CSQ', '+CHUP', '+CPIN',
+ '+CMGF', '+CMGL', '+CMGS',
+ '^SBNR',
+);
+
+$gsm->log->write('info', 'Start of GSM commands support test.');
+
+testcmd($gsm,$_) foreach @command;
+
+$gsm->log->write('info', 'End of commands test. Now some methods will be called.');
+
+$gsm->datetime();
+$gsm->imei();
+$gsm->manufacturer();
+$gsm->model();
+$gsm->software_version();
+$gsm->service_center();
+$gsm->signal_quality();
+$gsm->messages();
+
+
+sub testcmd {
+ my $gsm = $_[0];
+ my $cmd = $_[1];
+ $gsm->log->write('info', 'testing command ['.$cmd.']');
+ $gsm->test_command($cmd);
+}
+
+sub usage {
+ print <<EOT;
+
+$0 - Create profile of GSM supported commands
+
+Usage: $0 [options]
+Accepted options are:
+
+ --device=<device> Device to connect to.
+ Ex.: --device=/dev/ttyS0 for serial ports
+ --device=/dev/rfcomm0 for bluetooth device
+ --baud=<baudrate> Speed of serial communication.
+ Ex.: --baud=19200 or --baud=9600
+ --file=<filename> Name of profile filename to be saved
+ Ex.: --file=my_device.log
+
+EOT
+
+ exit;
+
+}
+

0 comments on commit dcb1235

Please sign in to comment.