/*

This program works with samples\aasc\znmaster.c to blink the
LED on the PK2500 (only if the RS485 driver is working
properly and the jumpers are set properly).

*/

#define ZNMASTER 0		//	I am a slave
#use vdriver.lib
#use aasczn.lib
#use eziopk25.lib			//	needed only if you use a pk2300

#define BUFSIZ 0x10
	
main() {
char InFrom0[BUFSIZ], OutTo0[BUFSIZ];
CHANNEL Node0;
char locBuf[30];
char *ptr;
int cnt, moved;
int rxCnt;
char ch;
unsigned long pakCnt;
char status;
	
	VdInit();

	eioBrdInit(0);

	Node0 = aascOpen(DEV_ZNET,0,ZN1200*16|ZNSLAVE*0,NULL);
	znID = 1;

	aascSetReadBuf(Node0,InFrom0,sizeof(InFrom0));
	aascSetWriteBuf(Node0,OutTo0,sizeof(OutTo0));
	aascTxSwitch(Node0,1);
	aascRxSwitch(Node0,1);
	aascFlush(Node0);
	pakCnt = 0;

	while (1) {
		znPollSlave();
		costate {
			if (aascReadChar(Node0, &status)) {
			  LED2(status);
			  waitfor(aascWriteChar(Node0,status));	//	echo back for verification
			} else {
			}
		}
	}
}