/* repeatSkillCmd.c - C file for the SKILL Process Example.*/

#include "stdio.h"
#include <ctype.h>

#define skillCommandPort 3
#define skillResultPort 4
#define PIPEBUFF 4096
#define TRUE 1

main(argc, argv)
int argc;
char **argv;
{
    long timeInterval;
    int  status;
    char timeDelay[PIPEBUFF], skillCommand[PIPEBUFF];
    char skillResult[PIPEBUFF];

    /* Read SKILL command */
    bzero(skillCommand,PIPEBUFF-1);
    gets(skillCommand);

    /* Read time delay in seconds */
    bzero(timeDelay,PIPEBUFF-1);
    gets(timeDelay);

    timeInterval = atoi(timeDelay);

    /* Send command back to SKILL every timeDelay seconds */
    while( TRUE ){
	fflush(stdout);
	sleep(timeInterval);

	/* write command to Design Framework II environment */

	status = write(skillCommandPort, 
	   skillCommand, strlen(skillCommand));

	/* read result from Design Framework II environment */

	bzero(skillResult,PIPEBUFF-1);
	status = read(skillResultPort, skillResult, PIPEBUFF);

	/* Note status is the number of bytes returned. */

	/* print results back to Design Framework II environment */

	printf("Executed SKILL command %s", skillCommand);
	printf(" with return value %s\n", 
	   skillResult);
    }
}
