/*  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 nRet;
	int fd;
	int port = 0;

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

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

	/*Purge the rx buffer*/
	nRet=mxcan_purge_buffer(fd,1);
	if(nRet==-1)
	{
		printf("Purge RX buffer fail.\r\n");
	}
	else
	{
		printf("Purge RX buffer Success.\r\n");
	}

	/*Purge the tx buffer*/
	nRet=mxcan_purge_buffer(fd,2);
	if(nRet==-1)
	{
		printf("Purge TX buffer fail.\r\n");
	}
	else
	{
		printf("Purge TX buffer Success.\r\n");
	}
	
	/*Close can port*/
	mxcan_close(fd);
	return 0;
}

