Table of Contents |
---|
Tutorial #1: test shared RAM
Code Block | ||||
---|---|---|---|---|
| ||||
//---------------------------------------------------------
// 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,¶meters);
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
Code Block | ||||
---|---|---|---|---|
| ||||
//---------------------------------------------------------
// 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,¶meters);
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
Code Block | ||||
---|---|---|---|---|
| ||||
//---------------------------------------------------------
// 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,¶meters);
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,µsec);
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,µsec);
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,µsec);
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;
} |
Tutorial #4: torn
Code Block | ||||
---|---|---|---|---|
| ||||
//---------------------------------------------------------
// 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,¶meters);
typedef struct
{
tCounter mDate;
tCounter mTime;
unsigned int mUN;
} tTestTorn;
unsigned long ramSize=0;
tTestTorn* torn=0;
tByte *pRAM = 0;
tByte i;
tWord len = 0, _FF01Value = 0, startData = 0;
tByte gData[1000]="";
gpiGetPrivateScratchPAD(MASTERCARD_PAYPASS,&pRAM,&ramSize);
sprintf(tmp,"Scratch PAD Size %lu\n",ramSize);
aceOut(tmp);
torn = (tTestTorn*)pRAM;
for(i = 0; i < 20; i++)
{
setDate(&torn[i].mDate,&torn[i].mTime);
gpiGetRandomNumber(&torn[i].mUN,256);
sprintf(tmp,"Torn %i UN %.2X Date: %lu Time: %lu\n",i,torn[i].mUN,torn[i].mDate,torn[i].mTime);
aceOut(tmp);
gpiSleep(500);
}
// Send DD signal
tSignal signal;
aceSetSignal(bTRUE); // Activate signal in ACE
aceSetDigitalSignal(bTRUE); // Use digital signal instead of legacy strings
aceGetSignal(&signal); // Get ACE signal services
pmwSetSignal(&signal); // Set AgnosMW accordingly
// Init indexes
len = 0;
_FF01Value = 0;
startData = 0;
gpiMemSet(gData,0x00,sizeof(gData));
// Prepare DD
gData[len++] = 0xFF;
gData[len++] = 0x01;
gData[len++] = 0x82;
_FF01Value = len;
gData[len++] = 0x00;
gData[len++] = 0x00;
startData = len;
for(i = 0; i < 20; i++)
{
gData[len++] = 0x9F;
gData[len++] = 0x37;
gData[len++] = 0x01;
gData[len++] = torn[i].mUN;
}
gData[_FF01Value] = (len - startData) / 256;
gData[_FF01Value+1] = (len -startData) - (gData[_FF01Value] * 256);
pmwSendRawDD(gData,len);
aceOut("Training Session - END\n");
return 0;
} |