I am new to POS programming using C language. I want to loop through the returned hex data and also print it to the screen after sending the APDU command and getting a response. Here is my main problem requirements.
First I elect the EMV Application using PSE method 1PAY.SYS.DD01
I read the record of the PSE which returns me the AID
I select the AID currently I'm using cards with VISA AIDs (A0 00 00 00 03 10 10 and A0 00 00 00 03 20 10) 3.I read the record of the AID interestingly for the first AID, it returns the magnetic stripe info without using GPO command first while the second one for some cards it requires them so I next get the GPO to process it
I then read the records from the card. The problem is I am outputting this byte info so its easy for me to track what's going on but the POS terminal I am using can only output a given number of characters on the screen. First I have space for 18 bytes, then I can have up to maximum of 35 bytes to display after clearing the screen everytime the user presses the arrow down button.
To do this, I used some variables below
int variab = 0, offset = 18, remainingBytes = apduResp.LenOut - 18, limit = apduResp.LenOut, AIDChooser = 0; // To track output data scroll // option if (apduResp.LenOut == 0) { offset = 0; remainingBytes = 0; limit = 0; } else if (apduResp.LenOut > 0) { int variab = 0, offset = 18, remainingBytes = apduResp.LenOut - 18, limit = apduResp.LenOut, AIDChooser = 0; }
Then I put the code below in a loop that runs while the arrow down key is pressed I read all the data and this is what it is supposed to do
i) Read all response bytes and the length
ii) check if the remaining bytes are more than 35, add 35 to the loop offset and then print the next 35 up to the limit which is (offset + 35). and if the remaining bytes are less than 35, print them out and stop.
The problem is when the intial data length is 0, pressing the scroll button doesn't show subsequent data but if the initial response data is greater than zero, the function works as required, can anyone figure out what I'm doing wrong?
if (remainingBytes > 35)
{
limit = offset + 35;
for (i_sn = offset; i_sn < limit; i_sn++)
{
sn_display += sprintf(sn_display, "%02X ", `apduResp.DataOut[i_sn]);
TP_LcdPrintf(" %s", te);
}
offset = limit; // Change
// offset
remainingBytes = apduResp.LenOut - limit; // Reduce
// remaining bytes
}
else if (remainingBytes == 0)
{
TP_LcdPrintf(" %s", " No more data\n Press Cancel to\n return");
}
else if (remainingBytes > 0 && remainingBytes < 35)
{
for (i_sn = offset; i_sn < apduResp.LenOut; i_sn++)
{
sn_display += sprintf(sn_display, "%02X ", apduResp.DataOut[i_sn]);
TP_LcdPrintf(" %s", te);
}
offset = limit;
remainingBytes = apduResp.LenOut - limit;
}
////indent: Standard input:32: Error:Stmt nesting error.
}