|
|
/*
|
/*
|
#ifndef __PEX_H__
|
#ifndef __PEX_H__
|
#include "pex.h"
|
#include "pex.h"
|
#endif
|
#endif
|
*/
|
*/
|
|
|
#include "board.h"
|
#include "board.h"
|
#include "pex_board.h"
|
#include "pex_board.h"
|
|
|
#include <cassert>
|
#include <cassert>
|
#include <cstdlib>
|
#include <cstdlib>
|
#include <cstring>
|
#include <cstring>
|
#include <iostream>
|
#include <iostream>
|
#include <iomanip>
|
#include <iomanip>
|
#include <climits>
|
#include <climits>
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
|
|
using namespace std;
|
using namespace std;
|
|
|
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
|
|
#include <locale.h>
|
#include <locale.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <signal.h>
|
#include <signal.h>
|
|
|
#include "cl_ambpex.h"
|
#include "cl_ambpex.h"
|
#include "tf_test.h"
|
#include "tf_test.h"
|
#include "tf_teststrm.h"
|
#include "tf_teststrm.h"
|
#include "tf_teststrmout.h"
|
#include "tf_teststrmout.h"
|
|
|
#define DEVICE_NAME "/dev/pexdrv0"
|
#define DEVICE_NAME "/dev/pexdrv0"
|
|
|
CL_AMBPEX *pBrd = NULL;
|
CL_AMBPEX *pBrd = NULL;
|
U32 isTwoTest=0;
|
U32 isTwoTest=0;
|
static volatile int exit_flag = 0;
|
static volatile int exit_flag = 0;
|
|
|
void signa_handler(int signo)
|
void signa_handler(int signo)
|
{
|
{
|
exit_flag = 1;
|
exit_flag = 1;
|
}
|
}
|
|
|
int BRDC_main(int argc, BRDCHAR* argv[])
|
int BRDC_main(int argc, BRDCHAR* argv[])
|
{
|
{
|
// анализ командной строки
|
// анализ командной строки
|
setlocale( LC_ALL, "Russian" );
|
setlocale( LC_ALL, "Russian" );
|
signal(SIGINT, signa_handler);
|
signal(SIGINT, signa_handler);
|
|
|
TF_Test *pTest=NULL;
|
TF_Test *pTest=NULL;
|
TF_Test *pTest2=NULL;
|
TF_Test *pTest2=NULL;
|
|
|
BRDCHAR* fname = argv[1];
|
BRDCHAR* fname = argv[1];
|
BRDCHAR* fname2=NULL;
|
BRDCHAR* fname2=NULL;
|
if( argc<2 )
|
if( argc<2 )
|
{
|
{
|
fname=(BRDCHAR*)_BRDC("");
|
fname=(BRDCHAR*)_BRDC("");
|
}
|
}
|
if( argc==3 )
|
if( argc==3 )
|
{
|
{
|
fname2=argv[2];
|
fname2=argv[2];
|
}
|
}
|
|
|
try
|
try
|
{
|
{
|
pBrd = new CL_AMBPEX(DEVICE_NAME);
|
pBrd = new CL_AMBPEX(DEVICE_NAME);
|
|
|
int ret=pBrd->init();
|
int ret=pBrd->init();
|
|
|
if( 0==ret )
|
if( 0==ret )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Module "DEVICE_NAME" successfuly opened\n") );
|
BRDC_fprintf( stderr, _BRDC("Module "DEVICE_NAME" successfuly opened\n") );
|
|
|
|
|
for( int trd=0; trd<8; trd++ )
|
for( int trd=0; trd<8; trd++ )
|
pBrd->RegPokeInd( trd, 0, 1 );
|
pBrd->RegPokeInd( trd, 0, 1 );
|
|
|
for( int trd=0; trd<8; trd++ )
|
for( int trd=0; trd<8; trd++ )
|
for( int ii=1; ii<32; ii++ )
|
for( int ii=1; ii<32; ii++ )
|
pBrd->RegPokeInd( trd, ii, 0 );
|
pBrd->RegPokeInd( trd, ii, 0 );
|
|
|
for( int trd=0; trd<8; trd++ )
|
for( int trd=0; trd<8; trd++ )
|
pBrd->RegPokeInd( trd, 0, 0 );
|
pBrd->RegPokeInd( trd, 0, 0 );
|
|
|
|
|
|
|
} else
|
} else
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Error open module "DEVICE_NAME": ret=0x%.8X\n"), ret );
|
BRDC_fprintf( stderr, _BRDC("Error open module "DEVICE_NAME": ret=0x%.8X\n"), ret );
|
exit(-1);
|
exit(-1);
|
}
|
}
|
|
|
if( fname[0]=='o' )
|
if( fname[0]=='o' )
|
pTest = new TF_TestStrmOut( fname, pBrd );
|
pTest = new TF_TestStrmOut( fname, pBrd );
|
else
|
else
|
pTest = new TF_TestStrm( fname, pBrd );
|
pTest = new TF_TestStrm( fname, pBrd );
|
|
|
Sleep( 10 );
|
Sleep( 10 );
|
|
|
if( fname2 )
|
if( fname2 )
|
{
|
{
|
isTwoTest=1;
|
isTwoTest=1;
|
if( fname2[0]=='o' )
|
if( fname2[0]=='o' )
|
pTest2 = new TF_TestStrmOut( fname2, pBrd );
|
pTest2 = new TF_TestStrmOut( fname2, pBrd );
|
else
|
else
|
pTest2 = new TF_TestStrm( fname2, pBrd );
|
pTest2 = new TF_TestStrm( fname2, pBrd );
|
}
|
}
|
|
|
pTest->Prepare();
|
pTest->Prepare();
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Prepare();
|
pTest2->Prepare();
|
|
|
Sleep( 10 );
|
Sleep( 10 );
|
pTest->Start();
|
pTest->Start();
|
Sleep( 10 );
|
Sleep( 10 );
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Start();
|
pTest2->Start();
|
|
|
//int key;
|
//int key;
|
int isFirstCallStep=1;
|
int isFirstCallStep=1;
|
int isStopped = 0;
|
int isStopped = 0;
|
for( ; ; )
|
for( ; ; )
|
{
|
{
|
if( exit_flag )
|
if( exit_flag )
|
{
|
{
|
if(!isStopped) {
|
if(!isStopped) {
|
pTest->Stop();
|
pTest->Stop();
|
if( pTest2 ) {
|
if( pTest2 ) {
|
pTest2->Stop();
|
pTest2->Stop();
|
}
|
}
|
BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
|
BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
|
isStopped = 1;
|
isStopped = 1;
|
}
|
}
|
}
|
}
|
|
|
if( exit_flag )
|
if( exit_flag )
|
{
|
{
|
if(isStopped) {
|
if(isStopped) {
|
|
|
if( pTest->isComplete() ) {
|
if( pTest->isComplete() ) {
|
|
|
if( pTest2 ) {
|
if( pTest2 ) {
|
if( pTest2->isComplete() )
|
if( pTest2->isComplete() )
|
break;
|
break;
|
} else {
|
} else {
|
break;
|
break;
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
if( isFirstCallStep || isTwoTest )
|
if( (isFirstCallStep && pTest->isDmaStart) || isTwoTest )
|
{
|
{
|
|
|
BRDC_fprintf( stderr, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"));
|
BRDC_fprintf( stderr, _BRDC("\n%10s %10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"), _BRDC("TIME"));
|
BRDC_fprintf( stderr, _BRDC("\n"));
|
BRDC_fprintf( stderr, _BRDC("\n"));
|
}
|
|
|
|
if (isFirstCallStep)
|
if (isFirstCallStep)
|
{
|
{
|
isFirstCallStep=false;
|
isFirstCallStep=false;
|
}
|
}
|
|
|
|
}
|
|
|
|
|
|
if( false==isFirstCallStep )
|
|
{
|
pTest->Step();
|
pTest->Step();
|
if( isTwoTest )
|
if( isTwoTest )
|
BRDC_fprintf( stderr, "\n" );
|
BRDC_fprintf( stderr, "\n" );
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->Step();
|
pTest2->Step();
|
if( isTwoTest )
|
if( isTwoTest )
|
BRDC_fprintf( stderr, "\n\n" );
|
BRDC_fprintf( stderr, "\n" );
|
|
}
|
|
|
Sleep( 1400 );
|
Sleep( 400 );
|
|
|
fflush( stdout );
|
fflush( stdout );
|
}
|
}
|
pTest->GetResult();
|
pTest->GetResult();
|
if( pTest2 )
|
if( pTest2 )
|
pTest2->GetResult();
|
pTest2->GetResult();
|
|
|
delete pTest; pTest=NULL;
|
delete pTest; pTest=NULL;
|
delete pTest2; pTest2=NULL;
|
delete pTest2; pTest2=NULL;
|
|
|
}
|
}
|
catch( BRDCHAR* str )
|
catch( BRDCHAR* str )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
|
BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
|
}
|
}
|
catch( ... )
|
catch( ... )
|
{
|
{
|
BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
|
BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
|
}
|
}
|
|
|
BRDC_fprintf( stderr, "Exit program\n" );
|
BRDC_fprintf( stderr, "Exit program\n" );
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|