13 Replies Latest reply on Dec 30, 2013 8:17 AM by Tobias Appel

    RMS 4.0 Barcode API Example not working

    Tobias Appel

      Hi,

       

      I'm a student and using Rhomobile for the first time for a university project. We purchased some laser scanners, Motorola MC3190 running Windows CE 6. I'm trying to figure out how to get the scanner working. So I watched the tutorial video and got the source code from here: rho-samples/BareBones/BarcodeExample at master · rhomobile/rho-samples · GitHub

       

      But it's not working. When I run Rhoelements on the device and press the button to call Rho.Barcode.enumerate(); nothing is happening. So I tried running it using RhoSimulator and now I know why it's not working - the method is not found. In code it's called via:

      scanners = Rho.Barcode.enumerate();

      And I've checked the build.yml file and it says:

       

      extensions:

      - rhoconnect-client

      app_type: rhoelements

       

      So I don't need to specify the barcode API as extension.

       

      That's from the debug log in eclipse:

      [quote]

      E 12/11/2013 16:02:32:453 00000fd0       js_helper| API method does not found: Rho:Barcode:enumerate
      I 12/11/2013 16:02:32:468 00000fd0      JavaScript| Console message at undefined:0
      I 12/11/2013 16:02:32:468 00000fd0      JavaScript| Method not found.

      [/quote]

       

      So I have checked the documentation again and there the enumerate function is called like this:

      scanners = Rho::Barcode.enumerate();

       

      But when I use this syntax I get a different error:

      I 12/11/2013 16:07:50:203 000002a0      JavaScript| Console message at http://127.0.0.1:1195/public/barcode_enumerate.html:16
      I 12/11/2013 16:07:50:203 000002a0      JavaScript| SyntaxError: Parse error

       

      Now I'm confused. I bet the solution is very simple but since I never worked with Javascript, Ruby nor RMS before I can't quite figure it out. Can someone please point me to the correct syntax?

        • Re: RMS 4.0 Barcode API Example not working
          BHAKTA RANJAN SATAPATHY

          Hi,

           

          Kindly upload your code snippet and build.yml file here.

           

          And if possible follow the docs available at http://docs.rhomobile.com/guide/api_js

           

          Thanks

          Bhakta

          • Re: RMS 4.0 Barcode API Example not working
            Robert Galvin

            What device is this? Also Rho.Barcode::enumerate is the Ruby API. Rho.Barcode.enumerate() is for Javascript.

             

             

            You can also just try Rho.Barcode.take() to see if it works. Maybe there is a problem with enumerate on your device.

             

            I would also check out the Weinre tutorial and video - it greatly helps with inspecting JS apis.

              • Re: RMS 4.0 Barcode API Example not working
                Glenn Sayer

                Tobias,

                 

                sounds like you are missing rhoapi-modules.js on your page.

                • Re: Re: RMS 4.0 Barcode API Example not working
                  Tobias Appel

                  I have a Motorola MC3190 which is running Windows CE 6.0 - so I need to develop under Windows. Thanks for the weinre tutorial, but apparently this works only under Linux / OSX? I couldn't find binaries for Windows.

                   

                  And like I said, I copied the original example from Motorola, so of course it is included:

                   

                      <title>Rho Barebones Example</title>

                      <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>

                      <script src="/public/api/rhoapi-modules.js" type="text/javascript" charset="utf-8" ></script>

                      <script src="/public/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>

                • Re: RMS 4.0 Barcode API Example not working
                  Robert Galvin

                  Weinre will work on Mac or Windows. If you installed RhoMobile Suite it will install NPM by default. So you should be able to open a command prompt on your Windows machine and type:

                   

                  npm -g install weinre

                   

                  I am not sure about the 3190 CE 6, but assume it either has a 1D or 2D scanner, not sure it has a camera. But maybe the scanner is being used by DataWedge on the device. Try to locate that app and disable it.

                   

                  Rob

                    • Re: RMS 4.0 Barcode API Example not working
                      Tobias Appel

                      Thanks for the link to the tutorial Robert. He is using exactly the project I copied - so that's the same code right there.

                      I got weinre to start on Windows - you were correct. It just worked right from the start.

                       

                      So I did exactly like shown in the tutorial, but when I navigate to the html on the device I get a popup titled Microsoft Internet Explorer (wth, I thought RhoElements uses it's own Webengine like Gecko?) with the following text: "Oops. It seems the page runs in compatibility mode. Please fix it and try again."

                       

                      I never had this before. Of course it does not connect to weinre - although when I run the Internet Explorer on the device I can connect to my weinre server at 8080, so it's not a network problem.

                      Also when starting Rhoelements I get a Config Error Popup everytime saying that RhoElements could not find Config.xml (file://) but it's right there in the Config folder on the device. I didn't even touched the file.

                       

                      And yes you are correct, the device got no camera and we only purchased one with a 1D laser scanner since we only need to scan barcodes. Still was way more expensive (way over 1000 bucks) than a Nexus 5 or iPhone 5 - and with those devices I would be able to code a barcode scanning app in like half an hour, but this Windows CE is just crap. But I need to use it since it's a field study and apparently those devices are still used by logistics companies. So I can't switch the hardware. I bet if I had a device running Android it would work either with the Android SDK or RMS 4.0 but I have the feeling that Windows CE 6 is absolutely not supported, even Windows Mobile 6 works better since there is still a SDK by Microsoft for those devices, but Windows CE 6 you find very little information. I installed some SDK from the Motorola Download page but that's it. CE is not even mentioned in the docs, most of the time it either says WP8 or Windows Mobile 6.

                       

                      Also the Datawedge hint was good, but on this device I didn't even install Datawedge, so I can't disable it. Before discovering RhoStudio my first plan of action was to do use Visual Studio and code the barcode scanning app there, I even downloaded a library with an example I think. Not sure if I need Datawedge than, but on the other device (older model with Windows Mobile 6.0) I couldn't get it to work.

                      Maybe I do need to install Datawedge to work with RhoElements than as well?

                       

                      There are a few Motorola Sample Applications installed on the device, one of which is a scan app which works flawless, so I know the laser scanner works.

                       

                      I don't know what to tell my boss now - since we spend all the money on those devices which we believed to be supported by RMS 4.0 ( and which we can't return now) and I can't even get the official sample code to work with them.

                    • Re: RMS 4.0 Barcode API Example not working
                      Robert Galvin

                      The 3190 is a supported product. For Windows Mobile/CE there are two ways of running applications.

                       

                      1) Build using RHoStudio (will generate a cab file). It sounds like you are doing it this way. Are you installing the cab file and selecting the default settings?

                       

                      2) Use a 'Shared Runtime' which is basically a precompiled application. In this scenario, you pass in a variable (or mod the config.xml) so that it knows where to start from (being careful of the path to your local or remote html page).

                       

                      It is not clear why you are getting that error, but if it cannot find the config.xml then the rest of the app will not work. It may also be helpful if you attach a log file.

                        • Re: RMS 4.0 Barcode API Example not working
                          Tobias Appel

                          Usually I just create a Run Configuration in RhoStudio and select Windows CE as Device to deploy the application. Although this does not always work and takes a lot of time to start. But yeah I did build a cab file using the command line (something like rake wm:cab or so). But it doesn't make any difference. I also googled for that config.xml file not found error and someone else had it too using Windows CE but his solution didn't work out for me.

                           

                          I went back to try pointing the shared runtime to my own webserver on my laptop where I have copied the html from the sample project. One problem was that the application runs in fullscreen with no buttons to close it! So I always to reboot the device until I found how that you can enable debug buttons in the config.xml.

                           

                          So I was able finally access my webserver with the enumerate.html and again if I press the button nothing is happening, nothing at all. I even managed to connect to weinre - I use the exact same code as in the Youtube video, it's just copy & paste but when I press the button nothing is happening and I don't get anything in the weinre log / console. At least I don't get the internet explorer error message anymore.

                           

                          Now I am really out of ideas. The last thing I can try is re-installing my XP VM.

                            • Re: RMS 4.0 Barcode API Example not working
                              Pietro Francesco Maggi

                              Hi Tobias,

                              to build for Windows CE, you need the MC3000 PSDK installed together with Visual Studio 2005 or 2008:

                              Rhomobile | Build for Windows Mobile

                               

                              from the command line, you can request a Windows CE built using the command:

                              rake device:wince:production

                               

                              Regarding Config.xml, you can specify your own in the build.yml like explained in the documentation:

                              http://docs.rhomobile.com/en/2.2.0/rhoelements/rhoelements2-native#including-a-customized-rhoelements-configuration-file

                               

                              and can be a good idea to put there a default metatags to show a quit button:

                                <DefaultMetaTags>

                                  <MetaTag VALUE="QuitButton~Visibility:Visible"/> 

                                </DefaultMetaTags>


                              Regarding Barcode API, is just the Barcode enumerate that does not work for you or you're struggling to have anything working using Barcode?


                              ~Pietro

                              1 of 1 people found this helpful
                                • Re: RMS 4.0 Barcode API Example not working
                                  Tobias Appel

                                  Hi Pietro,

                                   

                                  thanks for the reply.

                                  I am struggling to get any method of the Barcode API to work! Not just enumerate. If I run the official sample code in the RhoMobile Simulator for Windows CE it says that it does not find the method even tough I downloaded the files from github and just copied them to my project folder - so I didn't even change a single byte in their solution.

                                   

                                  I did set up a new virtual machine to try again and I suspect that it might have been a software issue on my developer machine. The documentation says to build for Windows CE I need the platform SDK but it only says something about Windows CE 5: http://docs.rhomobile.com/en/4.0.0/guide/nativesdksetup#setup-for-windows-mobile

                                  Essentially the same goes for the link you posted: http://docs.rhomobile.com/en/4.0.0/guide/build_wm#setup-target-sdk-and-emulator

                                   

                                  Since my MC3100 device runs Windows CE 6 I did NOT install the MC3000c50b PSDK but rather the Windows CE Platform SDK v1.4 for MC3100c60 (it says 1.4 but when you install it, it says 1.3 whatever) from here: https://portal.motorolasolutions.com/Support/US-EN/Resolution?solutionId=87559

                                   

                                  Now when I want to run it on the device rake aborts with an error since it always wants to build for MC3000c50b. I always get this error when I want to deploy it to my device (RhoSimulator works fine):

                                   

                                  cd C:/MotorolaRhoMobileSuite4.0.0/ruby/lib/ruby/gems/1.9.1/gems/rhodes-4.0.0/lib/commonAPI/coreapi/ext/platform/wm

                                  vcbuild.exe : error VCBLD0004: Project 'CoreAPI.vcproj' does not contain a configuration called 'Release|MC3000c50b (ARMV4I)'.

                                  rake aborted!

                                  ["C:/Programme/Microsoft Visual Studio 9.0/VC/vcpackages/vcbuild.exe" /M4 "CoreAPI.vcproj" "Release|MC3000c50b (ARMV4I)"]


                                  So I did add the following to my build.yml:

                                   

                                  wm:

                                    sdk: 'MC3100c60b (ARMV4I)'

                                   

                                  But apparently the build.yml is completely ignored. I have struggled with this for hours the last time and wasn't able to change that. It doesn't matter what I supply as SDK it always keeps building for the Windows CE 5 PSDK! Now with the new build.yml I still get the same error and rake aborts. The first lines when you start to build always show the old PSDK:

                                   

                                  1.9.3

                                  $app_config['extensions'] : ["coreapi", "json", "rhoconnect-client", "rhoelementsext", "motoapi", "rhoelements", "barcode", "indicators", "cardreader", "hardwarekeys", "sensor"]

                                  $app_config['capabilities'] : ["motorola", "motorola_browser", "webkit_browser"]

                                  $current_platform : wm

                                  $sdk [MC3000c50b (ARMV4I)]

                                  RET: 0

                                  build started

                                   

                                  I already googled for hours and wasn't able to fix this, so in the end I installed the PSDK foor MC3000c50b (Windows CE 5) so that I was finally able to build the application and it deployed and ran but Barcode API wasn't working, along with some other weird problems. So maybe this is the root of the problem.

                                   

                                  But since the documentation doesn't list Windows CE 6 anywhere, maybe it's really not supported and I have to downgrade my MC3100 device - not sure if this even possible.

                                   

                                  Edit: Found another thread on the forums where someone states that I always have to use the Windows CE 5 PSDK and not the device native one, see here: how to improve windows mobile performance?

                                  I can't quite believe this - why would Motorola then even offer a PSDK for other devices? Doesn't make sense.

                                    • Re: RMS 4.0 Barcode API Example not working
                                      Daniel Silva

                                      All RhoMobile CE builds use MC3000c50b PSDK, even if your target is CE6 or CE7 and even if the target is not an MC3XXX.  The other PSDKs are there for developers who are developing native C/C++ apps for specific devices.

                                       

                                      The barcode API is not going to work in rhosimulator, you will need to run on a real device to see it work.

                                       

                                      If you are having problems getting it to work on a real Motorola device, the most common cause is that you have Datawedge running on the device.  Only one app can have control of the scanner at a time.  If datawedge or some other app that uses the scanner is running, it will have the scanner open and not allow your app to open it. If your app is not running, pressing the scan trigger should not light up the scanner.  If it is lighting up, there is some app that has the scanner open and enabled.

                                      1 of 1 people found this helpful
                              • Re: RMS 4.0 Barcode API Example not working
                                Tobias Appel

                                I finally got it working - much thanks to Ian Hatton and Juergen Schirp from Motorola. They send me some sample code that actually works. It's a very short HTML file I got send, basically two buttons linked to Javascript, just like in the official example, but instead of calling Rho.Barcode.enable like in the sample, Ian Hatton just wrote scanner.enable() and it works like a charm.


                                I don't even need to build something with RMS, I just installed the shared runtimes, navigated to my own webserver where I put the html and it worked. I'm still not sure why the other code from the official documentation doesn't work, but at least I got the scanner now working for the time being.


                                So thanks to everyone who helped me. I wish you all a happy new years eve.