#include "../h/rci.h"

extern taskFxn();

#define BUFSIZE 256

#if VXWORKS_CFG
#define main msgDemo_
#endif

main()
{
	RCI_DESC *td1, *td2;
	char ibuf[BUFSIZE];
	int size;

	rciSetOptions (EXIT_ON_ERROR);

	td1 = rciCreate ("task1", 0x1);
	rciRate (td1, 1000, 500);
	rciScheduling (td1, ON_CLOCK, 0);
	rciControlFxns (td1, NULLF, taskFxn, NULLF, 0);

	td2 = rciCreate ("task2", 0x3);
	rciRate (td2, 1000, 0);
	rciScheduling (td2, ON_CLOCK, 0);
	rciControlFxns (td2, NULLF, taskFxn, NULLF, 0);

	rciStart(~0);

	while (1)
	 { gets (ibuf);
	   rciSend (TASKMASK(td1), ibuf, strlen(ibuf)+1);
	   while ((size = rciReceive(TASKMASK(td2), ibuf,
				     BUFSIZE, (RCI_DESC**)0)) == 0)
	      ;
	   printf ("%s\n", ibuf);
	 }
}
