Exemplo n.º 1
0
//#define PROOF_RESET_WORKS 1
void ImagerTesterBase::ResetSensor()
{
	AssertPowered();
	bool status;

#ifdef PROOF_RESET_WORKS
	unsigned short Data=0;
	unsigned char Register=0x02;	// Row start
	Data=0xF;
	status = GetHWL()->WriteReg(Register,&Data,1);
	if(!status)
		printf("Write sensor I2C failed\n");
	usleep(50 * 1000);	// wait one frame
	status = GetHWL()->ReadReg(Register,&Data,1);
	if(!status)
		printf("Read sensor I2C failed\n");
	printf("Before reset reg%i=%04X\n", Register, Data);

	BYTE PsocRegRead = 0;
	status = GetHWL()->ReadIIC_PSOC(0, &PsocRegRead,1);
	if(!status)
		printf("Read PSOC I2C failed\n");
#endif

	// Issue reset, wait 100ms, then reload all IIC registers.
	unsigned char data = 0;
	status = GetHWL()->WriteIIC_PSOC(0x82, &data, 1);
	if(!status)
		printf("Write PSOC I2C failed\n");
	usleep(100 * 1000);

#ifdef PROOF_RESET_WORKS
	status = GetHWL()->ReadReg(Register,&Data,1);
	if(!status)
		printf("Read sensor I2C failed\n");
	printf("After reset reg%i=%04X\n", Register, Data);
#endif

	SetupSensor();
}
Exemplo n.º 2
0
int main(int argc, char **argv)
{
	if(argc < 6)
		Usage(argv[0]);

    signal( SIGINT, sigc_handler );


	const char *pcDfnXml       = argv[1];
	const char *pcDriverName   = argv[2];
	const char *pcSensorAdress = argv[3];
	const char *pcSensorType   = argv[4];
	const char *pcNumSamples   = argv[5];

	int bShowProgress = 0;
	int nNumSamples = atoi(pcNumSamples);
	unsigned int nNum;

	if(nNumSamples < 0)
	{
		nNum = ~0;
		bShowProgress = 0; // set to 0 for infinite collection
	}
	else
	{
		nNum = nNumSamples;
		if(argc > 6)
			bShowProgress = atoi(argv[6]);
	}

	IVistaTimerImp::SetSingleton( new VistaDefaultTimerImp );

	VistaDriverManager mgr;
	VdfnObjectRegistry reg;

	VistaProgressBar bar(nNum, 1);

	VdfnUtil::InitVdfn(&mgr.GetDriverMap(), &reg);


	VdfnNodeFactory::GetSingleton()->SetNodeCreator( "print", new TVdfnDefaultNodeCreate<CPrintNode> );
	VdfnNodeFactory::GetSingleton()->SetNodeCreator( "quitter", new TVdfnDefaultNodeCreate<CDetermineQuit> );


	IVistaDeviceDriver *pSm        = mgr.CreateAndRegisterDriver(pcDriverName, "VRPN-GENERIC");
	IVistaDriverCreationMethod *pM = mgr.GetCreationMethodForClass("VRPN-GENERIC");

	if(pSm == NULL)
	{
		std::cerr << "could not create driver ["
				  << pcDriverName
				  << "] of type VRPN-GENERIC"
				  << std::endl;
		return -1;
	}

	if(pM == NULL)
	{
		std::cerr << "could not create driver  creation method of type VRPN-GENERIC"
				  << std::endl;
		return -1;

	}

	SetupSensor(pSm, pM, pcSensorAdress, pcSensorType );

	VdfnGraph *pGraph = NULL;

	if( pSm && pSm->Connect() )
	{
		VistaDriverInfoAspect *pInfo
			= dynamic_cast<VistaDriverInfoAspect*>(
					pSm->GetAspectById( VistaDriverInfoAspect::GetAspectId() ) );
		if(pInfo)
			pInfo->GetInfoProps().PrintPropertyList();


		pGraph = VdfnPersistence::LoadGraph( pcDfnXml, pcDfnXml, true, true );
		if(pGraph)
		{
			VistaTimer timer;
			unsigned int n = 0;

			if(bShowProgress)
				bar.Start();

			while( (n < nNum) && !bDone)
			{
				if(mgr.Update())
				{
					pGraph->EvaluateGraph( timer.GetMicroTime() );
					++n;
					if(bShowProgress)
						bar.Increment();
				}
				VistaTimeUtils::Sleep(1);
			}
		}

	}
	if(bShowProgress)
		bar.Finish(true);

	// we need to make sure the graph is destructed, as some nodes might
	// do some cleanups in the graph destructor
	delete pGraph;
	std::cout << "good bye then." << std::endl;
}