ReadMiFareData
async function ReadMiFareData(ctx: any, startBlockAddress: number, numberOfBlocks: number, usbConfig: any): {payload: string | null; serialNumber: string | null}
The asynchronous function ReadMiFareData reads data stored on a MiFare Classic Standard card via the serial interface connected to the browser. The data is read out via a memory area that is specified with the address and the number of blocks to be read. A block corresponds to 16 bytes, the address indicates the sector in which the data is located.
Browser compatibility The function is only compatible with Google Chrome and Microsoft Edge. |
Parameter
Name | Type | Description |
---|---|---|
ctx | any, Context | Asynchronous context object |
startBlockAddress | Sector in which the block with the data set to be read is located. | |
numberOfBlocks | Number of blocks to be read. | |
usbConfig | Configuration data of the connected serial interface. |
Return value
Type | Description |
---|---|
|
Example:
A data set of 32 bytes is to be read from sector 2. The following figure shows the parameters "startBlockAddress
= 2" and "numberOfBlocks
= 2". The USB port has already been connected with the ConnectToComPort function and the vendor ID (4292) and product ID (60000) have been read out via "GetConnectedComPortInfo
". The baud rate must be determined from the data sheet of the serial interface. The keyType
is defined by the MiFare Classic card used - the authentication key from the application (the default value here is 281474976710655.0
, which corresponds to the hexadecimal value 0xFFFF FFFF FFFF
).
const readMiFare = TcHmi.Functions.getFunction('TcHmi.Functions.Plastic.ReadMiFareData');
const data = await readMiFare(
ctx,
2,
2,
{
vendorId: 4292,
productId: 60000,
baudrate: 9600,
keyType: ‘A’,
authenticationKey = 281474976710655.0
}
);
console.log(data);
NuGet package: Beckhoff.TwinCAT.HMI.Plastic.RFID
Available: from version 12.14.0
Usage: TC3 Plastic Application HMI projects