15 Replies Latest reply on Nov 13, 2013 8:46 AM by Chris Child

    Rho Scanner Event

    Chris Child

      Hi all,

       

      I'm having an issue with the Scanner while using a MC95. I'm able to turn the scanner on and scan a barcode but when the barcode event fires the object sent to the event doesn't contain any of the data I scanned. When I try to do barcode.data I'm receiving 'undefined'.

       

      Thanks for any help.

       

      Chris

       

      edit: Code being used:

       

      function enableScanner() {

      scanner.enabled = true;

      Rho.Barcode.take({}, onBarcodeEvent);

      }

       

      function onBarcodeEvent (barcode) {

      alert("bc " + barcode.data);

      document.getElementById('meterNum').value = barcode.data;

      }

        • Re: Rho Scanner Event
          Peter Arcuri

          Just a thought, is it possible that DataWedge is enabled on the MC95? In this case pressing the scan trigger the data is captured by DW and directed to the keyboard buffer. This will superceed the Rho API.

           

          Launch DataWedge and ensure it is disabled.

           

          Hope this helps.

          • Re: Rho Scanner Event
            Glenn Sayer

            Chris,

             

            can you provide the code that you are using to enable the scanner and also the callback function code.

            • Re: Rho Scanner Event
              Robert Galvin

              What method are you using to turn the scanner on? There are two ways to do it and they both have different callback return params

               

              barcode.take will return an object that has the data in object.barcode

               

              barcode.enable will return an object that has data in object.data

               

              Also look at my video using Weinre - if you set this up, you will have your answer on what is being returned object wise in a few minutes.

                • Re: Rho Scanner Event
                  Peter Arcuri

                  Correct me if I'm wrong but I believe Chris is using the BarcodeExample project… below is relevant excerpt from the app:

                   

                          Rho.Barcode.enable( {} , function (e){

                                  //here is where the callback will occur

                                  // e is a Barcode callback return object

                                  // callback params

                                  //data : STRING The data decoded by the scanner or imaging device

                                  //source : STRING The source device and human readable decoder type of the decoded barcode or symbol

                                  //type : STRING Hex value representing the decoder type

                                  //time : STRING The time at which the decode occurred (hh:mm:ss)

                                  //length : STRING The length of the decoded barcode or symbol

                                  //direction : STRINGThe direction the barcode was scanned, either forward, reverse or unavailable

                                  $('ul').html('<li>' + e.data + '</li>');

                                  $('ul').append('<li>' + e.source + '</li>');

                                  $('ul').append('<li>' + e.type + '</li>');

                                  $('ul').append('<li>' + e.time + '</li>');

                                  $('ul').append('<li>' + e.length + '</li>');

                                  $('ul').append('<li>' + e.direction + '</li>');

                                  //document.getElementById('ul').html('<li>' + e.data + '</li>');

                                  //document.getElementById('ul').append('<li>' + e.direction + '</li>');

                              }

                    • Re: Rho Scanner Event
                      Chris Child

                      I am using an example app, as reference, that was sent to me by a sales rep but it does not look like this.

                       

                      Here is the example I was sent:

                       

                      function enableScanner1()

                      {

                           alert("asdf");

                           Rho.Barcode.take({}, onBarcodeEvent);

                           flash(3);

                      }

                        • Re: Rho Scanner Event
                          Robert Galvin

                          yeah so like I said previously, the take returns .barcode not .data

                           

                          function onBarcodeEvent (barcode) {

                          alert("bc " + barcode.barcode);

                          document.getElementById('meterNum').value = barcode.data;

                          }Screen Shot 2013-11-13 at 11.25.50 AM.jpg

                          1 of 1 people found this helpful
                            • Re: Rho Scanner Event
                              Chris Child

                              Yes you're right.

                               

                              This is what I was sent in the example project hence why I got confused. This is not the first error I've found either so I think I'll just stop using this project.

                               

                              function onBarcodeEvent (barcode)

                              {

                                   alert ("bc" + barcode);

                                   document.getElementById('barcode-data').value = barcode.data;

                                   document.getElementById('barcode-source').value = barcode.source;

                                   document.getElementById('barcode-type').value = barcode.type;

                                   document.getElementById('barcode-time').value = barcode.time;

                                   document.getElementById('barcode-length').value = barcode.length;

                                   document.getElementById('barcode-event').value = barcode.event;

                               

                                   flash(3);

                              }

                        • Re: Rho Scanner Event
                          Chris Child

                          Weinre sounds like exactly what I've been in need of. I was stuck trying to figure out how to view what was actually being passed to the callback.