Home Contents | # v4kf:magdata | V4kf | Core4 Lua Event System

## SYNOPSIS

1. data = rdrhandle:magdata()
2. rdrhandle:clearMagdata()

## DESCRIPTION

Whenever a card is inserted or removed, any magnetic stripe data is read and buffered. The contents of the data buffer can be queried with v4kf:magdata(). It is good programming style to clear the buffer when the data has been retrieved by calling v4kf:clearMagdata(). This way, there is little chance that the application accidentally confuses old magdata already buffered for the data of the next card that comes along.

The returned data is a list which in turn contains three tables, one for each magstripe track.

The table for each track contains the fields:

status | Read status of that track.
data | Decoded read data, if available.

If status is 0, the track was successfully read. Even if status is not 0, however, there might be data present in the data field, which is the part of the data that could be decoded until a decode error was encountered.

The status field is taken directly from the reader. Following is an excerpt from the original documentation:

40 | Read Error (SS error) | The C/R has failed to detect the SS code in the read data.
41 | Read Error (ES error) | The C/R has failed to detect the ES code after the SS code in the read data.
42 | Read Error (VRC error) | Vertical parity error (VRC error) has been detected in the read data. (excluding SS and ES codes).
43 | Read Error (LRC error) | The next character of ES in the read data did not agree with the LRC calculation result.
44 | Read Error (Not Encoded) | The read magnetic data was not encoded.
45 | Read Error (No Data) | The next character of SS in the read data was ES, and the next character agreed with the LRC calculation result.
46 | Read Error (Jitter Error) | Not above Read Error ("40"~"45"). More than 10 Bits = Over Permission Value of Jitter in Read Data.
49 | Read Track setting Error | The specified track has not been read.
4A | Read Error (Card Held by User) | When a card was inserted or pulled out, it was held by an end user.

## EXAMPLE

> > > > > > >
md = rdr:magdata() for nr = 1,3 do print("\nTRACK", nr) for k,v in pairs(md[nr]) do print(k,v) end end
TRACK 1 status 0 data HELLO WORLD TRACK 2 status 43 data TRACK 3 status 40 data