os/boardsupport/haitest/bspsvs/suite/bsp/uart/group/uartscript.pl
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 #
     2 # Copyright (c) 2005-2009 Nokia Corporation 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 # Nokia Corporation - initial contribution.
    11 #
    12 # Contributors:
    13 #
    14 # Description:
    15 #
    16 
    17 use Getopt::Long;
    18 
    19 sub Usage()
    20 	{
    21 	print <<USAGE_EOF;
    22 Usage
    23 perl uartscript.pl --in=FileNameIn --out=FileNameOut --port=Port --baud=Baud --help
    24 
    25     --in=FileNameIn             : Input file name
    26 
    27     --out=FileNameOut           : Output file name
    28 
    29     --port=Port                 : Serial port number
    30 
    31     --baud=Baud                 : Baud rate of the port
    32 
    33     --help                      : This help
    34 USAGE_EOF
    35 	exit( 0 )
    36 	}
    37 
    38 sub main()
    39 {
    40 	my	$help='';
    41 	my	$input="";
    42 	my	$output="";
    43 	my	$port="";
    44 	my	$baud="";
    45 
    46 	GetOptions(
    47 		'in=s'		=> \$input,
    48 		'out=s'		=> \$output,
    49 		'port=s'	=> \$port,
    50 		'baud=s'	=> \$baud,
    51 		'help' 		=> \$help
    52 	);
    53 
    54 	if($help or ($input eq "") or ($output eq "") or ($port eq "") or ($baud eq ""))
    55 		{
    56 		Usage();
    57 		exit(0);
    58 		}
    59 
    60 	open(FIN, $input);
    61 	open(FOUT, ">$output");
    62 
    63 	foreach (<FIN>)
    64 	{
    65 		if (/<port>/)
    66 		{
    67 			s/<port>/$port/;
    68 		}
    69 		if (/<baud>/)
    70 		{
    71 			s/<baud>/$baud/;
    72 		}
    73 		print FOUT $_;
    74 	}
    75 	close(FIN);
    76 	close(FOUT);
    77 }
    78 
    79 main();