Home  Contents

Introduction

Magstripe Core4 Lua Event System

OVERVIEW

The magstripe module provides support for generic magstripe reading on the V4 Controller only.

This is a high level interface to magstripe reading. Allocate a new instance using magstripe.new().

The reader can be controlled using magstripe:enable(), magstripe:disable(), magstripe:trigger().

A callback named magstripe.magdataChanged() reports whenever a new card was read.

The raw data must be decoded using magstripe.decode().

EXAMPLE

The following sample code will enable the reader and print each card that was read. It allows swiping the card in both directions by trying to decode the raw data forward and backward.

>  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  >  > 
app = event.new() mag = magstripe.new(app) function mag.magdataChanged(mag, magdata) for track, data in ipairs(magdata) do local dec, err dec, err = magstripe.decode(track, data) if (err ~= 0) then dec, err = magstripe.decode(track, data:bitrevert()) end print (track, err, dec) end end mag:enable() while true do app:poll() end