Skip to content
GBG Documents & Biometrics Documentation

MagLib library

The MagLib library controls the magnetic reader and collects and analyses its data once a card is swiped. It scans COM1 to COM16 for the reader and initialises it; after a swipe, the data is parsed and the library’s properties are refreshed. The data format is detected automatically. The driving licence formats supported are AAMVA, the old California DMV format and the old Louisiana DMV format.

Scans COM1–COM16 and searches for the magnetic reader device. Once found, the reader is initialized and the library loads and initializes.

Syntax

InitLibrary(License As String) As Long

Parameters

Parameter Description
[in] License Null-terminated string that contains license key value

Return Values

Value Description
LICENSE_VALID License valid; library ready for use
LICENSE_INVALID License invalid; all scanner operations disabled
LICENSE_EXPIRED License expired; all scanner operations disabled
LICENSE_DOES_NOT_MATCH_LIBRARY License does not match library; all library operations disabled
GENERAL_ERR_PLUG_NOT_FOUND Returned if the attached scanner is not one of the following: ScanShell 600. ScanShell 800. ScanShell 1000
MAG_ERR_NO_READER_FOUND Magnetic reader device not found on any PC ports

Detects if the magnetic stripe reader is connected and functioning. The reader is searched for in the COM port which is found in the InitLibrary function.

Syntax

IsReaderValid() As Long

Return Values

Value Description
MAG_ERR_NO_READER_FOUND Reader not connected to PC
MAG_ERR_NONE Reader connected to PC and functioning correctly

Call this function periodically to find out if a new card swipe was performed. If no new swipe was performed, the function returns MAG_ERR_CARD_NOT_DETECTED. If the reader detects a new swipe, it returns MAG_ERR_CARD_DETECTED. If the system is in error condition (due to bad initialization or disconnection of the reader from the PC), the function returns one of the other values.

Syntax

WasCardSweeped() As Long

Return Values

Value Description
MAG_ERR_NO_READER_FOUND Reader is not connected to the PC
SERIAL_NOT_INIT Serial port not initialized
SERIAL_PORT_NOT_OPEN Serial port could not be opened
SERIAL_PORT_CONFIG_FAIL COM port configuration failed
SERIAL_COM_TIMEOUT_FAIL COM port timeout failure
MAG_ERR_CARD_NOT_DETECTED No new card swipe detected from last call to this function
MAG_ERR_CARD_DETECTED Recent card swipe detected and data available for processing

Processes the recently swiped card raw data. The raw data is scanned for format detection. If a specific format is detected, the data is parsed further and loads the library properties.

Syntax

Process() As Long

Return Values

Value Description
LONG_AAMVA Standard AAMVA format (includes channel1, channel2 and channel3)
SHORT_AAMVA Short AAMVA format (includes channel1 and channel3)
OLD_CA_DMV Old DMV format (California)
OLD_LA_DMV Old DMV format (Louisiana)
UNKNOWN_FORMAT Unknown format; no further processing performed

Gets the data as retrieved from the magnetic reader device without further processing

Syntax

GetRawData(buffer As String) As Long

Parameters

Parameter Description
[in] Buffer Null-terminated string that receives the raw data

Return Values

Value Description
MAG_ERR_NONE Data retrieved successfully
MAG_ERR_CARD_NOT_DETECTED Buffer is empty

The MagLib library stores the detected textual information in an internal data structure. This structure is refreshed in each Process() function call. Some of the properties are relevant to some magnetic card formats and some are irrelevant. For example, the property ISSUE is relevant to the California Old DMV ID cards and not to standard AAMVA cards. If a property is irrelevant to a particular state, or if the field is not detected, it clears to an empty string. Loading the properties is done using a simple string assignment. The supported properties are:

Address City Class
DateOfBirth Endorsements ExpirationDate
Eyes Hair Height
Issue License NameFirst
NameLast NameMiddle Restriction
Sex State Weight
Zip