OpenCores
URL https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk

Subversion Repositories fpga-cf

[/] [fpga-cf/] [trunk/] [cpp/] [fcptest.cpp] - Blame information for rev 12

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

Line No. Rev Author Line
1 10 peteralieb
// fcptest.cpp
2
 
3
#include "fcpprotocol.hpp"
4
 
5
#include <iostream>
6
#include <time.h>
7
#include <sys/time.h>
8
 
9
using namespace std;
10
 
11
int main(char ** argv, int argc)
12
{
13
 
14
        FCPProtocol *fcp = new FCPProtocol();
15
        bool r = fcp->connect((byte[]){0x01, 0x23, 0x45, 0x67, 0x89, 0xab},
16
                (byte[]){192, 168, 1, 222});
17
        cout << "Connected: " << r << endl;
18
 
19
        struct timeval start, stop;
20
 
21
        gettimeofday(&start, 0);
22
        r = fcp->sendData(1, (byte[]){0x11}, 1);
23
        gettimeofday(&stop, 0);
24
        cout << "Latency Time: " << (long)(stop.tv_usec - start.tv_usec) << " us" << endl;
25
        cout << "Data Sent: " << r << endl;
26
        //byte data[] = {0, 0};
27
        //r = fcp->requestData(1, 1, data);
28
        //cout << "Data Received: " << r << endl;
29
        //cout << "Value: " << (int)data[0] << endl;
30
 
31
        cout << "Performing Speed Test..." << endl;
32
 
33
        byte senddata[1024];
34
 
35
        for (int j=0; j<1024; j++)
36
        {
37
                senddata[j] = (byte)(j/4);
38
        }
39
 
40
        gettimeofday(&start, 0);
41
        for (int i=0; i<4096; i++)
42
        {
43
    senddata[1023] = i;
44
                r = fcp->sendData(1,senddata, 1024);
45
                if (!r) cout << "Send Error!" << endl;
46
        }
47
        gettimeofday(&stop, 0);
48
        cout << "Throughput Time: " << (long)(stop.tv_usec - start.tv_usec) << " us" << endl;
49
 
50
        cout << "Throughput: " << 32000000.0 / (long)(stop.tv_usec - start.tv_usec) << "Mb/s" << endl;
51
 
52
 
53
        delete fcp;
54
}

powered by: WebSVN 2.1.0

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