#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>

int main()
{
	int fdusb, fdpm;
	int i;

	if ( (fdusb = open("/dev/cp_lkm_usb", O_RDWR)) < 0 ) {
		printf("%s() open failed\n", __FUNCTION__);
		return fdusb;
	}

	if ( (fdpm = open("/dev/cp_lkm_pm", O_RDWR)) < 0 ) {
		printf("%s() open failed\n", __FUNCTION__);
		close(fdusb);
		return fdpm;
	}

	printf("testing write fd:%d\n", fdusb);
	char buffer[52];
	for (i=0; i < 52; i++) {
		if (i < 26) {
			buffer[i] = 'A' + i;
		} else {
			buffer[i] = 'a' + i;
		}
	}
	int nwrite = write(fdusb, buffer, 52);
	if (nwrite != 52) {
		printf("%s() - write error -> %d of %d written\n", __FUNCTION__, nwrite, 52);
	}

	printf("testing write fd:%d\n", fdpm);
	char bufferpm[26];
	for (i=0; i < 26; i++) {
		bufferpm[i] = 'a' + i;
	}
	nwrite = write(fdpm, bufferpm, 26);
	if (nwrite != 26) {
		printf("%s() - write error -> %d of %d written\n", __FUNCTION__, nwrite, 26);
	}

	char read_buffer[52];
	int nread = read(fdusb, read_buffer, 52);
	if (nread != 52) {
		printf("%s() - read error -> %d of %d read\n", __FUNCTION__, nread, 52);
	}
	if (memcmp(buffer, read_buffer, 52)) {
		printf("%s() - read/write memcmp failed\n", __FUNCTION__);
	} else {
		printf("%s() - read/write memcmp succeeded\n", __FUNCTION__);
	}

	nread = read(fdpm, read_buffer, 26);
	if (nread != 26) {
		printf("%s() - read error -> %d of %d read\n", __FUNCTION__, nread, 26);
	}
	if (memcmp(bufferpm, read_buffer, 26)) {
		printf("%s() - read/write memcmp failed %s\n", __FUNCTION__, read_buffer);
	} else {
		printf("%s() - read/write memcmp succeeded\n", __FUNCTION__);
	}


	printf("%s() - testing ioctl\n", __FUNCTION__);

	int ioctl_resl = ioctl(fdusb, 322, 0xdeadbeef);
	printf("%s() - ioctl resl:%d\n", __FUNCTION__, ioctl_resl);

	close(fdusb);
	close(fdpm);

	return 0;
}
