use UARTchan; require 'TdWrapper.pl'; Test_Run( 'Full UART Bit Test - $Change: 2944 $' ); sub main { my( $why ); # establish the testing context and assert needed connections unless( initialize( ) ) { $why = IpdrTest_LastFailure( ); IpdrTest_EndLog( ); # assumes the logging got started return 'Failed to initialize: ' . $why; } print "UART Full Test \n"; IpdrTest_Identify( 'UART Full Test ' ); if( IpdrTest_Failure( ) ) { $why = IpdrTest_LastFailure( ); IpdrTest_EndLog( ); return 'Failed to identify: ' . $why; } # conduct the many test steps print "Test begun\n" ; IpdrTest_PrintLog( "Test begin\n\n" ); fillupUART(); print "Test done\n"; # conclusion of test. really only a wrapup of logging. IpdrTest_EndLog( ); if( IpdrTest_Failure( ) ) { return IpdrTest_LastFailure( ); } return 'Ok'; } ... ... ... sub fillupUART{ # Generate global data variable our( $data ); # Generate the UART Channel Object our( $testChan ) = new UARTchan(); # Prompt User for the STE Uart channel, loop until 'Exit' selected TOPLOOP: while(1){ printMenu(); # Print the menu } $testChan->DESTROY; UARTchan->END; # Destroy ALL Objects of the UARTchan class } ... ... ... #### package UARTchan; require 'TdWrapper.pl'; ########################################### #### Class Data #### ########################################### my $UARTobjs = 0; my $stepNumber = 0; # Used during testing, all objects linked my $subStepNum = 0; ########################################### #### Object Constructor #### ########################################### sub new { my $proto = shift; my $class = ref($proto) || $proto; my $this = {}; # Data Members $this->{IPDRUART} = undef; $this->{IPDRDATA} = undef; # The IPDR UART Data buffer, read and written to $this->{IPDRCONF} = undef; # Data member is used in both the config and block commands $this->{STEUART} = undef; $this->{STEBAUD} = undef; $this->{STEDATA} = undef; # The STE UART Data buffer, read and written to $this->{COMPBIT} = undef; # Tells the calculation method which way to compare the data members # Class Data $this->{"_UARTobjs"} = \$UARTobjs; # Storing a reference to this global in "_UARTobjs" bless($this, $class); ++ ${ $this->{ "_UARTobjs" } }; # Increment the reference printf( "Info> There are currently $UARTobjs UART Objects.\n" ); return($this); } ... ... ... sub steuartopen { my $this = shift; # Increase global count ++$stepNumber; $subStepNum = 0; # Reset Substep count to 0 IpdrTest_StepBegin( "$stepNumber.$subStepNum" ); printf( "Info> Configuring the IP521 UART.\n" ); IpdrTest_PrintLog( "Info> Configuring the IP521 UART.\n" ); # Set the STE IP521 UART as Open STE_Config_UART( $this->{STEUART}, 'Open' ); if( IpdrTest_Failure( ) ) { IpdrTest_Failed( IpdrTest_LastFailure( ) ); printf( "Warning> $stepNumber.$subStepNum failed : Unable to 'Open' device.\n" ); IpdrTest_PrintLog( "Warning> $stepNumber.$subStepNum failed : Unable to 'Open' device.\n" ); IpdrTest_StepFailed(); die "Step $stepNumber.$subStepNum failed"; } # Set the STE IP521 UART BAUD rate STE_Config_UART( $this->{STEUART}, $this->{STEBAUD} ); if( IpdrTest_Failure( ) ) { IpdrTest_Failed( IpdrTest_LastFailure( ) ); printf( "Warning> $stepNumber.$subStepNum failed : Unable to set device baud rate.\n" ); IpdrTest_PrintLog( "Warning> $stepNumber.$subStepNum failed : Unable to set device baud rate.\n" ); IpdrTest_StepFailed(); IpdrTest_StepEnd(); die "Step $stepNumber.$subStepNum failed"; } printf( "Step $stepNumber.$subStepNum passed\n" ); IpdrTest_PrintLog( "Step $stepNumber.$subStepNum passed\n" ); IpdrTest_StepPassed(); IpdrTest_StepEnd(); }