os/boardsupport/haitest/bspsvs/suite/bsp/uart/group/uartscript.pl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
#
sl@0
     2
# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     3
# All rights reserved.
sl@0
     4
# This component and the accompanying materials are made available
sl@0
     5
# under the terms of "Eclipse Public License v1.0"
sl@0
     6
# which accompanies this distribution, and is available
sl@0
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     8
#
sl@0
     9
# Initial Contributors:
sl@0
    10
# Nokia Corporation - initial contribution.
sl@0
    11
#
sl@0
    12
# Contributors:
sl@0
    13
#
sl@0
    14
# Description:
sl@0
    15
#
sl@0
    16
sl@0
    17
use Getopt::Long;
sl@0
    18
sl@0
    19
sub Usage()
sl@0
    20
	{
sl@0
    21
	print <<USAGE_EOF;
sl@0
    22
Usage
sl@0
    23
perl uartscript.pl --in=FileNameIn --out=FileNameOut --port=Port --baud=Baud --help
sl@0
    24
sl@0
    25
    --in=FileNameIn             : Input file name
sl@0
    26
sl@0
    27
    --out=FileNameOut           : Output file name
sl@0
    28
sl@0
    29
    --port=Port                 : Serial port number
sl@0
    30
sl@0
    31
    --baud=Baud                 : Baud rate of the port
sl@0
    32
sl@0
    33
    --help                      : This help
sl@0
    34
USAGE_EOF
sl@0
    35
	exit( 0 )
sl@0
    36
	}
sl@0
    37
sl@0
    38
sub main()
sl@0
    39
{
sl@0
    40
	my	$help='';
sl@0
    41
	my	$input="";
sl@0
    42
	my	$output="";
sl@0
    43
	my	$port="";
sl@0
    44
	my	$baud="";
sl@0
    45
sl@0
    46
	GetOptions(
sl@0
    47
		'in=s'		=> \$input,
sl@0
    48
		'out=s'		=> \$output,
sl@0
    49
		'port=s'	=> \$port,
sl@0
    50
		'baud=s'	=> \$baud,
sl@0
    51
		'help' 		=> \$help
sl@0
    52
	);
sl@0
    53
sl@0
    54
	if($help or ($input eq "") or ($output eq "") or ($port eq "") or ($baud eq ""))
sl@0
    55
		{
sl@0
    56
		Usage();
sl@0
    57
		exit(0);
sl@0
    58
		}
sl@0
    59
sl@0
    60
	open(FIN, $input);
sl@0
    61
	open(FOUT, ">$output");
sl@0
    62
sl@0
    63
	foreach (<FIN>)
sl@0
    64
	{
sl@0
    65
		if (/<port>/)
sl@0
    66
		{
sl@0
    67
			s/<port>/$port/;
sl@0
    68
		}
sl@0
    69
		if (/<baud>/)
sl@0
    70
		{
sl@0
    71
			s/<baud>/$baud/;
sl@0
    72
		}
sl@0
    73
		print FOUT $_;
sl@0
    74
	}
sl@0
    75
	close(FIN);
sl@0
    76
	close(FOUT);
sl@0
    77
}
sl@0
    78
sl@0
    79
main();