OpenCores
URL https://opencores.org/ocsvn/pcie_ds_dma/pcie_ds_dma/trunk

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [soft/] [linux/] [application/] [adm_test/] [src/] [work/] [main.cpp] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
/*
3
#ifndef __PEX_H__
4
    #include "pex.h"
5
#endif
6
*/
7
 
8
#include "board.h"
9
#include "pex_board.h"
10
 
11
#include <cassert>
12
#include <cstdlib>
13
#include <cstring>
14
#include <iostream>
15
#include <iomanip>
16
#include <climits>
17
 
18
//-----------------------------------------------------------------------------
19
 
20
using namespace std;
21
 
22
//-----------------------------------------------------------------------------
23
 
24
#include <locale.h>
25
#include <unistd.h>
26
#include <stdlib.h>
27
#include <stdio.h>
28
#include <signal.h>
29
 
30
#include "cl_ambpex.h"
31
#include "tf_test.h"
32
#include "tf_teststrm.h"
33
#include "tf_teststrmout.h"
34
 
35 6 v.karak
#define DEVICE_NAME "/dev/pexdrv0"
36
 
37 2 dsmv
CL_AMBPEX *pBrd = NULL;
38
U32 isTwoTest=0;
39
static volatile int exit_flag = 0;
40
 
41
void signa_handler(int signo)
42
{
43
    exit_flag = 1;
44
}
45
 
46
int BRDC_main(int argc, BRDCHAR* argv[])
47
{
48
    // анализ командной строки
49
    setlocale( LC_ALL, "Russian" );
50
    signal(SIGINT, signa_handler);
51
 
52
    TF_Test  *pTest=NULL;
53
    TF_Test  *pTest2=NULL;
54
 
55
    BRDCHAR* fname = argv[1];
56
    BRDCHAR* fname2=NULL;
57
    if( argc<2 )
58
    {
59
        fname=(BRDCHAR*)_BRDC("");
60
    }
61
    if( argc==3 )
62
    {
63
        fname2=argv[2];
64
    }
65
 
66
    try
67
    {
68
        pBrd = new CL_AMBPEX(DEVICE_NAME);
69
 
70
        int ret=pBrd->init();
71
 
72
        if( 0==ret )
73
        {
74
            BRDC_fprintf( stderr, _BRDC("Module "DEVICE_NAME" successfuly opened\n") );
75
 
76 6 v.karak
 
77 2 dsmv
            for( int trd=0; trd<8; trd++ )
78
                pBrd->RegPokeInd( trd, 0, 1 );
79
 
80
            for( int trd=0; trd<8; trd++ )
81
                for( int ii=1; ii<32; ii++ )
82
                    pBrd->RegPokeInd( trd, ii, 0 );
83
 
84
            for( int trd=0; trd<8; trd++ )
85
                pBrd->RegPokeInd( trd, 0, 0 );
86
 
87
 
88 6 v.karak
 
89 2 dsmv
        } else
90
        {
91
            BRDC_fprintf( stderr, _BRDC("Error open module "DEVICE_NAME": ret=0x%.8X\n"), ret );
92
            exit(-1);
93
        }
94
 
95
        if( fname[0]=='o' )
96
            pTest = new TF_TestStrmOut( fname, pBrd );
97
        else
98
            pTest = new TF_TestStrm( fname, pBrd );
99
 
100
        Sleep( 10 );
101
 
102
        if( fname2 )
103
        {
104
            isTwoTest=1;
105
            if( fname2[0]=='o' )
106
                pTest2 = new TF_TestStrmOut( fname2, pBrd );
107
            else
108
                pTest2 = new TF_TestStrm( fname2, pBrd );
109
        }
110
 
111
        pTest->Prepare();
112
        if( pTest2 )
113
            pTest2->Prepare();
114
 
115
        Sleep( 10 );
116
        pTest->Start();
117
        Sleep( 10 );
118
        if( pTest2 )
119
            pTest2->Start();
120
 
121
        //int key;
122
        int isFirstCallStep=1;
123 6 v.karak
        int isStopped = 0;
124 2 dsmv
        for( ; ; )
125
        {
126 6 v.karak
            if( exit_flag )
127
            {
128
                if(!isStopped) {
129 2 dsmv
                    pTest->Stop();
130 6 v.karak
                    if( pTest2 ) {
131 2 dsmv
                        pTest2->Stop();
132 6 v.karak
                    }
133 2 dsmv
                    BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
134 6 v.karak
                    isStopped = 1;
135 2 dsmv
                }
136 6 v.karak
            }
137 2 dsmv
 
138 6 v.karak
            if( exit_flag )
139
            {
140
                if(isStopped) {
141 2 dsmv
 
142 6 v.karak
                    if( pTest->isComplete() ) {
143
 
144
                        if( pTest2 ) {
145
                            if( pTest2->isComplete() )
146
                                break;
147
                        } else {
148
                            break;
149
                        }
150
                    }
151 2 dsmv
                }
152
            }
153
 
154
            if( isFirstCallStep || isTwoTest )
155
            {
156
 
157
                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"));
158
                BRDC_fprintf( stderr, _BRDC("\n"));
159
            }
160
 
161
            if (isFirstCallStep)
162
            {
163
                isFirstCallStep=false;
164
            }
165
 
166
            pTest->Step();
167
            if( isTwoTest )
168
                BRDC_fprintf( stderr, "\n" );
169
            if( pTest2 )
170
                pTest2->Step();
171
            if( isTwoTest )
172
                BRDC_fprintf( stderr, "\n\n" );
173
 
174 6 v.karak
            Sleep( 1400 );
175 2 dsmv
 
176
            fflush( stdout );
177
        }
178
        pTest->GetResult();
179
        if( pTest2 )
180
            pTest2->GetResult();
181
 
182
        delete pTest; pTest=NULL;
183
        delete pTest2; pTest2=NULL;
184
 
185
    }
186
    catch( BRDCHAR* str )
187
    {
188
        BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
189
    }
190
    catch( ... )
191
    {
192
        BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
193
    }
194
 
195 6 v.karak
    BRDC_fprintf( stderr, "Exit program\n" );
196 2 dsmv
 
197
    return 0;
198
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.