/*
 * test_skel2.c
 *
 * Test program for the skeldev2 device.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

int main(void) 
{
	int fd;
	ssize_t count;
	char buf[50];

	/* open device */
	if ((fd = open("/dev/skeldev2", O_RDWR)) < 0) {
		perror("open()");
		exit(1);
	}

	/* write to device */
	memset(buf, 0x00, sizeof(buf));   /* clear buffer */
	strcpy(buf, "Hello World!");
	count = write(fd, buf, sizeof(buf));
	printf("Written %d bytes to device\n", count);

	/* read from device */
	memset(buf, 0x00, sizeof(buf));   /* clear buffer */
	count = read(fd, buf, sizeof(buf));
	printf("Read %d bytes from device: %s\n", count, buf);

	/* close device */
	close(fd);
	exit(0);
}
