13.56MHz MIFARE Reader Module

Write

Command  
CMD DATA
‘w’ write block block (1 byte) 00…3F data (16 bytes)
‘wv’ write value block block (1 byte) 00…3F value (4 bytes)
‘we’ write register register (1 byte) 00..0F data (1 byte)
‘wm’ write master key key number (1 byte) 00…1F key (6 bytes)

Binary Frame: write block 04h, data 001122…:

02 01 12 77 04 00 11 22 33 44 55 66 77 88 99 AA BB CC DD EE FF 60 03

write value block 04h, value 00112233: 02 01 07 77 76 04 00 11 22 33 03 03 write register 10h (user data), data AAh 02 01 04 77 65 10 AA AD 03 write master key 0, keydata A0A1A2A3A4A5: 02 01 09 77 6D 00 A0 A1 A2 A3 A4 A5 13 03

Answer  
ANS DATA
None write block: written data (16 bytes) write value: written value (4 bytes) write register: written value (1 byte) write master key: written key (6 bytes)
‘X’: unable to read after write none
‘U’: read after write error none
‘N’: no TAG none
‘F’: write failure none
‘I’: write failure none

⇒ Writes a block or sets a value. A read after write is performed automatically.

Writing blocks

The writing procedure requires a successful authentication, which requires a select and login before.

No tag error ‘N’

This means that the tag does not respond, because there is either no tag present or none of the tags in the field is not authenticated (login instruction).   

Invalid value ‘I’
The value read back after the write value instruction is a not a value block. Data was written corruptly. In almost all cases you can handle this similar to a write failure ‘F’.

Unable to read after write ‘X’
TAG was removed from field immediately after the write instruction. Data was written but the TAG did not response to the Read after Write Instruction (which is done automatically by the reader module). Data stored on the TAG may be corrupted.

Read after write error ‘U’
After each write access to the TAG a read is done automatically. This error occurs if the data read does not match the written one. This is caused when data was not stored on the TAG or if the sector is protected (f.e. keys of sector trailers are read protected and will always cause a read after write error although written correctly).

Write failure ‘F’
Additional to an data write error caused by bad transmission conditions, this error appear if you want to write a block which is not in your currently authenticated sector. i.e. if you try to read the block 02 (sector 0) after you just logged in into sector 1 (using the ‘l01..’ command).

Writing values
The write value block command is designed to create blocks which match the value format. This command requires write access to specified block. It is not recommended to use this instruction for ticketing operations. For ticketing algorithms special instructions (Increment/Decrement/Copy) are supported.

Writing to the EEPROM
Writing to the internal reader EEPROM takes approximately 3 ms per byte. If the supply voltage is turned off while the reader is programming, data in the EEPROM may be corrupted. The reader is transmitting the write acknowledge (6 bytes key data) after successful programming of the EEPROM. Reset reader to activate parameter changes.

Master keys
Master keys are not readable. Due to data security reasons master keys are stored redundant, consuming 12 bytes per key. The reader module allows to store up to 32 master keys. They are stored non-volatile.

Writing master keys
Due to the fact that master keys are stored in a write only area the reader module is not able to do a read after write for this sections. 

Writing to the Sector Trailer

Because of some parts of the sector Trailer are write only (key areas) writing to the Sector Trailer will cause a “read after write“ (‘U’) error. If a part of the Sector Trailer is write protected (i.e. key A area), dummy data is required for a successful write operation.

Examples:

w08000102030405060708090A0B0C0D0 E0F writes a data stream (000102…) to block 8 (sector 2)
wv05010055EF writes value 010055EF to block 5.
we0464 write the value 64h to the STATIONID register
we0502 set the reader in binary mode (write 02h into the Protocol Configuration register)
wm00112233445566 store key 112233445566 in EEPROM (key number 0)
wm02A0A1A2A3A4A5 store transport key 1 in EEPROM key 2
we0600 sets the reader to 9600 baud