Xamarin Android and EMDK Failure

I am using Xamarin Android and EMDK and keep getting errors with the scanner service just dying or returning scanner disabled and am not using data wedge. This is a custom application for my company. WE needed a custom  solution.  I do get the EMDK status as success. However that does not translate into the scanner returning information.

I return the data to my application via an EventHandler.  IN the end we are not trying to have special configurations. we want to set it once and just ignore the data in the UI if we do not need the scan we can throw it away.

 

I obviously may not know enough about all this. I am new to Android. My application is almost done but this scanner not coming up or just dying is plaguing us.

 

Thanks

 

-Pete

Peter Drozd
     Here is my code for the

     Here is my code for the data and status events.  

private void scanner_Data(object sender, Scanner.DataEventArgs e)

        {

            ScanDataCollection scanDataCollection = e.P0;

            if ((scanDataCollection != null) && (scanDataCollection.Result == ScannerResults.Success))

            {

                var scanData = scanDataCollection.GetScanData();

                foreach (var data in scanData)

                {

                    displaydata(data.LabelType.ToString(), data.Data);

                }

            }

        }

        private void scanner_Status(object sender, Scanner.StatusEventArgs e)

        {

            String statusStr = "";

            StatusData statusData = e.P0;

            StatusData.ScannerStates state = e.P0.State;

            try

            {

                if (state == StatusData.ScannerStates.Idle)

                {

                    statusStr = "Scanner is idle and ready to submit read.";

                    try

                    {

                        if (scanner == null)

                            InitScanner();

                        if (scanner.IsEnabled && !scanner.IsReadPending)

                        {

                            Thread.Sleep(100);

                            scanner.Read();

                        }

                    }

                    catch (ScannerException e1)

                    {

                        statusStr = e1.Message;

                        string msg = "Exception - " + e1.Message;

                        if (ScannerStatusEvent != null)

                            ScannerStatusEvent(this, new ScannerDataEventArgs("", msg));

                        Log.Debug("BmService", msg);

                       

                    }

                }

                if (state == StatusData.ScannerStates.Waiting)

                {

                    statusStr = "Waiting for Trigger Press to scan";

                }

                if (state == StatusData.ScannerStates.Scanning)

                {

                    statusStr = "Scanning in progress...";

                }

                if (state == StatusData.ScannerStates.Disabled)

                {

                    statusStr = "Scanner disabled";

                    scanner.Enable();

                }

                if (state == StatusData.ScannerStates.Error)

                {

                    statusStr = "Error occurred during scanning";

                   

                }

                displayStatus(statusStr);

            }

            catch (Exception ex)

            {

                string msg = "Exception - " + ex.Message;

                if (ScannerStatusEvent != null)

                    ScannerStatusEvent(this, new ScannerDataEventArgs("", msg));

                Log.Debug("BmService", msg);

            }

        }

void InitScanner()

        {

            if (emdkManager != null)

            {

                if (barcodeManager == null)

                {

                    try

                    {

                        //Get the feature object such as BarcodeManager object for accessing the feature.

                        barcodeManager = (BarcodeManager)emdkManager.GetInstance(EMDKManager.FEATURE_TYPE.Barcode);

                        if (barcodeManager != null)

                        {

                            // Add connection listener

                            barcodeManager.Connection += barcodeManager_Connection;

                        }

                        scanner = barcodeManager.GetDevice(BarcodeManager.DeviceIdentifier.Default);

                        if (scanner != null)

                        {

                            //Attahch the Data Event handler to get the data callbacks.

                            scanner.Data += scanner_Data;

                            //Attach Scanner Status Event to get the status callbacks.

                            scanner.Status += scanner_Status;

                            scanner.Enable();

                            //EMDK: Configure the scanner settings

                            ScannerConfig config = scanner.GetConfig();

                            config.SkipOnUnsupported = ScannerConfig.SkipOnUnSupported.None;

                            config.ScanParams.DecodeLEDFeedback = true;

                            config.ReaderParams.ReaderSpecific.ImagerSpecific.PickList = ScannerConfig.PickList.Enabled;

                            config.DecoderParams.Code39.Enabled = true;

                            config.DecoderParams.Code128.Enabled = false;

                            scanner.SetConfig(config);

                        }

                        else

                        {

                            displayStatus("Failed to enable scanner.\n");

                        }

                    }

                    catch (ScannerException e)

                    {

                        displayStatus("Error: " + e.Message);

                    }

                    catch (Exception ex)

                    {

                        displayStatus("Error: " + ex.Message);

                    }

                }

            }

        }

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Peter,It's difficult to

Hi Peter,

It's difficult to say what could be causing your issue - I tried running your code but there isn't quite enough there to try and reproduce the issue.

What do you see in your adb log when the problem happens?  And what device / OS are you using?

Also, it might be worth taking a look at the sample barcode app if you haven't seen it: Barcode APIs - Zebra Technologies Techdocs , that provides a known configuration for scanning through EMDK for Xamarin.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Peter Drozd
Thanks for the response

Thanks for the response Darryn;

The log is showing that the service restarts. It shows a crashed service.  I have a bit of difficulty filtering the logs to only get the EMDK crashes but that is what it happening. When it seems to stop working the light on top of the gun is RED in color not the usual green. Sometimes it goes yellow but i don't really know what all that means.

All the examples have UI elements with spinners and a bunch of stuff that we will never use. I strap it one way and that is it. It will never really change for our company so why provide an interface to change scanner settings? It is a bit outside of the scope of what we are doing. I am also not using anything like profiles for the gun as some of the examples I am seeing. These are large XML files with settings. I'm not using that.

My entire app is working except for scanner reliability.

-Pete

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Peter Drozd
I have included the log file.

I have included the log file. There may be some configuration that has to be set up. I'm not using a Configuration file or anything like that.

933 Zebra Technologies TC8000 Debug 31833 EmdkService Caught exception : Already scanning. Wait for current scanning to complete.

05-02 14:25:41.933 Zebra Technologies TC8000 Debug 31833 com.symbol.emdk.emdkservice.barcode.SvcScanner start - getScanStatus

05-02 14:25:41.933 Zebra Technologies TC8000 Debug 31833 com.symbol.emdk.emdkservice.barcode.SvcScanner end - getScanStatus

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Peter,Can you please

Hi Peter,

Can you please confirm this happens with a release application with the device not connected to the host PC via USB?  I remember a similar issue a short while back whilst _debugging_ an application that we are dealing with but that issue happened only whilst debugging.

Thanks for sharing the log, it's strange there are so many errors related to scanner properties (e.g. beam width) that you aren't even setting, but that's nothing wrong with your application.  Personally I don't see anything wrong with your code, would be good to know exactly where the problem is occurring though.  The error implies you are submitting the scan read at the wrong time but your code looks fine to me

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Peter Drozd
Yes It still fails. -pete

Yes

It still fails.

-pete

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
Hi Peter,Sorry I can't help

Hi Peter,

Sorry I can't help further without being able to reproduce the issue and there are no 'smoking guns' in the log file.  If you have a support contract then I suggest reaching out to our technical support Contact Tech Support

If you have a small application which shows the issue I can take a look at it in a bit more detail.

Darryn.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments