#include <v_lib.h>

int	main(int argc, char *argv[])
{
	file_t comm;
	char buf[16];
	logStartConsoleLog();
	logUpperLevel(LOG_TRACE);
	if(argc>1)
		comm=commOpen(2,atoi(argv[1]),8,0,0);
	else
		comm=commOpen(2,9600,8,0,0);
	if(!comm)
		return -1;
	printf("Reading bytes from COM2 (press ^C to exit)\n");
	for(;;)
	{
		if(!fileRead(comm,buf,1))
		{
			puts("fileRead() failed; re-opening port ...");
			fileClose(comm);
			if(argc>1)
				comm=commOpen(2,atoi(argv[1]),8,0,0);
			else
				comm=commOpen(2,9600,8,0,0);
		}
		printf("%02X; ",buf[0]);
	}
	return 0;
}

