telephonyserverplugins/attestltsy/config/modifycommdb.pl
branchAT_Test_LTSY
changeset 6 9b3b5a50db11
child 10 4d82aaca4452
equal deleted inserted replaced
5:c646ab78f948 6:9b3b5a50db11
       
     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 simple script shows how to modify the content of a feature manager
       
    16 # data file.
       
    17 # 
       
    18 #
       
    19 
       
    20 use strict;
       
    21 
       
    22 
       
    23 # Ask for the COM port and Baud
       
    24 my $com;
       
    25 my $baud;
       
    26 print "What COMM port is the modem on?\n(Note: Symbian COMM ports are 1 less than windows)\n\tCOMM::";
       
    27 chomp ($com = <>);
       
    28 
       
    29 print "What is the baud rate of the modem?\n(Wavecomm default is 9600, Telit default is 152000)\n\tBaud=";
       
    30 chomp ($baud = <>);
       
    31 
       
    32 print "\nComm::$com Baud=$baud\n";
       
    33 
       
    34 # Open the config files
       
    35 my $defaultcomdb = "<./AT-LTSY(default).cfg";
       
    36 my $commdb = ">>../../../../../../epoc32/winscw/c/AT-LTSY.cfg";
       
    37 #my $commdb = ">./AT-LTSY.cfg";
       
    38 
       
    39 open(COMMDBOUT, $commdb);
       
    40 open(COMMDBREAD, $defaultcomdb);
       
    41 
       
    42 # Read in the default commdb and write it out to the new file, changing the com port and baud where necessary
       
    43 my $modembearertable = 0;
       
    44 my $modementry = 0;
       
    45 
       
    46 while(<COMMDBREAD>)
       
    47 {
       
    48 my($line)=$_;
       
    49 
       
    50 # first wait till we've found the $modembearertable line.
       
    51 if ($line =~ m/^\[ModemBearer\]/) 
       
    52 	{
       
    53 	print "Found the modem bearer table\n";
       
    54 	$modembearertable = 1;
       
    55 	}
       
    56 # Or if we've got the end of the table unset the boolean
       
    57 elsif ($modembearertable && $line =~ m/^\[/) 
       
    58 	{
       
    59 	print "Found the end fo the modem bearer table\n";
       
    60 	$modembearertable = 0;	
       
    61 	}
       
    62 
       
    63 # If we're in the modem table then check for a few things
       
    64 if ($modembearertable)
       
    65 	{
       
    66 	# Now wait till we've got to an entry for our modem
       
    67 	if ($line =~ m/^\sName=CommModem/) 
       
    68 		{
       
    69 		print "Found the modem entry\n";
       
    70 		$modementry = 1;
       
    71 		}
       
    72 
       
    73 	# Or if we've reached the end of the modem entry unset the boolean
       
    74 	if ($modementry && $line =~ m/^END_ADD/) 
       
    75 		{
       
    76 		print "Found the end of the modem entry\n";
       
    77 		$modementry = 0;
       
    78 		}
       
    79 	}
       
    80 
       
    81 # If we're in the entry for our modem then potentially modify the line
       
    82 if ($modementry)
       
    83 	{
       
    84 	# If it's the comm port number set that up
       
    85 	if ($line =~ m/^\sPortName=COMM::/) 
       
    86 		{
       
    87 		print "Changing COMM port\n";
       
    88 		$line = "\tPortName=COMM::$com\n"
       
    89 		}
       
    90 	
       
    91 	# If it's the rate then set that up
       
    92 	if ($line =~ m/^\sRate=/) 
       
    93 		{
       
    94 		print "Changing Baud rate\n";
       
    95 		$line = "\tRate=$baud\n"
       
    96 		}
       
    97 	}
       
    98 
       
    99 # Write out the (modified) line to the new commdb
       
   100 print COMMDBOUT $line;
       
   101 }
       
   102 
       
   103 # Close the files
       
   104 close(COMMDBOUT);
       
   105 close(COMMDBREAD);
       
   106 
       
   107 
       
   108 
       
   109 # Open the .cfg file and read each line
       
   110 
       
   111 #rename($datfile, $datfileback) or die "Couldn't backup feature data file '$datfile'\n";
       
   112 #rename($datfile2, $datfile) or die "Couldn't copy feature data file '$datfile2'\n";
       
   113 
       
   114 #printf ("\tFeature Database setup\n");
       
   115 #
       
   116 # Example code to remove a feature flag.
       
   117 #
       
   118 #$fmc->RemoveFeatureFlagByUID($ffuid) or die "Couldn't remove feature flag\n";
       
   119