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] - Diff between revs 6 and 12

Only display areas with differences | Details | Blame | View Log

Rev 6 Rev 12
 
/*
 
*This file is part of fpga_gpib_controller.
 
*
 
* Fpga_gpib_controller is free software: you can redistribute it and/or modify
 
* it under the terms of the GNU General Public License as published by
 
* the Free Software Foundation, either version 3 of the License, or
 
* (at your option) any later version.
 
*
 
* Fpga_gpib_controller is distributed in the hope that it will be useful,
 
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
* GNU General Public License for more details.
 
*
 
* You should have received a copy of the GNU General Public License
 
* along with Fpga_gpib_controller.  If not, see <http://www.gnu.org/licenses/>.
 
* Author: Andrzej Paluch
 
*/
#include <string.h>
#include <string.h>
#include <stdio.h>
#include <stdio.h>
#include <time.h>
#include <time.h>
 
 
#include <unistd.h>
#include <unistd.h>
 
 
#include "GpibRegAccess.h"
#include "GpibRegAccess.h"
#include "GpibHwAdapter.h"
#include "GpibHwAdapter.h"
#include "GpibHw.h"
#include "GpibHw.h"
 
 
 
 
int listenOnlyMain(int argc, char* argv[])
int listenOnlyMain(int argc, char* argv[])
{
{
        struct GpibRegAccess ra;
        struct GpibRegAccess ra;
        struct GpibHwAdapter ghw;
        struct GpibHwAdapter ghw;
        struct GpibHw gpib;
        struct GpibHw gpib;
 
 
        time_t rawtime;
        time_t rawtime;
        struct tm * timeinfo;
        struct tm * timeinfo;
 
 
        GpibRegAccess_init(&ra);
        GpibRegAccess_init(&ra);
        GpibHwAdapter_init(&ghw, &ra, 0);
        GpibHwAdapter_init(&ghw, &ra, 0);
        GpibHw_init(&gpib, &ghw);
        GpibHw_init(&gpib, &ghw);
 
 
        struct GpibHwSettings gs;
        struct GpibHwSettings gs;
        // set listen only
        // set listen only
        // set T1
        // set T1
        GpibHw_getSettings(&gpib, &gs);
        GpibHw_getSettings(&gpib, &gs);
        gs.T1 = 132;
        gs.T1 = 132;
        gs.listenOnly = true;
        gs.listenOnly = true;
        GpibHw_setSettings(&gpib, &gs);
        GpibHw_setSettings(&gpib, &gs);
 
 
        char buf[2048];
        char buf[2048];
        SizeType bytesRead;
        SizeType bytesRead;
        bool endOfStream;
        bool endOfStream;
        int i;
        int i;
        char fileName[1024];
        char fileName[1024];
        bool fileAllocated;
        bool fileAllocated;
        FILE *file;
        FILE *file;
 
 
 
 
        while(true){
        while(true){
                sprintf(fileName, "/home/andrzej/Downloads/TDS420/img%u.tiff", i);
                sprintf(fileName, "/home/andrzej/Downloads/TDS420/img%u.tiff", i);
                fileAllocated = false;
                fileAllocated = false;
 
 
                do
                do
                {
                {
                        GpibHw_read(&gpib, buf, 2048, &bytesRead, &endOfStream);
                        GpibHw_read(&gpib, buf, 2048, &bytesRead, &endOfStream);
 
 
                        if(bytesRead > 0)
                        if(bytesRead > 0)
                        {
                        {
                                if(!fileAllocated)
                                if(!fileAllocated)
                                {
                                {
                                        file = fopen(fileName, "wb");
                                        file = fopen(fileName, "wb");
                                        fileAllocated = true;
                                        fileAllocated = true;
                                        rawtime = time (0);
                                        rawtime = time (0);
                                        timeinfo = localtime ( &rawtime );
                                        timeinfo = localtime ( &rawtime );
                                        printf ( "Start time: %s\n", asctime (timeinfo) );
                                        printf ( "Start time: %s\n", asctime (timeinfo) );
                                }
                                }
 
 
                                fwrite(buf, 1, bytesRead, file);
                                fwrite(buf, 1, bytesRead, file);
                        }
                        }
                }
                }
                while(!endOfStream);
                while(!endOfStream);
 
 
                rawtime = time (0);
                rawtime = time (0);
                timeinfo = localtime ( &rawtime );
                timeinfo = localtime ( &rawtime );
                printf ( "Stop time: %s\n", asctime (timeinfo) );
                printf ( "Stop time: %s\n", asctime (timeinfo) );
 
 
                fclose(file);
                fclose(file);
                i++;
                i++;
        }
        }
 
 
        GpibHw_release(&gpib);
        GpibHw_release(&gpib);
        GpibHwAdapter_release(&ghw);
        GpibHwAdapter_release(&ghw);
        GpibRegAccess_release(&ra);
        GpibRegAccess_release(&ra);
 
 
        return 0;
        return 0;
}
}
 
 

powered by: WebSVN 2.1.0

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