Click or drag to resize

MagCardReader Interface

Provides access to the magnetic card reader, for devices equipped with one.

Namespace:  Zebra.Sdk.Device
Assembly:  SdkApi_Core (in SdkApi_Core.dll) Version: 2.13.898
Syntax
public interface MagCardReader

The MagCardReader type exposes the following members.

Methods
  NameDescription
Public methodRead
Activates the device's magnetic card reader, if present, and waits for a card to be swiped.
Top
Examples
using System;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Device;
using Zebra.Sdk.Printer;

public class MagCardReaderExample {

    public static void Main(string[] args) {
        Connection connection = new TcpConnection("192.168.1.100", TcpConnection.DEFAULT_CPCL_TCP_PORT);

        try {
            connection.Open();
            ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection);
            MagCardReader mcr = MagCardReaderFactory.Create(printer);
            if (mcr != null) {
                string[] trackData = mcr.Read(10 * 1000);
                Console.WriteLine("Track1: " + trackData[0]);
                Console.WriteLine("Track2: " + trackData[1]);
                Console.WriteLine("Track3: " + trackData[2]);
            }
        } catch (ConnectionException e) {
            Console.WriteLine(e.ToString());
        } catch (ZebraPrinterLanguageUnknownException e) {
            Console.WriteLine(e.ToString());
        } finally {
            connection.Close();
        }
    }
}
See Also