cancel
Showing results for 
Search instead for 
Did you mean: 

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

Andrew Sotov
Associate
Posted on February 09, 2018 at 02:03

  1. Hi!

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

  3. 1. I sending 9370 and 9570 same as in your iso14443a_select_by_uid.py.

  4. All is OK with them, both returns 0.

  5. 2. Next RATS:

  6.     char *rxRats = new char[1024];

  7.     for (int i = 0; i < 1024; i++) {

  8.         rxRats[i] = '\0';

  9.     }

  10.     size_t rxRatsSize = 0;

  11.     res = iso14443aRATS(h, 256, 0x1, rxRats, &rxRatsSize);

  12.     printf('%d\r\n', res);

  13.     printf('%d\r\n', rxRatsSize);

  14. 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.

  15. 3. Next PPS (dr and ds just set to my mind's random 8):

  16.     printf('--- PPS: ---\r\n');

  17.     char *rxPPS = new char[1024];

  18.     for (int i = 0; i < 1024; i++) {

  19.         rxPPS[i] = '\0';

  20.     }

  21.     size_t rxPPSSize = 1024;

  22.     res = iso14443aPPS(h, 0x1, 8, 8, true, rxPPS, &rxPPSSize);

  23.     printf('%d\r\n', res);

  24.     printf('%d\r\n', rxPPSSize);

  25. Also all OK, res = 0.

  26. 4. And now request:

  27.     printf('--- Req 3: ---\r\n');

  28.     pcb_t pcb;

  29.     pcb.b1 = 0; // Block number

  30.     pcb.b2 = 1;

  31.     pcb.b3 = 0; // is NAD set

  32.     pcb.b4 = 1; // is CID set

  33.     pcb.b5 = 0; // is Chaining

  34.     pcb.b6 = 0;

  35.     pcb.b7 = 0;

  36.     pcb.b8 = 0;

  37.     char *cl3 = new char[24];

  38.     cl3[0] = *(char*)&pcb;

  39.     cl3[1] = 0x1;

  40.     cl3[2] // 2-21 - some APDU command

  41.     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]

  42.     , cl3[11], cl3[12], cl3[13], cl3[14], cl3[15], cl3[16], cl3[17], cl3[18], cl3[19], cl3[20], cl3[21]};

  43.     int crc16m = crc16(arr, 1, 0x6363, false);

  44.     cl3[22] = ((unsigned char *)(&crc16m))[1];

  45.     cl3[23] = ((unsigned char *)(&crc16m))[0];

  46.     sak = new char[256];

  47.     sak_size = 256;

  48.     for (int i = 0; i < 256; i++) {

  49.         sak[i] = '\0';

  50.     }

  51.     res = txrxBytes(h, cl3, 24, sak, &sak_size, &us);

  52.     printf('%d\r\n', res);

  53.     printf('|SS: %d|\r\n', sak_size);

  54.     for (int i = 0; i < sak_size; i++) {

  55.         printf('|s 0x%02hhx|\r\n', (unsigned char)sak[i]);

  56.     }

  57. 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).

  58. I tried different combination of 2, 4 and 8 parameters in iso14443aPPS but no effect.

  59. How should I fix it?

#st25 #st25r3911b-disco
1 ACCEPTED SOLUTION

Accepted Solutions
Ulysses HERNIOSUS
ST Employee
Posted on February 09, 2018 at 15:04

Hi Andrew,

I think we will need to improve here a bit the documentation of the DLL. 

  • Parameter fsd of the RATS command is really fsdi, so best to  use an 8 here. You can find this in the documentation of the Firmware source of ST25R3911B-DISCO.
  • The values for dr and ds are 106,212,424,848. For now please stay with 106 or omit PPS (it is optional).
  • APDU transceive: CRC will be added by ST25R3911B hardware. You should not add it.
  • Please report value of res, I assume you get a framing error or such.
  • For PPS the DLL will automatically tell the reader also to change the new bitrate.

If this doesn't help you, then please provide a printout of all your sent and received bytes, length parameters and return codes.

Regards, Ulysses

View solution in original post

1 REPLY 1
Ulysses HERNIOSUS
ST Employee
Posted on February 09, 2018 at 15:04

Hi Andrew,

I think we will need to improve here a bit the documentation of the DLL. 

  • Parameter fsd of the RATS command is really fsdi, so best to  use an 8 here. You can find this in the documentation of the Firmware source of ST25R3911B-DISCO.
  • The values for dr and ds are 106,212,424,848. For now please stay with 106 or omit PPS (it is optional).
  • APDU transceive: CRC will be added by ST25R3911B hardware. You should not add it.
  • Please report value of res, I assume you get a framing error or such.
  • For PPS the DLL will automatically tell the reader also to change the new bitrate.

If this doesn't help you, then please provide a printout of all your sent and received bytes, length parameters and return codes.

Regards, Ulysses