/*  Copyright (C) MOXA Inc. All rights reserved.

    This software is distributed under the terms of the
    MOXA License.  See the file COPYING-MOXA for details.
*/
/*
    mxcan_read.cpp

    This is for the read of canbus data.

    2010-10-31	Epson Chiang
		new release
*/

#include "stdafx.h"
#include "stdafx.h"
#include <windows.h>
#include "..\SDK\mxcanbus.h"

int _tmain(int argc, _TCHAR* argv[])
{
	int fd;
	
	int port = 0;
	unsigned char pDumpReg[32];

	printf("Enter can port number:");
	scanf("%d",&port);

	/*Open can port*/
	fd =  mxcan_open(port);

	if (mxcan_get_registers(fd, pDumpReg,32)==-1)
	{
		printf("mxcan_get_registers fail\r\n");
		return -1;
	}
	else
	{
		_tprintf(_T("Demp registers:\r\n"));
		for (int i=0;i<32;i++)
		{
			_tprintf(_T("%d=0x%02x\r\n"),i,pDumpReg[i]);
		}
	}

	/*Close can port*/
	mxcan_close(fd);
	return 0;
}

