E_SCN_READINCOMPATIBLE Notification error thrown while scanning bar code on MC9090G

StackOverflow https://stackoverflow.com/questions/12719302

  •  05-07-2021
  •  | 
  •  

سؤال

I'm using EMDK 2.5 (VS2008 and VC# and .NetCF3.5) Barcode2 class from the library to write a sample application to scan bar codes. I followed the samples available in EMDK namely CS_Barcode2Sample1 project.Every time I hardware trigger the scan the notification "E_SCN_READINCOMPATIBLE" is thrown and not able to retrieve the scanned data. The documentation doesn't say much about the cause of E_SCN_READINCOMPATIBLE notification and no luck from Google search. I tried several options including making use of Symbol.Barcode and the outcome is same. I also tried EMDK 2.3 but the result is same.

I've pasted the whole code here....

public partial class Form1 : Form
    {
        private Barcode2 myBarcode2 = null;

        public Form1()
        {
            InitializeComponent();
            InitBarcode();
        }

        public bool InitBarcode()
        {
            // If the Barcode2 object is already initialized then fail the initialization.
            if (myBarcode2 != null)
            {
                return false;
            }
            else // Else initialize the reader.
            {
                try
                {

                    Symbol.Barcode2.Device[] AvailableDevices = Symbol.Barcode2.Devices.SupportedDevices;
                    if (AvailableDevices.Length == 0)
                    {
                        return false;
                    }

                    if (AvailableDevices.Length == 1)
                    {
                        //get the first available scanner in the list
                        Symbol.Barcode2.Device MyDevice = AvailableDevices[0];
                        // Create the reader, based on selected device.
                        myBarcode2 = new Barcode2(MyDevice);

                        // Attach a scan notification handler.
                        //this.myScanNotifyHandler = new Barcode2.OnScanHandler(myBarcode2_ScanNotify);
                        myBarcode2.OnScan += myBarcode2_ScanNotify;

                        // Attach a status notification handler.
                        //this.myStatusNotifyHandler = new Barcode2.OnStatusHandler(myBarcode2_StatusNotify);
                        myBarcode2.OnStatus += myBarcode2_StatusNotify;
                        myBarcode2.Config.TriggerMode = TRIGGERMODES.HARD;

                        // Submit a scan.
                        myBarcode2.Scan(5000);
                      }
                }
                catch (OperationFailureException ex)
                {
                    MessageBox.Show("Exception Raised 1");
                    return false;
                }
                catch (InvalidRequestException ex)
                {
                    MessageBox.Show("Exception Raised 2");
                    return false;
                }
                catch (InvalidIndexerException ex)
                {
                    MessageBox.Show("Exception Raised 3");
                    return false;
                }
            }
            return false;
        }

        private void myBarcode2_ScanNotify(ScanDataCollection scanDataCollection)
        {
            // Checks if the BeginInvoke method is required because the OnScan delegate is called by a different thread
            if (this.InvokeRequired)
            {
                // Executes the OnScan delegate asynchronously on the main thread
                this.BeginInvoke(new Barcode2.OnScanHandler(myBarcode2_ScanNotify), new object[] { scanDataCollection });
            }
            else
            {
                // Get ScanData
                ScanData scanData = scanDataCollection.GetFirst;

                int i;
                switch (scanData.Result)
                {
                    case Symbol.Barcode2.Results.SUCCESS:
                        String str = scanData.Text;
                        myBarcode2.Config.TriggerMode = TRIGGERMODES.HARD;
                        myBarcode2.Scan(5000);
                        break;

                    case Symbol.Barcode2.Results.E_SCN_READTIMEOUT:
                        break;

                    case Symbol.Barcode2.Results.CANCELED:
                        break;

                    case Symbol.Barcode2.Results.E_SCN_DEVICEFAILURE:
                        i = 93;
                        break;

                    default:
                        if (scanData.Result == Symbol.Barcode2.Results.E_SCN_READINCOMPATIBLE)
                        {
                            // If the failure is E_SCN_READINCOMPATIBLE, exit the application.
                            MessageBox.Show("Fatal Error");
                            this.Close();
                            return;
                        }
                        break;
                }
            }
        }

        private void myBarcode2_StatusNotify(StatusData statusData)
        {
            // Checks if the Invoke method is required because the OnStatus delegate is called by a different thread
            if (this.InvokeRequired)
            {
                // Executes the OnStatus delegate on the main thread
                this.Invoke(new Barcode2.OnStatusHandler(myBarcode2_StatusNotify), new object[] { statusData });
            }
            else
            {
                int i;
                switch (statusData.State)
                {
                    case States.IDLE:
                        break;

                    case States.READY:
                        break;

                    default:
                        break;
                }
            }
        }
    }
}
هل كانت مفيدة؟

المحلول

I've went thru this recently also, as I observed, it probably due to the scanner device is occupied by other application, where the scan request has been queued already, you can go to memory management, and kill the suspect app, and try your app again.

Refer to the Symbol FAQ

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top