#include "GPIOController.h"
#include "BCap.h"
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char** argv) {
	int port = 5007;
	if (argc > 1) {
		char* endptr;
		port = strtol(argv[1], &endptr, 10);
		if (*endptr != '\0') {
			//TODO エラーメッセージの処理を考える
			fprintf(stdout, "Usage: GPIOController [portNo]");
			return 1;
		}
	}

	HRESULT hr = bCap::InitBcap(port);
	if(FAILED(hr)) return 1;

	while(1) {
		usleep(1000000); //1s
	}

	bCap::DisposeBcap();
	fprintf(stdout, "stopped\n");

	return 0;

}