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()
{
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.
if (BarcodeScannerManager.Instance.RegisteredEvents.Contains(EventType.Image))
{
};
You can now get a List<IMotorolaBarcodeScanner> containing your connected scanners with GetDevices().
_scanners = BarcodeScannerManager.Instance.GetDevices();
You may have to set your scanners to the proper USB host mode before it will function correctly.
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:
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)