+

Optimize return in non-debug mode

Benjamin Renard [2012-07-26 10:38:59]
Optimize return in non-debug mode
Filename
gnokii-init-modem
diff --git a/gnokii-init-modem b/gnokii-init-modem
index 58bfc08..77945e0 100755
--- a/gnokii-init-modem
+++ b/gnokii-init-modem
@@ -33,6 +33,9 @@ my $databits = 8;			# Between 5 and 8. Only 8 is commonly used.
 my $stopbits = 1;			# Set to 1 or 2. 1 is most common.
 my $handshake = 'rts';			# Set to 'none', 'rts' or 'xoff'

+# Auto-flush
+local $| = 1;
+
 # Functions

 sub debug {
@@ -47,7 +50,7 @@ sub debug {

 # Main code

-print "Initialising GSM modem at $port_name...";
+print "Initialising GSM modem at $port_name ...";

 debug "";
 debug "Open device $port_name";
@@ -85,15 +88,15 @@ if ($string_in =~ /CME ERROR/ms) {
 	(my $count_in, my $string_in) = $PortObj->read(256);
 	debug "Return :\n\n----\n$string_in----\n";
 	if ($string_in =~ /OK/ms) {
-		print "Sim unlocked\n";
+		print " Sim unlocked\n";
 		exit 0;
 	}
 	else {
-		print "ERROR unlocking SIM (bad PIN code ?)\n";
+		print " ERROR unlocking SIM (bad PIN code ?)\n";
 		exit 1;
 	}
 }
 else {
-	print "SIM already unlocked\n";
+	print " SIM already unlocked\n";
 	exit 0;
 }
ViewGit