#========================================================================= 
#          Copyright © 2001-2004 QUALCOMM Incorporated.
#                     All Rights Reserved.
#========================================================================= 

#! /usr/local/bin/perl -w
# LoadShaker.pl
use lib "${ENV{BREWTOOLSDIR}}\\BREW Perl Interface";
use BREWPerlIF;
#################################################
# Load Shaker
################################################# 

# Display usage on user error.
if($#ARGV) {
	die "Usage: LoadShaker.pl <Com Port>\n";
}

# Store target name
$comPort = $ARGV[0];

$dllName = "$ENV{BTILDIR}\\OEMLayer\\QCOMOEM.dll";

printf "Connecting to device $comPort\n" ;

if(BREWPerlIF::ConnecttoDevice($comPort, $dllName)) {
	print "Connection to Device successful\n";
	} else {
	die "Could not connect to the port\n";
}

# This assumes shaker files are installed under the Grinder directory.
$moduleDir = 'shaker';
$moduleName = 'shaker';

printf "Loading modules\n";

# Load the module
$result = BREWPerlIF::LoadDeviceModule($moduleDir, $moduleName);
if($result == 0) {
	printf "Successfully loaded $moduleName module\n";
	printf "Resetting Device\n";
	$result = BREWPerlIF::ResetDevice(); 
	if($result == 0) {
		printf "Device Reset successfully\n";
	} else{
		printf "Device Reset was not successful: code: $result\n";
}


} else {
	printf "Error in loading $moduleName code: $result\n";
}

	
