This training tutorial will cover programming basics for the Windows SDK for Zebra scanners.
Upon completing this video, you'll be familiar with how to use our documentation to start
writing an app, where to find free source code, and you will build an app that establishes
a communication link with the scanner, queries asset tracking information, enables and disables
a symbology, controls the LEDs and beeper, switches communication protocols, and handles barcode
data. To simplify electronic searches, we've added a timestamp to the beginning of each
of the training sections.
Before starting our training, let's cover some key SDK definitions. What is scanner discovery?
It's establishing a link that enables communication and control between your application and Zebra
Scanner. What is asset tracking information? Your scanner's electronic identification information
such as serial number, model number, data manufacturer, and firmware version. What is host variant
switching? The ability to electronically trigger the switching between communication protocols
such as from USB-HID keyboard wedge to USB-OPOS and back. What are Attributes? Attributes are
values located within the scanner's memory. Three types of attributes exist. Configuration
parameters, monitor data, asset tracking information. What are Setting and Retrieving Attributes?
Set Attributes is the ability to program a value to the scanner's memory.
Required resources to create an application include a PC running the Zebra Windows SDK.
For details on how to install and validate the SDK, go to YouTube and watch the video Scanner
SDK Installation Validation, a PC running MS Visual Studio, a Zebra Scanner, and this is
important. The scanner must be in USB OPOS or USB SNAPI communication mode, and user documentation.
It's actually two documents you'll need to download. the Zebra Scanner SDK for Windows Developers
Guide, and the Zebra Scanner SDK Attribute Data Dictionary. There is a single site to download
all the Zebra Scanner software tools, including the Scanner SDK for Windows, user documentation,
both the Windows Developers Guide and the Attribute Data Dictionary. Click on the circled Scanner
SDK for Windows link, and to access how-to videos, click on the circled how-to video link. And
all of this is available at www.zebra.com forward slash scanner software the URL at the top of
the page. To make a scanner application follow these steps 1. See the reference implementation
for advice and source code it's appendix A of the Zebra Scanner SDK for Windows developers
guide. 2. Make your app in MS Visual Studio create a new console application project add
Core Scanner COM library as a reference, code your app, and compile and build the app. And
third, validate the app's operation. Before going further, let's look at your API options.
There are five SDK APIs called Core Scanner APIs. Open, which initiates the Core Scanner's
programming interface. Get Scanner, which detects all scanners and retrieves their asset tracking
information. Exec Command, which commanding controls all scanner functionality. which commanding
controls all scanner functionality asynchronously, and Close, which closes the core scanner programming
interface. Let's take a look at the Zebra Scanner SDK for Windows Developer's Guide and see how
to use it to start writing an app. Go to Appendix A. This appendix provides a step-by-step guide
to writing a simple application using the SDK's core scanner APIs. Topics covered include How
to create a console application within MS Visual Studio
How to add the CoreScan or COM library as a reference? The steps are outlined pictorially.
The document includes source code essentials like Open API to initiate the Core Scanner
interface.
Get Scanner API to detect all connected scanners and retrieve their asset tracking information.
The ExecCommand API commanding controls all scanner functionality such as beeping the beeper,
flashing the LEDs, controlling firmware upgrade, setting and retrieving parameter values, host
variant switching, and rebooting the scanner. And how to handle unsolicited events like the
display of barcode data. At this point, please print appendix A of the developer's guide.
For developers, it's key to know what attributes or parameters are available within the scanner,
what their default value is, and the range of settings that are available. For that, we go
to the Data Dictionary.
For example, if you'd like to enable or disable Code 128, you need to know the attribute number.
Go Ctrl-F, type in Code 128.
We see it in the table of contents, and now we actually find it. The attribute number is
8, and if it's enabled or disabled as a default, you'll see a star next to the value. In another
example, if you'd like to take the LED state and turn it on in red color, you'd need to
know that you are dealing with attribute 6000, and the value for red LED is 47. and we'll
show you a little later in this video how you'll implement that in code. To access source code,
click on this sequence of buttons. Start, All Programs, Zebra Scanner, Scanner SDK, Scanner
SDK Sample App Source Code. From our sample apps, we have C++ and C# source code from
Visual Studio Solutions. we're going to access the source code in the C# solution. From
within Visual Studio, right-click on Main Form to see all the source code.
We've now covered how to use our documentation to start writing an app, and where to find
the free source code. So as a next step, let's start coding our app. Before we start coding,
let's create a new project within Visual Studio. Click on File, New, Project. Select Visual
C Sharp, Windows, and Console Application. Then name your console application. In this case,
we've named it Console Application 1. Now let's add the Core Scanner COM library as a reference.
Click on Project, Add Reference. When the Add Reference dialog box pops up, select COM as
the tab, scroll down to Core Scanner 1 Type Library, select it. Core Scanner is now listed
under your projects under Reference. You're now ready to import the Core Scanner library
into your application. After importing, you can declare and instantiate the Core Scanner
class for the application. The steps shown in this video come from the user documentation
I showed earlier. The project is now ready to accept code. First, let's establish a communication
link with the scanner. As shown earlier from Appendix A, Section 8 of the Developer's Guide.
We're going to insert three lines of code into your project. As the boxes indicate in this
diagram here, use the namespace for Core Scanner, Declare Core Scanner Class, and Instantiate
Core Scanner Class.
We insert the code here.
inserting the declaration code next.
and third, inserting the instantiation code.
Now compile the code.
Next, to initiate the Core Scanner programming interface, we're going to call OpenAPI. Copy
this code.
and paste the code here.
From our developer's guide, if Visual Studio properly compiles the code, you'll see the
following output in the console window. To validate the code runs properly, click Debug, Start
Without Debugging, and your dialog is shown. Before going further, we're going to remove
some validation code.
Now we're going to save this code named consoleApplication1 because it will be used as a starting point
of many applications going forward.
Now let's create a mini application called ConsoleApplication2 to query asset tracking information. From Appendix
A, the Get Scanners API section of the Developer's Guide, we're going to call Get Scanner API
by copying the highlighted code below into our second mini application called ConsoleApplication2.
And now we're going to make copies of ConsoleApplication1.
As you can see we've made a total of five console applications. Now open Console Application
2 and paste the Get Scanner API code copied from the Developer's Guide into it.
To validate the mini-app that queries asset tracking information, connect any USB-cabled
Motorola scanner.
Go to Debug, Start Without Debugging, and displayed here as a serial number, model number, firmware
version, and date of manufacture. Now let's create a mini application called Console Application
3 to enable and disable a symbology. Basically to enable and disable the scanning of a certain
type of barcode. From Appendix A of the Developer's Guide, enable the UPCA attribute by calling
Set Attribute via Exec Command section. Copy and paste the highlighted code into the third
mini application called Console Application 3. This code will enable a symbology, in this
case UPCA. Change the highlighted area from True to False.
Now open Console Application 3 and paste the code into it.
To validate the mini-app that enables UPCA barcode scanning, simply scan a UPCA and listen for
the beep. If no beep is emitted, UPCA has been disabled. As an alternate implementation, if
instead of qpca you'd like to enable code 128, you would take the attribute number shown here
as 1 and instead type in 8. You might remember this from the Attribute Data Dictionary where
we looked it up earlier in the video. And if you'd like to disable scanning of code 128,
take the attribute value from true and turn it to false.
Now let's create a mini application called ConsoleApplication4 to beep the beeper. From Appendix A of the
Developer's Guide, the CallingExecCommand API to demonstrate beep the beeper section. Copy
and paste the highlighted code into the fourth mini application called ConsoleApplication4.
Now open ConsoleApplication4 and paste the code into it.
To validate the mini app that beeps the beeper, connect any USB-cabled Motorola scanner. Then
go to Debug.
Start without debugging.
As an alternate implementation, instead of beeping the beeper, if you would like to display a
constant red LED, type in here, instead of 2018, 6000. If you remember earlier from the data
dictionary, attribute 6000 was LED. The other thing you would do is you would take this value
here and change the value from 3 to 47, which we looked up in the attribute data dictionary,
as display constant on red LED. Now let's create a mini application called Console Application
5 that switches the scanner's communication mode from USB-HID to USB-OPOS. From Appendix
A of the Developer's Guide, calling an Exec Command API to demonstrate switching communication
protocols, copy and paste the highlighted code into the fifth mini application called Console
Application 5.
Now open Console Application 5 and paste the code into it.
To validate the MiniApplications operation, go to Debug, start without debugging.
and the beep you heard indicates auto switching occurred. In most implementations you'll want
to silence the beep. To do that, switch the false statement to true under silent switch
option.
Now let's create a Windows application that displays scanned barcode data. from Appendix
A of the Developer's Guide, the Capture Barcode Data into an Application section. We're going
to create a Windows Application project in Visual Studio. Next, we're going to add the Core Scanner
Driver as a reference, and then add a Button and Text Box area to display the scanned barcode
data. Now let's create a Windows application project. Go to File, New, Project, Windows
Application.
Now let's add the CoreScanner.com library as a reference. Go to Project. Add Reference.
As you can see, the Core Scanner has been added as a reference. Now let's add a button and
text box to your application. First, let's expand the Form 1 box so it can display all the data.
To add a button, click Toolbox, Button, and drag it to Form 1. To add a text box, click
Toolbox, Text Box, and drag it to the form.
to display the multiple lines of XML barcode output. Go to Properties, and change Multi-Line
from Fault to True.
and now expand the text box to display all the multi-lines.
From Appendix A, copy and paste the following code into the application's button click method.
From Appendix A, copy and paste the highlighted code below, which will implement a method to
receive barcode events, and paste it into the Form 1 class.
From Appendix A, copy and paste the highlighted text below to import the Core Scanner library
into your application.
And finally, copy and paste the highlighted text below to declare the Core Scanner class.
To validate the application's operation, go to Debug, Start without Debugging. When the
dialog box displays, click the button 1.
and the text displayed in the window is the output from the barcode scanner, including
barcode data. And this concludes our training on programming basics for the Windows SDK from
Zebra Scanners.