WriteMiFareData
async function WriteMiFareData(ctx: any, startBlockAddress: number, numberOfBlocks: number, dataToWrite: string | Uint8Array, usbConfig: any): {serialNumber: string; payload: string}
The asynchronous function WriteMiFareData writes data to a MiFare Classic Standard card via the serial interface connected to the browser. The data is saved via a memory area that is specified with the address and the number of blocks to be written. A block corresponds to 16 bytes, the address indicates the sector in which the data is stored.
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. | |
dataToWrite | Data set to be saved on the card. | |
usbConfig | Configuration data of the connected serial interface. |
Return value
Type | Description |
---|---|
|
Example:
The data set (dataToWrite = „Loremipsumdolorsitametconsectetu“
) with a size of 32 bytes is to be written to 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 - in this example 9600
. The keyType
is defined by the MiFare Classic card used (here: ‚A‘
- the authentication key from the application (the default value is 281474976710655.0
, which corresponds to the hexadecimal value 0xFFFF FFFF FFFF
).
const dataToWrite = ‘Loremipsumdolorsitametconsectetu
’;
const writeMiFare = TcHmi.Functions.getFunction('TcHmi.Functions.Plastic.WriteMiFareData');
const data = await readMiFare(
ctx,
2,
2,
dataToWrite,
{
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