I'm assisting with the development of a simple app to manage a staff check in procedure.
I decided to use the Scanner SDK in leu of parsing the HID data so the only interaction the end user needs to perform is scanning their badge. ( no selecting a specific text box or anything like that)
The final application will need to automatically connect a scanner without user interaction and handle around 200 people scanning their badges as quickly as possible.
Below is my code, additionally I included a solution file with the code I am using
private void ConnectScanners()
{
try
{
//Instantiate CoreScanner Class
var cCoreScannerClass = new CCoreScannerClass();
//Call Open API
short[] scannerTypes = new short[1];//Scanner Types you are interested in
scannerTypes[0] = 1; // 1 for all scanner types
short numberOfScannerTypes = 1; // Size of the scannerTypes array
int status; // Extended API return code
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
// Subscribe for barcode events in cCoreScannerClass
cCoreScannerClass.BarcodeEvent += new
_ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
// Let's subscribe for events
int opcode = 1001; // Method for Subscribe events
string outXML; // XML Output
string inXML = "" +
"" +
"1" + // Number of events you want to subscribe
"1" + // Comma separated event IDs
"" +
"";
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
MessageBox.Show(outXML + '\n' + status);
}
catch (Exception exp)
{
MessageBox.Show("Something wrong please check... " + exp.Message);
}
}
void OnBarcodeEvent(short eventType, ref string pscanData)
{
string barcode = pscanData;
richTextBox1.Invoke((MethodInvoker)delegate { richTextBox1.Text = barcode;});
}
Currently this code above I am using is the sample code from page 132 the the Zebra Scanner SDK Developer Guide with a small tweak or two
https://www.zebra.com/content/dam/zebra_new_ia/en-us/manuals/barcode-sc…
I'm working on parsing the data that's returned from the OnBarcodeEvent but I notice the scanner seems to intermittently disconnect.
If I move to another window it's hit and miss, sometimes my test app will still read barcode events even if I'm scanning into a notepad or something.
Then randomly disconnects.
So my question is to anyone who may have experience with the Scanner SDK for windows, are there any additional steps, commands to execute, or events I would need to register in order to ensure that the device is always connected?
0 Replies