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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [prototype_1/] [PC_software/] [test_src/] [listenOnly_Test.c] - Blame information for rev 7

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

Line No. Rev Author Line
1 3 Andrewski
 
2
#include <string.h>
3
#include <stdio.h>
4
#include <time.h>
5
 
6
#include <unistd.h>
7
 
8
#include "GpibRegAccess.h"
9
#include "GpibHwAdapter.h"
10
#include "GpibHw.h"
11
 
12
 
13
int listenOnlyMain(int argc, char* argv[])
14
{
15
        struct GpibRegAccess ra;
16
        struct GpibHwAdapter ghw;
17
        struct GpibHw gpib;
18
 
19
        time_t rawtime;
20
        struct tm * timeinfo;
21
 
22
        GpibRegAccess_init(&ra);
23
        GpibHwAdapter_init(&ghw, &ra, 0);
24
        GpibHw_init(&gpib, &ghw);
25
 
26
        struct GpibHwSettings gs;
27
        // set listen only
28
        // set T1
29
        GpibHw_getSettings(&gpib, &gs);
30
        gs.T1 = 132;
31
        gs.listenOnly = true;
32
        GpibHw_setSettings(&gpib, &gs);
33
 
34
        char buf[2048];
35
        SizeType bytesRead;
36
        bool endOfStream;
37
        int i;
38
        char fileName[1024];
39
        bool fileAllocated;
40
        FILE *file;
41
 
42
 
43
        while(true){
44
                sprintf(fileName, "/home/andrzej/Downloads/TDS420/img%u.tiff", i);
45
                fileAllocated = false;
46
 
47
                do
48
                {
49
                        GpibHw_read(&gpib, buf, 2048, &bytesRead, &endOfStream);
50
 
51
                        if(bytesRead > 0)
52
                        {
53
                                if(!fileAllocated)
54
                                {
55
                                        file = fopen(fileName, "wb");
56
                                        fileAllocated = true;
57
                                        rawtime = time (0);
58
                                        timeinfo = localtime ( &rawtime );
59
                                        printf ( "Start time: %s\n", asctime (timeinfo) );
60
                                }
61
 
62
                                fwrite(buf, 1, bytesRead, file);
63
                        }
64
                }
65
                while(!endOfStream);
66
 
67
                rawtime = time (0);
68
                timeinfo = localtime ( &rawtime );
69
                printf ( "Stop time: %s\n", asctime (timeinfo) );
70
 
71
                fclose(file);
72
                i++;
73
        }
74
 
75
        GpibHw_release(&gpib);
76
        GpibHwAdapter_release(&ghw);
77
        GpibRegAccess_release(&ra);
78
 
79
        return 0;
80
}

powered by: WebSVN 2.1.0

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