cancel
Showing results for 
Search instead for 
Did you mean: 

ST25RU3993 - read complete memory bank

michaelneeser9
Associate II

Hi all,

how can I read a complete memory bank of a tag with the ST25RU3993 ?

The problem is that I don't know the number of received bytes.

Thanks in advance

Michael

1 ACCEPTED SOLUTION

Accepted Solutions
Cedric Dalban
ST Employee

Hi Michael,

The read API (STUHFL_T_RET_CODE Gen2_Read(STUHFL_T_Read *readData);) can only read 16 bytes (MAX_READ_DATA_LEN) at a time.

The parameter readData.bytes2Read is provided to specify how much bytes have to be read

and it returns how much where duly read.

So with the following piece of code you can read the full area content (here assuming you read User bank and pwd is 00000000):

    STUHFL_T_RET_CODE  ret;

    STUHFL_T_Read readData;

    readData.memBank = GEN2_MEMORY_BANK_USER;

    readData.bytes2Read = MAX_READ_DATA_LEN;

    readData.wordPtr = 0;

    memset(readData.pwd, 0, 4);

    do {

      ret = Gen2_Read(&readData);

       

      // do whatever needed with readData.data 

       

      readData.wordPtr += MAX_READ_DATA_LEN/2;

    } while ((ret==ERR_NONE) && (readData.bytes2Read == MAX_READ_DATA_LEN));

I assumed you wanted to read Gen2 tags, procedure is equivalent for Gb29768 (using Gb29768_Read())

Best regards,

Cedric.

View solution in original post

4 REPLIES 4
Cedric Dalban
ST Employee

Hi Michael,

The read API (STUHFL_T_RET_CODE Gen2_Read(STUHFL_T_Read *readData);) can only read 16 bytes (MAX_READ_DATA_LEN) at a time.

The parameter readData.bytes2Read is provided to specify how much bytes have to be read

and it returns how much where duly read.

So with the following piece of code you can read the full area content (here assuming you read User bank and pwd is 00000000):

    STUHFL_T_RET_CODE  ret;

    STUHFL_T_Read readData;

    readData.memBank = GEN2_MEMORY_BANK_USER;

    readData.bytes2Read = MAX_READ_DATA_LEN;

    readData.wordPtr = 0;

    memset(readData.pwd, 0, 4);

    do {

      ret = Gen2_Read(&readData);

       

      // do whatever needed with readData.data 

       

      readData.wordPtr += MAX_READ_DATA_LEN/2;

    } while ((ret==ERR_NONE) && (readData.bytes2Read == MAX_READ_DATA_LEN));

I assumed you wanted to read Gen2 tags, procedure is equivalent for Gb29768 (using Gb29768_Read())

Best regards,

Cedric.

Hi Cedric,
Thank you very much for the quick answer.
What value do I set to readData.bytes2Read if I don't know how many bytes the bank has ?
e.g. TID-bank of tag 1 has 8 bytes
TID-bank of tag 2 has 12 bytes
If I set readData.bytes2Read to 8, I only get 8 bytes back from tag 2
If I set readData.bytes2Read to 12 I get an error back for tag 1
Best regards,
Michael
Cedric Dalban
ST Employee

Hi Michael,

which release version do you use ?

With release v2.2.0 and as mentioned above, if you don't know the size, you just have to set bytes2read to the max size (MAX_READ_DATA_LEN)

and Gen2_Read() will update this parameter to the data really read.

Another option I did not mention, you can even set bytes2read to 0, here again Gen2_Read() will update this parameter to the data really read.

The error you get with tag1 is probably not linked to the length, could you check the returned error code value ?

To be sure could you reduce the size from 12 to 4 (or even 2) bytes ?

Hoping this helps,

regards,

Cedric

Cedric Dalban
ST Employee

Hi again Michael,

if you only want to read the tag TID, you can set, during the inventory settings phase, the parameter readTID from structure STUHFL_T_ST25RU3993_Gen2Inventory_Cfg to true,

The inventory will report tag TIDs of all found tags in parameter tagList[<index>].tid of structure STUHFL_T_Inventory_Data.

best regards,

Cedric.