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 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 Andrewski
/*
2
*This file is part of fpga_gpib_controller.
3
*
4
* Fpga_gpib_controller is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* Fpga_gpib_controller is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with Fpga_gpib_controller.  If not, see <http://www.gnu.org/licenses/>.
16
* Author: Andrzej Paluch
17
*/
18 3 Andrewski
#include <string.h>
19
#include <stdio.h>
20
#include <time.h>
21
 
22
#include <unistd.h>
23
 
24
#include "GpibRegAccess.h"
25
#include "GpibHwAdapter.h"
26
#include "GpibHw.h"
27
 
28
 
29
int listenOnlyMain(int argc, char* argv[])
30
{
31
        struct GpibRegAccess ra;
32
        struct GpibHwAdapter ghw;
33
        struct GpibHw gpib;
34
 
35
        time_t rawtime;
36
        struct tm * timeinfo;
37
 
38
        GpibRegAccess_init(&ra);
39
        GpibHwAdapter_init(&ghw, &ra, 0);
40
        GpibHw_init(&gpib, &ghw);
41
 
42
        struct GpibHwSettings gs;
43
        // set listen only
44
        // set T1
45
        GpibHw_getSettings(&gpib, &gs);
46
        gs.T1 = 132;
47
        gs.listenOnly = true;
48
        GpibHw_setSettings(&gpib, &gs);
49
 
50
        char buf[2048];
51
        SizeType bytesRead;
52
        bool endOfStream;
53
        int i;
54
        char fileName[1024];
55
        bool fileAllocated;
56
        FILE *file;
57
 
58
 
59
        while(true){
60
                sprintf(fileName, "/home/andrzej/Downloads/TDS420/img%u.tiff", i);
61
                fileAllocated = false;
62
 
63
                do
64
                {
65
                        GpibHw_read(&gpib, buf, 2048, &bytesRead, &endOfStream);
66
 
67
                        if(bytesRead > 0)
68
                        {
69
                                if(!fileAllocated)
70
                                {
71
                                        file = fopen(fileName, "wb");
72
                                        fileAllocated = true;
73
                                        rawtime = time (0);
74
                                        timeinfo = localtime ( &rawtime );
75
                                        printf ( "Start time: %s\n", asctime (timeinfo) );
76
                                }
77
 
78
                                fwrite(buf, 1, bytesRead, file);
79
                        }
80
                }
81
                while(!endOfStream);
82
 
83
                rawtime = time (0);
84
                timeinfo = localtime ( &rawtime );
85
                printf ( "Stop time: %s\n", asctime (timeinfo) );
86
 
87
                fclose(file);
88
                i++;
89
        }
90
 
91
        GpibHw_release(&gpib);
92
        GpibHwAdapter_release(&ghw);
93
        GpibRegAccess_release(&ra);
94
 
95
        return 0;
96
}

powered by: WebSVN 2.1.0

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