/************ testing, debugging and tracking functions ************/

printhex(char *header,char *buffer,int length)
{	
	int margin;
	int col=0;
	unsigned char a;
	int i,j;

	margin=strlen(header);
	printf("%s %4d:",header,length);

	for (i=0; i<length; i++)
	{
		if (col >= 16)
		{
			printf("\n");
			col=0;
			for(j=0; j<margin+6; j++) printf(" ");
		}
		printf("%02x ",a=buffer[i]);
		col++;
	}
	if (col!=0) printf("\n");
	return(1);
}

printascii(char *header,char *buffer,int length)
{	
	int margin;
	int col=0;
	unsigned char a;
	int i,j;

	margin=strlen(header);
	printf("%s %4d:",header,length);

	for (i=0; i<length; i++)
	{
		if (col >= 16)
		{
			printf("\n");
			col=0;
			for(j=0; j<margin+6; j++) printf(" ");
		}
		a=buffer[i];
		if (a<32 || a>126) a='¤';
		printf("%c  ",a);
		col++;
	}
	if (col!=0) printf("\n");
	return(1);
}


readhexchars()		/* this is a debugging function only */
{
	int i,numchars;
	int a;
	Delay(50);
	numchars=readserial(buffer,MAXLEN);
	printf("RX<< %4d: ",numchars);
	for (i=0; i<numchars; i++)
		printf("%02x ",a=buffer[i]);
	printf("\n");

	return(0);
}

fuji_test()
{
	int chars_received=0;
	int i,size;
	int frame,status,frames;
	char filename[30];

	attention();

	set_flashmode(0);

	for(i=1; i<10 && attention(); i++)
	{
		charge_flash(200);
		shoot(&frame,&status);
		sprintf(filename,"Image%02d.jpeg\0",i+10);
/*		get_image(frame,filename);*/
		delete_image(frame);
	}

	/* flush out the receive buffer */
	printf("\n\n");
	readhexchars();
	printf("\n");



	return(1);
}



/********************* debug bits ******************/         /*
bit 0	 1		Low level tracking per received and/or decoded byte
bit 1	 2		Print packets sent/received in hex 
bit 2	 4		Print packets sent/received in ascii 
bit 3	 8		Show acks sent/received
bit 4	 16		Show received headers
bit 5	 32		Show sent camera commands and responses
bit 6 	 64		Show packet counter
bit 7	128		Show initial contact establishment proceedings 

*/