Send UID or block data from a card/tag over Wiegand
Card/tag data can be passed straight to an access controller by your VTAP reader, like data from any other card reader. The most simple scenario is where the data required is the card/tag UID. Your config.txt file will need to contain settings like those used in this example:
!VTAPconfig
MIFAREClassic=U ; Read UID data from MIFARE Classic card/tag
WiegandMode=1 ; Enable Wiegand interface
TagWiegandBits=0 ; Automatically determines the bit length from the
; extracted data.
Output on ComPort or other ASCII interface:
Hex (4-byte): C699E142
Output on Wiegand interface:
Hex (4-byte): C699E142
Binary: 11000110 10011001 11100001 01000010
When TagWiegandBits=0, the Wiegand bit length will be determined from the number of bytes of data that have been read. We recommend this automatic method where you have a mixed population of cards: For example a MIFARE Classic UID could be either 4 bytes or 7 bytes and will then produce 32 bit or 56 bit Wiegand data appropriately.
Setting a specific bit length value will cause a larger bit length UID to be truncated, or a smaller bit length UID zero-padded, to the achieve the set bit length. This may be better if your access controller only supports a small bit length data (eg 32 bit).
Additional settings are needed if you want to Read block data from MIFARE Classic card/tags or Read DESFire card/tags. And there are a number of settings which will allow you to adjust the Format of card/tag data before it is sent over the Wiegand interface.
Read block data from MIFARE Classic card/tag
If your application requires reading block data from a MIFARE Classic card/tag (MIFAREClassic=B or =3), you need to set the following additional parameters to define which block to read, and specify the key and its type, in order to read that block.
-
TagReadBlockNum specifies the block number to read. Set a value between 0 to 255 (default is TagReadBlockNum=0). MIFARE Classic 1K cards have 64 blocks; 4k cards have 256 blocks, which are numbered in decimal from 0 to 255.
-
TagReadKey is a hex value key, needed to read the block data. Set a 6-byte hexadecimal value corresponding to the key required to read the block chosen by TagReadBlockNum. There is no default for this.
Alternatively, you can save the key needed to read the block data in a file called appkey#.txt on the VTAP reader and set TagReadKeySlot=# instead, where # is the key number, an integer from 1 to 9.
-
TagReadKeyType is the key type for the key identified in TagReadKey. Set =A or =B corresponding to the MIFARE Classic key type. Default is TagReadKeyType=A.
MIFARE block data specific settings are used in the following example:
!VTAPconfig
WiegandMode=1
MIFAREClassic=B ; Read block data from MIFAREClassic card/tag
TagReadBlockNum=3 ; Read data from block 3
TagReadKey=AC42E155C409 ; Key to read the block 3
Outputs:
Hex (16-byte): 00000000000000000000000001378684
Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001 00110111 10000110 10000100
Note: Since TagReadLength is not defined, the default value of 16 bytes is used.
Remember that there are a number of additional settings which will allow you to adjust the Format of card/tag data before it is sent over the Wiegand interface if needed.
Read DESFire cards or tags over Wiegand interface
DESFire specific settings are used in the following example:
!VTAPconfig
WiegandMode=1
NFCType4=D ; Read DESFire data from NFCType4 cards
DESFire1AppID=92E672 ; 24 bit DESFire application ID to read
; (6 hex digits)
DESFire1FileID=26 ; The file ID to read, within the
; application (decimal 1 to 255)
DESFire1KeyNum=1
DESFire1KeySlot=3 ; Use the key saved in appkey3.txt
; on the VTAP reader
DESFire1Crypto=1 ; 3DES cryptography
DESFire1Format=1 ; Use Key-ID format (26bit facility code
; and number format) to read the
; stored data
Outputs:
Hex (3-byte): 323135
Binary: 10011010100110001001100100
If you use DESFire#Format=1 to select Key-ID 26-bit format, you need to be aware that different sections of the data serve different functions, as separate facility code and card number, which affects how that data converts from binary to decimal or hex:
In this case, if an output was sent to an ASCII interface, such as the COMport, that output would be a concatenation of the decimal facility code and decimal card number, 05012597.
Remember that there are a number of settings which will allow you to adjust the Format of card/tag data before it is sent over the Wiegand interface. In particular, if reading DESFire cards or tags when the DESFire#Format is not set (=0), you may want to use TagWiegandASCIIFormat (in conjunction with TagReadFormat=a and DESFire#ReadLength) since the output data format and length is not otherwise constrained.
Note: When using the Wiegand interface, multiple reads are not supported. In this case, only the lowest numbered DESFire#... settings will be used, which might not be DESFire1.... If only DESFire3... and DESFire4... settings are defined in config.txt, the DESFire3... settings would then be used for output over Wiegand.
Format of card/tag data sent over Wiegand
Before UID or block data is sent to a Wiegand interface you may need to perform a number of operations on that data, such as changing byte order, truncation, right shifting the bits, padding with zeroes or addition of parity bits. The settings required to perform these operations are discussed here:
Note: The Wiegand interface is only available if you are using the VTAP100‑PAC‑W model.
-
TagByteOrder will reverse the byte order of the block data or UID read from a card or tag. (Or use TagByteOrderTypes if you only want to reverse byte order for some card or tag types.)
-
TagReadFormat sets the format of the extracted binary block data as ASCII (a), hex (h), or decimal (d).
-
When TagReadFormat=a (ASCII), each byte is an ASCII character.
This will output the binary data from card/tag as an ASCII character sequence over ASCII interfaces (COM, Serial, Serial2, keyboard emulation). Use this setting along with TagWiegandASCIIFormat if the tag data is an ASCII sequence representing the digits of a decimal or hexadecimal value. If TagReadFormat is not set =a, binary data will be output to the Wiegand interface.
-
TagReadFormat=d will interpret the binary data as 64 bit decimal value for output to ASCII interfaces.
If the tag data is a binary sequence (not an ASCII sequence) then use TagReadFormat=d or =h along with any other settings required to adjust the binary data for output over Wiegand.
-
TagReadFormat=h (default) converts the binary data to hex digits with 2 digits per byte for output to ASCII interfaces.
-
-
TagWiegandASCIIFormat sets how to interpret tag data that contains an ASCII character sequence, representing a decimal or hexadecimal number, for output as a bit sequence over Wiegand. This setting only works when TagReadFormat=a.
-
Set TagWiegandASCIIFormat=a (default) to send the ASCII character byte values directly as a sequence of bits over Wiegand.
-
TagWiegandASCIIFormat=d to interpret the ASCII character sequence as a decimal number (up to 64 bits) when converting to a Wiegand bit sequence.
-
TagWiegandASCIIFormat=h to interpret the ASCII character sequence as a hexadecimal number when converting to a Wiegand bit sequence.
-
-
TagWiegandBits=56 lets you specify the number of bits (1 to 255) to output over the Wiegand interface, from the start of the extracted tag data. If omitted it defaults to 0, meaning that the Wiegand bit length is automatic: The number of bits is determined automatically from the number of bytes of tag data that have been read.
-
TagWiegandParity=1 adds a single 'parity bit' equivalent to the resulting bit sequence that is sent over Wiegand. This makes it possible to use tag or card data formats that include parity bits. Parity bit equivalents can be used if the parity bit(s) are not being tested for validity. TagWiegandParity=2 adds calculated odd and even parity bits to the data. Either can be used with TagReadFormat=a and TagWiegandASCIIFormat=d or =h to get decimal or hex data. Again, the default =0 turns this feature off.
-
TagReadOffset sets a byte offset within the block or UID data to start reading from, using a value between 1 to 15. This setting is often used with TagReadLength to specify starting point of the desired data to be extracted and how many bytes to read from that starting point. If using TagReadOffset along with TagReadLength, the TagReadOffset + TagReadLength values must be less than or equal to 16, otherwise the length will be reduced by truncating data. Default TagReadOffset=0 (no offset).
Note: TagReadOffset and TagReadLength are not applicable when reading secure DESFire data where DESFireReadLength is used instead.
-
TagReadRightShift will right shift decimal 64bit data. It can be used to remove any parity bits at the end of extracted binary data. Use a value from 1 to 63 to enable this setting, with a default is TagReadRightShift=0. TagReadFormat must be set to decimal (=d).
The following example shows how using TagByteOrder will change the UID card/tag data output from a VTAP reader over all interfaces.
!VTAPconfig
MIFAREClassic=U ; Read UID data from MIFARE Classic card/tag
WiegandMode=1 ; Enable Wiegand interface
Output on ComPort or other ASCII interface:
Hex (4-byte): C699E142
Output on Wiegand interface:
Hex (4-byte): C699E142
Binary: 11000110 10011001 11100001 01000010
Now, add this extra line in config.txt to reverse the byte order:
TagByteOrder=1 ; Reverse the byte order of the tag data
Output for MIFARE card/tag on ComPort or other ASCII interface:
Hex (4-byte): 42E199C6
Output for MIFARE card/tag on Wiegand interface:
Hex (4-byte): 42E199C6
Binary: 01000010 11100001 10011001 11000110
If you only want to reverse the byte order on certain types of card/tag data, refer to
The following example shows how using the card/tag data format settings can progressively change the way MIFARE Classic block data is output from a VTAP reader over all interfaces.
!VTAPconfig
WiegandMode=1
MIFAREClassic=B ; Read block data from MIFAREClassic card/tag
TagReadBlockNum=3 ; Read data from block 3
TagReadKey=AC42E155C409 ; Key to read the block 3
TagReadOffset=12 ; Start reading data after byte 12 in the
; block data
TagReadLength=4 ; Read 4 bytes starting from 13th byte in the
; block TagReadOffset+TagReadLength=16 (12+4)
Outputs:
Hex (4-byte): 01378684
Binary: 00000000 10011011 11000011 01000010
Adding two further settings in config.txt:
TagReadRightShift=1 ; Right shift the data by 1 bit to remove
; parity bit
TagReadFormat=d ; Convert extracted binary block data into
; decimal
Outputs:
Decimal: 10208066
Binary: 00000000 10011011 11000011 01000010
The right shift by 1 bit causes an extra bit (0) to be padded on the left, resulting in a whole byte of 0 on the left of the ‘payload of interest’. When outputting to ASCII in decimal, any leading zeros are not printed, however the Wiegand output is still 32 bits (including leading zeros).
And adding another two settings in config.txt:
TagReadMinDigits=9 ; Fix the number of digits to be read to 9.
TagWiegandBits=32 ; Bit length for Wiegand data from card/tags
Output for MIFARE card/tag on ComPort or other ASCII interface:
Decimal (3-byte): 010208066
Output for MIFARE card/tag on Wiegand interface:
Hex (4-byte): 009BC342
Binary: 00000000 10011011 11000011 01000010
The following example shows how using the card/tag data format settings can change the way secure DESFire data is output from a VTAP reader over all interfaces.
!VTAPconfig
WiegandMode=1
NFCType4=D ; Read DESFire data from NFCType4 cards
DESFire1AppID=92E672 ; 24 bit DESFire application ID to read
; (6 hex digits)
DESFire1FileID=26 ; The file ID to read, within the
; application (decimal 1 to 255)
DESFire1KeyNum=1
DESFire1KeySlot=3 ; use the key saved in appkey3.txt
; on the VTAP reader
DESFire1Crypto=1 ; 3DES cryptography
DESFire1Format=0 ; No format, so must set DESFireReadLength
; and TagReadFormat
DESFire1ReadLength=8 ; Number of bytes to read
; when DESFire1Format=0
Outputs:
Hex (8-byte): 3531323334333336
Binary: 00110101 00110001 00110010 00110011 00110100 00110011 00110011 00110110
And adding another setting in config.txt to output ASCII:
TagReadFormat=a ; Keep the ASCII data read from DESFire
; card/tag for ASCII interfaces. If not
; set, the data will be converted to hex
Outputs:
ASCII (8-characters) 51234336
Binary: 00110101 00110001 00110010 00110011 00110100 00110011 00110011 00110110
And adding further settings in config.txt to alter the Wiegand output only:
TagWiegandASCIIFormat=d ; Interpret the ASCII data from
; TagReadFormat as decimal
TagWiegandBits=32 ; Set the Wiegand output bit length to 32
Output for DESFire card/tag on ComPort or other ASCII interface:
ASCII: 51234336
Output for DESFire card/tag on Wiegand interface:
Hex: 030DC620