/*  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"
#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
	CANPRM param;
	
	//unsigned int nRet;
	DWORD nRet;
	int fd;
	int port = 0;

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

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

	if (mxcan_get_parameters(fd, &param)==-1)
	{
		printf("mxcan_get_parameters fail\r\n");
		return -1;
	}

	printf("param.bus_timing (recv)=%d\r\n",param.bus_timing);
	printf("param.acceptance_filter_mode (recv)=%d\r\n",param.acceptance_filter_mode);
	printf("param.acceptance_filter_code (recv)=0x%x\r\n",param.acceptance_filter_code);
	printf("param.acceptance_filter_mask (recv)=0x%x\r\n",param.acceptance_filter_mask);

	param.acceptance_filter_code=0x80001000;
	param.acceptance_filter_mask=0x0;
	mxcan_set_parameters(fd, &param);

	printf("param.bus_timing (send)=%d\r\n",param.bus_timing);
	printf("param.acceptance_filter_mode (send)=%d\r\n",param.acceptance_filter_mode);
	printf("param.acceptance_filter_code (send)=0x%x\r\n",param.acceptance_filter_code);
	printf("param.acceptance_filter_mask (send)=0x%x\r\n",param.acceptance_filter_mask);

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

