/* regularly outputs the amount of data in the buffer */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#include <errno.h>
#include <assert.h>

#include <sys/sysmacros.h> /* major() minor() */

#include "consoleio.h"
#include "debug.h"
#include "apci3600msg.h"
#include "findboards.h"
#include "configuration.h"

//--------------------------------------------------------------------------------
int main(int argc, char** argv)
{
	struct apci3600_card_t ** apci3600_cards = NULL; /* array of struct apci3600_card_t - allocated by apci3600_find_boards() */
	int apci3600_card_number = 0;
	struct apci3600_card_t * pboard = NULL; /* index of the board the user wish to work with (if there is only one board, select it) */ 
	
	assert( 0 != (apci3600_card_number = apci3600_find_boards(&apci3600_cards) ) );

	if (apci3600_card_number>1)
	{
		printf("which board do you want to access ? (%i-%i) \n", 0, apci3600_card_number-1 );
		pboard=apci3600_cards[get_integer(0, apci3600_card_number-1)];
	}
	else
		pboard=apci3600_cards[0];	
	
	while(1)
	{
		unsigned long val = 0;
		ASSERT_SUCCESS(apci3600_QueryAnalogInputCyclicAcquisitionNumberOfData(pboard, &val));
		printf("%li\n",val);
		sleep(2);
	}
}
