/* ---------------------------------------------------------------------- */
/*
	footest_sample.C

	Sample program	for	a device driver on kernel 2.0.33

						Apr/06/98
*/
/* ---------------------------------------------------------------------- */
#include <iostream.h>

#include <stdio.h>
#include <unistd.h>          /* For read() y close()                   */
#include <fcntl.h>           /* For open()                             */

/* ---------------------------------------------------------------------- */
void main	(int argc,char *argv[])
{
	extern	int	errno;

	int fd;		/* File descriptor for the driver         */

	int	in_data;
	int	out_data;

	cerr << "*** footest_sample *** Apr/06/98 PM 15:45 ***\n";

	if( (fd = open	("/dev/foo_sample", O_RDWR, 0)) < 0)
		{
		perror	("check");

		printf	("fd = %d\n",fd);
		printf	("errno = %d\n",errno);
	 	printf	("Error opening /dev/foo_sample\n");
		exit	(1);
		}

	cerr << "check bbb\n";

	if (read (fd, (char *) &in_data, sizeof(long)) < 0)
		{
		printf	("Error reading from /dev/foo_sample\n");
		close	(fd);
		exit	(1);
		}

	cout << "In_data = " << hex << in_data << '\n';

	cerr << "check ddd\n";

	out_data = 0x32;

	if (write (fd, (char *) &out_data, sizeof(int)) < 0)
		{
		printf	("Error writing to /dev/foo_sample\n");
		close	(fd);
		exit	(1);
        	}

	if (close (fd))
		{
		printf	("Error closing foo\n");
		exit	(1);
  		}

	cerr << "*** footest_sample  *** End ***\n";

	return	(0);
}

/* ---------------------------------------------------------------------- */
