#include "stdafx.h"
#include "nio_lib20.h"
#include "nio_lib20_err.h"


short NIO_Example_Init(short idx,HAND *pHDev)
{
	short rtn;
	short devNum;
	TIODevInfo devList[8];


	// 1.search 
	rtn = NIO_DevSearch(0,&devNum,devList);
	if(rtn != RTN_CMD_SUCCESS)
	{
		printf("error:NIO_DevSearch = %d",rtn);
		return rtn;
	}
	if(devNum < 1)
	{
		printf("error:No NIO device found");
		return 1;
	}
	printf("%d NIO device found ",devNum);
	for(int i=0;i<devNum;i++)
	{
		printf("    %d:address = %d ",devList[i].address);
	}

	// 2.open
	rtn = NIO_DevOpen(idx,pHDev);
	if(rtn != RTN_CMD_SUCCESS)
	{
		printf("error:NIO_DevOpen = %d",rtn);
		return rtn;
	}

	return 0;
}




















