Home  Contents

v4kf:state

V4kf Core4 Lua Event System

SYNOPSIS

#include <lua/v4kf.lh>
  1. code = rdrhandle:state()
  2. name = rdrhandle:stateName([code])

DESCRIPTION

v4kf:state() provides the current state of the reader handler.

v4kf:stateName() can be used to get a printable name of the state for debugging purposes. The function returns the name of the current state when called with no parameter or the name of the passed state code.

The states are:

code name Description
V4KF_STATE_RESET Reset The reader is not initialized. Before the reader can be used, call v4kf:init() and wait for completion.
V4KF_STATE_INITIALIZING Initializing The reader is being initialized. During initialization, the shutter clicks once or twice. When initialization is complete, the reader enters one of the next states, depending whether a card is already inside.
V4KF_STATE_CLOSED Closed The shutter is closed and the reader is empty. If this state was reached via the Ejecting state, then there might be magstripe data available via v4kf:magdata() that has been read while the card was removed.
V4KF_STATE_ACCEPTING Accepting The shutter is open and the reader is waiting for a card to be inserted.
V4KF_STATE_INSERTED Inserted Card is inserted fully into the reader but not locked. With an insertion reader, the card can be removed by the user any time. With a motor reader, this state means the card is in, but the chip contact is not engaged. If the card has a magstripe that was readable, the data is available with v4kf:magdata().
V4KF_STATE_LOCKED Locked A card is inside the reader and the chip contact is mechanically connected. Some reader models prevent the card from being removed.
V4KF_STATE_EJECTING Ejecting The shutter is open and the reader is waiting for a card to be removed. When the card has been completely removed, the shutter closes and the reader enters the Closed state.
V4KF_STATE_PROCESSING Processing A chip card command is executing.
V4KF_STATE_CAPTURING Capturing A card is being transported to the rear and captured inside the reader. When the card has been captured, the reader enters the Closed state.

Notes

The Sankyo and Hopt+Schuler readers make no distinction between Inserted and Locked. An inserted card is always automatically mechanically connected to the chip contact. The state machine never enters the Inserted state.

The Hopt+Schuler CHD845 and CHD862 do not have protection against surprise removal of the card. The term Locked is misleading in that case, but kept anyway for compatibility reasons.

The Leadus V4KF insertion reader actively prevents card removal while in Locked state.

RETURN VALUE

v4kf:state() returns a number, v4kf:stateName() returns a string.

SEE ALSO