/* $Header:_command.c 12.0$ */
/* $ACIS:_command.c 12.0$ */
/* $Source: /ibm/acis/usr/src/usr.lib/libaed/RCS/_command.c,v $ */

#ifndef lint
static char *rcsid = "$Header:_command.c 12.0$";
#endif

#include "whim.h"
#ifdef DEBG
#define PRINTF if(1) printf
#else
#define PRINTF if(0) printf
#endif
command(nwords)
INT16 nwords;		   /* number of words to transfer */

{
#include "whimdcl.h"
    INT16 poll; 	   /* semaphore word */
    INT_PURE i;
    INT_PURE status;

if (init_yet == FALSE)
	{
	fprintf(stderr,"Viking not initialized. Call VI_Init\n");
	exit();
	}

/* copy the vikint buffer to shared ram */
vwrite(&vikint[1],nwords,0x4002);

poll = 0x0101;

i = 0;
status = ioctl(v_cntl,AEDSEM_SET_WAIT,&poll);
PRINTF("\n");
while(status)
	{
	for(poll = 1000; poll != 0; poll--);
	status = ioctl(v_cntl,AEDSEM_UNTIL,&poll); /* wait for 0 */
	PRINTF("%04d\b\b\b\b",i);
	if (i++ >= 250)
		{
		fprintf(stderr,"Semaphore apparently hung.  Abort\n");
		exit();
		}
	}
}
