4 Replies Latest reply on Jun 11, 2013 1:33 PM by Cristian Quintero

    ET1 Rho App Scanner and Barcode not working

      Hi..

       

      I am trying to use the Scanner or the Barcode and I always get this error...

       

      Const_missing: Scanner

      App Error: unitialized constant

      InspectionController::Scanner

       

      or

       

      Const_missing: Barcode

      App Error: unitialized constant

      InspectionController::Barcode

       

      This is my code..

       

      def takeBarCode

          RhoLog.error("CRISTIAN","Antes de Barcode")   

           #Barcode.enumerate(url_for(:action => :getScanners))   

           #Barcode.take_barcode(url_for(:action => :tagScanned),{:camera=>'back'})

          Scanner.enable

          Scanner.decodeEvent = url_for(:action => :tagScanned)  

          RhoLog.error("CRISTIAN","Despues de Barcode") 

      end


      def getScanners

            RhoLog.info("CRISTIAN",@params['scannerArray']) 

      end

       

      def tagScanned

            RhoLog.info("CRISTIAN","cALBACK SCANNED")     

           barcode = @params['data']     

           if barcode

              WebView.execute_js("setBC('"+barCode+"')")

          else   

              RhoLog.info("cANCELADO")

              redirect :action => :index     

      end     


        • Re: ET1 Rho App Scanner and Barcode not working
          Hector Meza

          Cristian, I am not sure what device you are looking to enable the scanner on, Motorola MSI devices have a true scan engine where others are leveraging the camera.

           

          The scanner API is for a MSI scanner

           

          There are a lot of parameters and options that you can take advantage of - the documentation has all of them.  The following is a basic example of enabling via the controler with Ruby:

           

           

          # Enable Scanner

          def scannerform

               # scanner will only work on a physical device so I check for the emulator (helps with testing the app)

                if !(System::get_property('is_emulator'))

                    # Set the Callback method to be used

                    Scanner.decodeEvent = url_for(:action => :decodeEventCallback)

                    if System::get_property('platform') == 'ANDROID'

                        #ET1 and MC40 have camera and scanner and SCN2 is the scanner            

                       Scanner.enabled = 'SCN2'

                    else

                       # MSI WEHH/CE default scanner is the scanner

                       Scanner.enable

                    end

                end

               render :action => :scannerform

          end

           

           

           

          # Barcode CallBack from Decode

          def decodeEventCallback

               barcode = @params['data']

               # do something with the data ie. look for item in Inventory

               @inventory = Inventory.find(

                         :first,

                         :conditions => {:SKU => barcode})  

                if @inventory.nil?

                      Alert.show_popup('SKU Not Found!')

                 else

                      WebView.execute_js("setProductData("'+barcode+'''); ")

           

                 end

          end

           

           

          Hope this helps.

          HM