ST意法半导体
直播中

杨丽

7年用户 156经验值
私信 关注
[问答]

如何使用ST25R3911DiscoComm.dll并用C / C ++进行编写

嗨!

我使用ST25R3911DiscoComm.dll并用C / C ++编写。

1.我发送9370和9570与你的iso14443a_select_by_uid.py相同。
一切都好,两者都返回0。

2.下一步RATS:
char * rxRats = new char [1024];
for(int i = 0; i< 1024; i ++){
rxRats =' 0';
}
size_t rxRatsSize = 0;
res = iso14443aRATS(h,256,0x1,rxRats,& rxRatsSize);
printf('%d  r  n',res);
printf('%d  r  n',rxRatsSize);
还好,res = 0.但是我无法在rxRats中收到一些响应,因此我不知道PPS的ds和dr参数。

3.下一个PPS(dr和ds只是设置在我脑海中的随机8):
printf('--- PPS:---  r  n');
char * rxPPS = new char [1024];
for(int i = 0; i< 1024; i ++){
rxPPS =' 0';
}
size_t rxPPSSize = 1024;
res = iso14443aPPS(h,0x1,8,8,true,rxPPS,& rxPPSSize);
printf('%d  r  n',res);
printf('%d  r  n',rxPPSSize);
也一切OK,res = 0。

4.现在请求:
printf('--- Req 3:---  r  n');
PCB_t pcb;
pcb.b1 = 0; //块号
pcb.b2 = 1;
pcb.b3 = 0; //是NAD设置
pcb.b4 = 1; //是CID集
pcb.b5 = 0; //是Chaining
pcb.b6 = 0;
pcb.b7 = 0;
pcb.b8 = 0;
char * cl3 = new char [24];
cl3 [0] = *(char *)& pcb;
cl3 [1] = 0x1;
cl3 [2] // 2-21 - 一些APDU命令
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]
,cl3 [11],cl3 [12],cl3 [13],cl3 [14],cl3 [15],cl3 [16],cl3 [17],cl3 [18],cl3 [19],cl3 [20] ,cl3 [21]};
int crc16m = crc16(arr,1,0,036363,false);
cl3 [22] =((unsigned char *)(& crc16m))[1];
cl3 [23] =((unsigned char *)(& crc16m))[0];
sak = new char [256];
sak_size = 256;
for(int i = 0; i< 256; i ++){
sak =' 0';
}
res = txrxBytes(h,cl3,24,sak,& sak_size,& us);
printf('%d  r  n',res);
printf('| SS:%d |  r  n',sak_size);
for(int i = 0; i< sak_size; i ++){
printf('| s 0x%02hhx |  r  n',(unsigned char)sak );
}
结果我得到sak_size = 14个字节。我在控制台中将这些字节打印出来,它们100%正确吗?但是14个字节太少,这个“响应”甚至没有一些状态代码(9000或另一个)。

我在iso14443aPPS尝试了不同的2,4和8参数组合,但没有效果。

我应该怎么解决?

#st25#st25r3911b-disco

以上来自于谷歌翻译


以下为原文




  • Hi!
  • I working with ST25R3911DiscoComm.dll and writing in C/C++.
  • 1. I sending 9370 and 9570 same as in your iso14443a_select_by_uid.py.
  • All is OK with them, both returns 0.
  • 2. Next RATS:
  •     char *rxRats = new char[1024];
  •     for (int i = 0; i < 1024; i++) {
  •         rxRats = '';
  •     }
  •     size_t rxRatsSize = 0;
  •     res = iso14443aRATS(h, 256, 0x1, rxRats, &rxRatsSize);
  •     printf('%drn', res);
  •     printf('%drn', rxRatsSize);
  • 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.
  • 3. Next PPS (dr and ds just set to my mind's random 8):
  •     printf('--- PPS: ---rn');
  •     char *rxPPS = new char[1024];
  •     for (int i = 0; i < 1024; i++) {
  •         rxPPS = '';
  •     }
  •     size_t rxPPSSize = 1024;
  •     res = iso14443aPPS(h, 0x1, 8, 8, true, rxPPS, &rxPPSSize);
  •     printf('%drn', res);
  •     printf('%drn', rxPPSSize);
  • Also all OK, res = 0.
  • 4. And now request:
  •     printf('--- Req 3: ---rn');
  •     pcb_t pcb;
  •     pcb.b1 = 0; // Block number
  •     pcb.b2 = 1;
  •     pcb.b3 = 0; // is NAD set
  •     pcb.b4 = 1; // is CID set
  •     pcb.b5 = 0; // is Chaining
  •     pcb.b6 = 0;
  •     pcb.b7 = 0;
  •     pcb.b8 = 0;
  •     char *cl3 = new char[24];
  •     cl3[0] = *(char*)&pcb;
  •     cl3[1] = 0x1;
  •     cl3[2] // 2-21 - some APDU command
  •     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]
  •     , cl3[11], cl3[12], cl3[13], cl3[14], cl3[15], cl3[16], cl3[17], cl3[18], cl3[19], cl3[20], cl3[21]};
  •     int crc16m = crc16(arr, 1, 0x6363, false);
  •     cl3[22] = ((unsigned char *)(&crc16m))[1];
  •     cl3[23] = ((unsigned char *)(&crc16m))[0];
  •     sak = new char[256];
  •     sak_size = 256;
  •     for (int i = 0; i < 256; i++) {
  •         sak = '';
  •     }
  •     res = txrxBytes(h, cl3, 24, sak, &sak_size, &us);
  •     printf('%drn', res);
  •     printf('|SS: %d|rn', sak_size);
  •     for (int i = 0; i < sak_size; i++) {
  •         printf('|s 0x%02hhx|rn', (unsigned char)sak);
  •     }
  • 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).
  • I tried different combination of 2, 4 and 8 parameters in iso14443aPPS but no effect.
  • How should I fix it?


#st25 #st25r3911b-disco

回帖(1)

周志光

2019-7-18 16:23:25
嗨安德鲁,
我想我们需要在这里改进DLL的文档。
 RATS命令的参数fsd实际上是fsdi,所以最好在这里使用8。您可以在ST25R3911B-DISCO的固件源文档中找到它.dr和ds的值是106,212,424,848。现在请保持106或省略PPS(可选).APDU收发:CRC将由ST25R3911B硬件添加。你不应该添加它。请报告res的值,我假设你得到一个帧错误等。对于PPS,DLL会自动告诉读者也改变新的比特率。如果这对你没有帮助,那么请提供一个打印出所有发送和接收的字节,长度参数和返回码。
问候,尤利西斯

以上来自于谷歌翻译


以下为原文




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
举报

更多回帖

发帖
×
20
完善资料,
赚取积分