readBlock method
Reads data from a specific block of an RFID tag.
This method sends an APDU command to the RFID reader to read a specified amount of data from a given block number on the RFID tag. It is useful for retrieving stored information on the tag, such as identifiers or other data.
Parameters
blockNumber
: The block number from which to read data.length
: The number of bytes to read from the specified block.
Returns
A list of integers representing the data read from the specified block.
Throws
- Exceptions related to APDU transmission failures or if the RFID tag responds with an error.
Example
var data = await readBlock(blockNumber: 4, length: 16);
print('Data read from block: $data');
Note: Ensure the block number and length are within the limits supported by the RFID tag.
Implementation
@override
Future<List<int>> readBlock({
required int blockNumber,
required int length,
}) async {
return (await transmitApdu(
ApduHeader(
classNumber: 0xFF,
instruction: 0xB0,
p1: 0x00,
p2: blockNumber,
),
le: length,
))
.data;
}