LLC2_API
example.c
Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------- */
00002 /* file example.c                                                            */
00003 /* ------------------------------------------------------------------------- */
00004 /*   Copyright (C) 2011 Peter Milne, D-TACQ Solutions Ltd
00005  *                      <Peter dot Milne at D hyphen TACQ dot com>
00006  *  Created on: Sep 14, 2011
00007  *      Author: pgm
00008 
00009     http://www.d-tacq.com
00010 
00011     This program is free software; you can redistribute it and/or modify
00012     it under the terms of Version 2 of the GNU General Public License
00013     as published by the Free Software Foundation;
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00023 /* ------------------------------------------------------------------------- */
00024 
00025 /** @file example.c null control system example.
00026  *
00027  * Simplest "null control system":
00028  * outputs and fills user buffers no data change, no use of data.
00029  */
00030 #include <stdio.h>
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #include <unistd.h>
00034 #include <stdlib.h>
00035 #include <errno.h>
00036 #include <assert.h>
00037 
00038 #include "ll2-api.h"
00039 
00040 
00041 int main(int argc, const char* argv[])
00042 {
00043         short* AO_buf = calloc(48, sizeof(short));
00044         short* AI_buf = calloc(96, sizeof(short));
00045         unsigned *DI_buf = calloc(1, sizeof(unsigned));
00046         unsigned *DO_buf = calloc(2, sizeof(unsigned));
00047         unsigned *ST_buf = calloc(16, sizeof(unsigned));
00048         int ii;
00049 
00050         RtSetup("./xml/example1.xml", argc, argv);
00051         RtArm(AO_buf, DO_buf);
00052 
00053         for (ii = 0; ii < 100; ++ii){
00054                 RtIO(AO_buf, DO_buf, AI_buf, DI_buf, ST_buf);
00055         }
00056 
00057         RtDone();
00058 }