Motorola CoreScanner Driver Wrapper
Welcome!

Introduction

Thank you for using this tool. My name is Jason, I was assigned to complete this project by my employer Fortelinea. We decided to start this open source project when we realised how frustrating and anti-object-oriented the Motorola CoreScanner driver is. Most of the scanner commands and attributes were originally executed or modified using XML and a single method. This wrapper breaks them up into individual methods and properties and organizes them in a meaningful object-oriented fashion. It also parses the XML outputs into appropriate objects and values and generates input XML for the values you provide allowing you to forget about all the annoying XML and write clearer, more object-oriented code.

Getting Started

First, open an instance of the CoreScanner driver.

static void Main()
{
//First open an instance of the CoreScanner driver.
BarcodeScannerManager.Instance.Open();

Next, register for all events that you want to listen for in your application.

BarcodeScannerManager.Instance.RegisterForEvents(
EventType.Barcode,
EventType.Pnp,
EventType.Image,
EventType.Other,
EventType.Rmd
);

If you need to unregister.

BarcodeScannerManager.Instance.UnRegisterForEvents(
EventType.Barcode,
EventType.Pnp,
EventType.Image,
EventType.Other,
EventType.Rmd
);

To check which events you are registered to check RegisteredEvents.

//The events you are currently registered to will be listed in RegisteredEvents.
if (BarcodeScannerManager.Instance.RegisteredEvents.Contains(EventType.Image))
{
//Do things
};

You can now get a List<IMotorolaBarcodeScanner> containing your connected scanners with GetDevices().

//Get a List<IMotorolaBarcodeScanner> containing each connected scanner.
_scanners = BarcodeScannerManager.Instance.GetDevices();

You may have to set your scanners to the proper USB host mode before it will function correctly.

//Loop through scanners and set their host mode to SNAPI with imaging enabled.
foreach (var scanner in _scanners)
{
scanner.SetHostMode(HostMode.USB_SNAPI_Imaging);
}

Add a handler to your DataReceived event.

BarcodeScannerManager.Instance.DataReceived += OnDataReceived;

Example DataReceived handler:

//Outputs barcode data to the console and overwrites _lastScanned.
private static void OnDataReceived(object sender, BarcodeScanEventArgs e)
{
_lastScanned = e.Data;
Console.WriteLine("Barcode type: " + e.BarcodeType.GetDescription());
Console.WriteLine("Data: " + e.Data);
}
complete class.

Licensed by The MIT License (MIT)