Create File in Mifare Desfire. Return error response like 0x0E DESFire card related exception has occurred. what is the correct command to create files in mifare desfire
CreateStdDataFile(FileNo,Com.Set.,AccessRights,FileSize)
[8bytes]
public void CreateFile() throws Exception {
byte[] buffer = new byte[7];
buffer[0] = (byte) ((0x00)); //file Number
buffer[1] = (byte) ((0xFF)); //Comm. Sett.
buffer[2] = (byte) (0x00); // 2 & 3 Access Rights
buffer[3] = (byte) (0x04);
buffer[4] = (byte) (0x00); // 4 & 5 & 6 File Size
buffer[5] = (byte) (0x00);
buffer[6] = (byte) (0x0F);
sendRequest(CREATE_FILE,buffer);
}
try
{
reader.CreateFile();
}
catch (Exception e) {
Log.d(TAG, "Problem accessing Desfire tag", e);
} finally {
try {
isoDep.close();
} catch (IOException e) {
// ignore
}
}
The problem you are experiencing is endianness . (See in particular the Illustration section.)
The DESFire instruction requires you to pass the file size in the least significant byte order (little-endian), but your code uses the most significant byte order (big-endian).
The way you currently have it in your code ( 0x00, 0x00, 0x0F
) you are not asking for a file of size 0x00000F
(15) bytes, but 0x0F0000
(983 040) bytes.
To request a file of size 15 bytes, your code should be:
// ...
buffer[4] = (byte)0x0F;
buffer[5] = (byte)0x00;
buffer[6] = (byte)0x00;
// ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.