#include <stdio.h>

/* Print SIO stats. */

main()
{
	char sitty_file[1024];
	int j;
	struct foo
	{
		unsigned char rx_chars;
		unsigned char tx_chars;
		unsigned short int foo_bar;
	} hw ;

	int fd;

	system("clear");
	printf("Number of Characters IN HARDWARE BUFFERS :\n");
	for(j=0; j<16; j++)
	{
		sprintf(sitty_file, "/dev/sitty%d", j);
		fd=open(sitty_file, 0);
		if(ioctl(fd, 0x5499, &hw) != 0)
		{
			printf("\n\n\nFailed port %d", j);
			perror("Status read failed because");
			printf("\n\n\n");
			exit(0);
		}
		printf("Port %d = %d", j, hw.tx_chars);
		close(fd);

		sprintf(sitty_file, "/dev/sitty%d", j+16);
		fd=open(sitty_file, 0);
		if(ioctl(fd, 0x5499, &hw) != 0)
		{
			printf("\n\n\nFailed port %d (fd=%d)", j+16, fd);
			perror("Status read failed because ");
			printf("\n\n\n");
			exit(0);
		}
		printf("\tPort %d = %d\n", j+16, hw.tx_chars);
		close(fd);
	}
}
