cbsref/telephonyrefplugins/atltsy/config/modifycommdb.pl
changeset 49 f50f4094acd7
equal deleted inserted replaced
48:14460bf2a402 49:f50f4094acd7
       
     1 #!perl -w
       
     2 # Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
       
     3 # All rights reserved.
       
     4 # This component and the accompanying materials are made available
       
     5 # under the terms of "Eclipse Public License v1.0"
       
     6 # which accompanies this distribution, and is available
       
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #
       
     9 # Initial Contributors:
       
    10 # Symbian Foundation - initial contribution.
       
    11 #
       
    12 # Contributors:
       
    13 #
       
    14 # Description:
       
    15 # This modifies CommDB for the AT LTSY modem, asking the user for the comm port and baud rate to use.
       
    16 # 
       
    17 #
       
    18 
       
    19 use strict;
       
    20 
       
    21 
       
    22 # Ask for the COM port and Baud
       
    23 my $com;
       
    24 my $baud;
       
    25 print "What COMM port is the modem on?\n(Note: Symbian COMM ports are 1 less than windows)\n\tCOMM::";
       
    26 chomp ($com = <>);
       
    27 
       
    28 print "What is the baud rate of the modem?\n(Wavecomm default is 9600, Telit default is 152000)\n\tBaud=";
       
    29 chomp ($baud = <>);
       
    30 
       
    31 #print "\nComm::$com Baud=$baud\n";
       
    32 
       
    33 # Open the config files
       
    34 my $defaultcomdb = "<./AT-LTSY(default).cfg";
       
    35 my $commdb = ">/epoc32/winscw/c/AT-LTSY.cfg";
       
    36 
       
    37 open(COMMDBOUT, $commdb);
       
    38 open(COMMDBREAD, $defaultcomdb);
       
    39 
       
    40 # Read in the default commdb and write it out to the new file, changing the com port and baud where necessary
       
    41 my $modembearertable = 0;
       
    42 my $modementry = 0;
       
    43 
       
    44 while(<COMMDBREAD>)
       
    45 {
       
    46 my($line)=$_;
       
    47 
       
    48 # first wait till we've found the $modembearertable line.
       
    49 if ($line =~ m/^\[ModemBearer\]/) 
       
    50 	{
       
    51 	#print "Found the modem bearer table\n";
       
    52 	$modembearertable = 1;
       
    53 	}
       
    54 # Or if we've got the end of the table unset the boolean
       
    55 elsif ($modembearertable && $line =~ m/^\[/) 
       
    56 	{
       
    57 	#print "Found the end fo the modem bearer table\n";
       
    58 	$modembearertable = 0;	
       
    59 	}
       
    60 
       
    61 # If we're in the modem table then check for a few things
       
    62 if ($modembearertable)
       
    63 	{
       
    64 	# Now wait till we've got to an entry for our modem
       
    65 	if ($line =~ m/^\sName=CommModem/) 
       
    66 		{
       
    67 		#print "Found the modem entry\n";
       
    68 		$modementry = 1;
       
    69 		}
       
    70 
       
    71 	# Or if we've reached the end of the modem entry unset the boolean
       
    72 	if ($modementry && $line =~ m/^END_ADD/) 
       
    73 		{
       
    74 		#print "Found the end of the modem entry\n";
       
    75 		$modementry = 0;
       
    76 		}
       
    77 	}
       
    78 
       
    79 # If we're in the entry for our modem then potentially modify the line
       
    80 if ($modementry)
       
    81 	{
       
    82 	# If it's the comm port number set that up
       
    83 	if ($line =~ m/^\sPortName=COMM::/) 
       
    84 		{
       
    85 		print "\tSetting the COMM port\n";
       
    86 		$line = "\tPortName=COMM::$com\n"
       
    87 		}
       
    88 	
       
    89 	# If it's the rate then set that up
       
    90 	if ($line =~ m/^\sRate=/) 
       
    91 		{
       
    92 		print "\tSetting the Baud rate\n";
       
    93 		$line = "\tRate=$baud\n"
       
    94 		}
       
    95 	}
       
    96 
       
    97 # Write out the (modified) line to the new commdb
       
    98 print COMMDBOUT $line;
       
    99 }
       
   100 
       
   101 # Close the files
       
   102 close(COMMDBOUT);
       
   103 close(COMMDBREAD);
       
   104 
       
   105