AnsweredAssumed Answered

I working with ST25R3911DiscoComm.dll and writing in C/C++

Question asked by Andrew Sotov on Feb 9, 2018
Latest reply on Feb 9, 2018 by Ulysses HERNIOSUS
  1. Hi!
  2.  
  3. I working with ST25R3911DiscoComm.dll and writing in C/C++.
  4.  
  5. 1. I sending 9370 and 9570 same as in your iso14443a_select_by_uid.py.
  6. All is OK with them, both returns 0.
  7.  
  8. 2. Next RATS:
  9.     char *rxRats = new char[1024];
  10.     for (int i = 0; i < 1024; i++) {
  11.         rxRats[i] = '\0';
  12.     }
  13.     size_t rxRatsSize = 0;
  14.     res = iso14443aRATS(h, 256, 0x1, rxRats, &rxRatsSize);
  15.     printf("%d\r\n", res);
  16.     printf("%d\r\n", rxRatsSize);
  17. Also all OK, res = 0. But I cannot receive some response in rxRats therefore I have no idea about ds and dr parameters for PPS.
  18.  
  19. 3. Next PPS (dr and ds just set to my mind's random 8):
  20.     printf("--- PPS: ---\r\n");
  21.     char *rxPPS = new char[1024];
  22.     for (int i = 0; i < 1024; i++) {
  23.         rxPPS[i] = '\0';
  24.     }
  25.     size_t rxPPSSize = 1024;
  26.     res = iso14443aPPS(h, 0x1, 8, 8, true, rxPPS, &rxPPSSize);
  27.     printf("%d\r\n", res);
  28.     printf("%d\r\n", rxPPSSize);
  29. Also all OK, res = 0.
  30.  
  31. 4. And now request:
  32.     printf("--- Req 3: ---\r\n");
  33.     pcb_t pcb;
  34.     pcb.b1 = 0; // Block number
  35.     pcb.b2 = 1;
  36.     pcb.b3 = 0; // is NAD set
  37.     pcb.b4 = 1; // is CID set
  38.     pcb.b5 = 0; // is Chaining
  39.     pcb.b6 = 0;
  40.     pcb.b7 = 0;
  41.     pcb.b8 = 0;
  42.     char *cl3 = new char[24];
  43.     cl3[0] = *(char*)&pcb;
  44.     cl3[1] = 0x1;
  45.     cl3[2] // 2-21 - some APDU command
  46.     unsigned char arr [] = { cl3[0], cl3[1], cl3[2], cl3[3], cl3[4], cl3[5], cl3[6], cl3[7], cl3[8], cl3[9], cl3[10]
  47.     , cl3[11], cl3[12], cl3[13], cl3[14], cl3[15], cl3[16], cl3[17], cl3[18], cl3[19], cl3[20], cl3[21]};
  48.     int crc16m = crc16(arr, 1, 0x6363, false);
  49.     cl3[22] = ((unsigned char *)(&crc16m))[1];
  50.     cl3[23] = ((unsigned char *)(&crc16m))[0];
  51.     sak = new char[256];
  52.     sak_size = 256;
  53.     for (int i = 0; i < 256; i++) {
  54.         sak[i] = '\0';
  55.     }
  56.     res = txrxBytes(h, cl3, 24, sak, &sak_size, &us);
  57.     printf("%d\r\n", res);
  58.     printf("|SS: %d|\r\n", sak_size);
  59.     for (int i = 0; i < sak_size; i++) {
  60.         printf("|s 0x%02hhx|\r\n", (unsigned char)sak[i]);
  61.     }
  62. And in result I got sak_size = 14 bytes. I seing these bytes printf'ed in console, they are 100% correct? but 14 bytes is too few, this "response" even haven't some status code (9000 or another).
  63.  
  64. I tried different combination of 2, 4 and 8 parameters in iso14443aPPS but no effect.
  65.  
  66. How should I fix it?

Outcomes