Amadis

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Tutorial #1: test shared RAM

//---------------------------------------------------------
//            Main
//---------------------------------------------------------
//  Main function:
//		- Hypothesis: IP communication with ACE
//      - Use aceOut from Agnos tutorials
//
//  Visibility: Public
//  Hypothesis: --
//  Reference: --
//
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";
	// Trace for debugging
	char tmp[100]="";

	// Get Communication parameters from ini file
	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);
	// Activate SDK to access to ACE services
	aceSetMode(pmSDK);

	aceOut("Training Session - BEGIN\n");

	tByte *buffer = NULL;
	tDataFileSize size=0;
	char* parameters;

	// Initialize GPI
	// This is platform dependent. On Kizis AVT, this set PCSC readers' name from agnos.ini
	gpiMain(0,&parameters);


	if (admNO_ERROR == gpiGetTotalRAM(&buffer,&size))
	{
		sprintf(tmp,"Total RAM Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		sprintf(tmp,"Size = %ld\n",size);
		aceOut("Total RAM Issue\n");
	}
	if (admNO_ERROR == gpiGetRAMForTags(&buffer,&size))
	{
		sprintf(tmp,"RAM for Tags Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		aceOut("RAM for Tags Issue\n");
	}
	if (admNO_ERROR == gpiGetRAMForUnknownTags(&buffer,&size))
	{
		sprintf(tmp,"Unknown Tags RAM Size = %ld\n",s
		
		ize);
		aceOut(tmp);
	}
	else
	{
		aceOut("Unknown Tags RAM Issue\n");
	}
	if (admNO_ERROR == gpiGetFreeRAM(&buffer,&size))
	{
		sprintf(tmp,"Free RAM Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		aceOut("Free RAM Issue\n");
	}
	if (admNO_ERROR == gpiGetPrivateScratchPAD(MASTERCARD_PAYPASS,&buffer,&size))
	{
		sprintf(tmp,"MCW Scracth PAD Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		aceOut("MCW SP Issue\n");
	}
	if (admNO_ERROR == gpiGetPrivateScratchPAD(JCB_JSPEEDY,&buffer,&size))
	{
		sprintf(tmp,"JCB Scratch PAD Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		aceOut("JCB SP RAM Issue\n");
	}
	if (admNO_ERROR == gpiGetDataObjectRAM(&buffer,&size))
	{
		sprintf(tmp,"DO RAM Size = %ld\n",size);
		aceOut(tmp);
	}
	else
	{
		aceOut("Object RAM Issue\n");
	}

	aceOut("Training Session - END\n");

	return 0;
}

Tutorial #2: send data to ACE over communication link

//---------------------------------------------------------
//            Main
//---------------------------------------------------------
//  Main function:
//		- Hypothesis: IP communication with ACE
//      - Use aceOut from Agnos tutorials
//
//  Visibility: Public
//  Hypothesis: --
//  Reference: --
//
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";

	// Get Communication parameters from ini file
	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);
	// Activate SDK to access to ACE services
	aceSetMode(pmSDK);

	aceOut("Training Session - BEGIN\n");

	tByte *buffer = NULL;
	tDataFileSize size=0;
	char* parameters;
	char workingString[1000]="";

	// Initialize GPI
	// This is platform dependent. On Kizis AVT, this set PCSC readers' name from agnos.ini
	gpiMain(0,&parameters);

	tFileHandler ifp = 0;

	gpiGetTotalRAM(&buffer,&size);
	sprintf(workingString,"%sENTRY_POINT","./AGNOS/");

	if(gpiFileOpen(workingString,&ifp,READ|BINARY)==filNO_ERROR)
	{
		gpiFileRead(ifp,buffer,&size);
		gpiFileClose(ifp);
	}

	// Send data read but skip file header
	aceSendRawDD(buffer+21,size-21);

	aceOut("Training Session - END\n");

	return 0;
}

Tutorial #3: timers

//---------------------------------------------------------
//            Main
//---------------------------------------------------------
//  Main function:
//		- Hypothesis: IP communication with ACE
//      - Use aceOut from Agnos tutorials
//
//  Visibility: Public
//  Hypothesis: --
//  Reference: --
//
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";
	// Trace for debugging
	char tmp[1000]="";

	// Get Communication parameters from ini file
	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);
	// Activate SDK to access to ACE services
	aceSetMode(pmSDK);

	aceOut("Training Session - BEGIN\n");

	char* parameters;

	// Initialize GPI
	// This is platform dependent. On Kizis AVT, this set PCSC readers' name from agnos.ini
	gpiMain(0,&parameters);

	tTimerHandler MaxTimer=0, timer1=0, timer2=0;
	tTimerState state;
	tTimerTime sec, microsec;

	gpiResetTimers();
	gpiGetMaxTimer(&MaxTimer);
	sprintf(tmp,"Max Timer: %i\n",MaxTimer);
	aceOut(tmp);

	gpiGetTimer(&timer1);
	sprintf(tmp,"Timer 1 is: %i\n",timer1);
	aceOut(tmp);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i \n",timer1,state);
	aceOut(tmp);

	gpiStartTimer(timer1,0,0);

	gpiGetTimer(&timer2);
	sprintf(tmp,"Timer 2 is: %i\n",timer2);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i \n",timer2,state);
	aceOut(tmp);


	gpiStartTimer(timer2,0,0);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiSleep(5000);

	gpiStopTimer(timer1);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerTime(timer1,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer1,sec,microsec);
	aceOut(tmp);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiSleep(5000);

	gpiStopTimer(timer2);

	gpiGetTimerState(timer2,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer2,state);
	aceOut(tmp);

	gpiGetTimerTime(timer2,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer2,sec,microsec);
	aceOut(tmp);

	gpiRestartTimer(timer1);

	gpiSleep(5000);

	gpiStopTimer(timer1);

	gpiGetTimerState(timer1,&state);
	sprintf(tmp,"Timer State (tsNONE|tsRUNNING|tsSTOPPED|tsTIMEOUT (%i) = %i\n",timer1,state);
	aceOut(tmp);

	gpiGetTimerTime(timer1,&sec,&microsec);
	sprintf(tmp,"Elapse Time (%i) =  %lu seconds, %lu micro-seconds\n",timer1,sec,microsec);
	aceOut(tmp);

	gpiFreeTimer(timer1);
	gpiFreeTimer(timer2);

	aceOut("Training Session - END\n");

	return 0;
}

  • No labels