1 2 Previous Next 19 Replies Latest reply on Apr 14, 2016 1:05 AM by eric_yuan

    Error when upload the project

    eric_yuan

      Hello

      I met a problem when i tried to upload the  current project.

      QQ截图20160406200517.png

      I tried to update the xdk IDE and also change back from another project. But still have the same result.

      Anyone know the reason of it.

      I had updated the XDK IDE several days ago and the mraa version is v0.10.1

      I also udpate the yacto to iot-devkit-prof-dev-image-edison-20160315, but for some reason, i  cannot get the version of it.

      QQ截图20160406201132.png

       

      I have two js files, one is the main.js

      var drive_spi = require('./spi_drive.js');

      loop();

      function loop()

      {

          var spi_ = new drive_spi();

          console.log('Start the test');

          spi_.initial();

      }

       

      another is spi.js

      var lsbmode={};

      lsbmode.LSB = 0;

      lsbmode.MSB = 1;

      var mraa = require('mraa');

      var spi_drive = function()

      {

          var spi = new mraa.Spi(0);

          spi_drive.prototype.initial = function(x)

          {

              spi.lsbmode(false);

              spi.mode(0);

              spi.frequency(15000);

              var lsb = lsbmode.MSB;

              if(lsb==1)

                  console.log('use the MSB mode for spi');

              else

                  console.log('use the LSB mode for spi');

              console.log('finish the configuration of spi');

          };

          spi_drive.prototype.write = function(date)

          {   

              spi.writeByte(date);

          };

      };

      module.exports = spi_drive;

       

       

      I' not sure it's caused by the file itself or some other reason, I just want to build my own lib so that it looks like more neat.

       

      Eric

        • 1. Re: Error when upload the project
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello eric_yuan,
           
          The reason why you cannot retrieve the version of the current image is because the command configure_edison --version does not display the firmware version on the latest image.
           
          Is this the first time you receive this error message? Or did you also get it on previous versions of the image? Have you tried to reflash the board? Sometimes this help with issues similar to this one. Also, the issue might have been caused by a corrupt file when you updated the XDK, reinstalling it might also be of help.
           
          As a workaround you could work from linux where you can also use Node.JS to run your code. If you'd like to learn more about how to run JavaScript code this way, let me know and I'll gladly help you.
           
          Peter.

          • 2. Re: Error when upload the project
            eric_yuan

            Hello Peter

             

            I met with this problem with the previous version of image, but i'm not sure it was caused by the updating of XDK or not.,

            I will try to reinstall the XDK and have a try again.

            Also, i would appreciate if you can give me a direction on how to run JavaScript code with Node.JS, since i'm pretty new to it.

             

            Eric

            • 3. Re: Error when upload the project
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Sure, I'd be glad to. First of all, you will need to have a serial connection to your board so you can access Edison's Linux terminal. In case you don't know how to do this, you can follow this guide: https://software.intel.com/en-us/get-started-edison-windows-step3 to learn how to do it. You will also need an internet connection, you can set the Wi-Fi interface with the command configure_edison --wifi.
              Once you are connected to your Edison, you will have to update the repo included in Edison's image, in order to do so, enter the following command:

              echo src iotkit http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586/ > /etc/opkg/iotkit.conf

              Once you've done that, check if you have a prior version of mraa with the command opkg list-installed | grep mraa. If you in fact have mraa installed on your Edison, remove it with the following commands:

              *if the output of the command above is libmraa0 use:
              opkg remove libmraa0 --force-removal-of-dependent-packages

              *if the output of the command above is mraa use:
              opkg remove mraa
              **if it doesn't let you remove it add the option --force-removal-of-dependent-packages

              Once the old mraa version is uninstalled, you can install the latest version with the command:

              opkg install mraa

              With mraa you can interact with Edison's interfaces such as the GPIOs, PWM, I2C, etc. I will explain how to use Node.JS with a simple blink example. Create a file that contains the following code (you can create files using vi, in case you know how to use vi you can read http://ss64.com/vi.html to learn about it):

              var mraa = require('mraa');
              console.log('MRAA Version: ' + mraa.getVersion());
              var BLED = new mraa.Gpio(13);
              BLED.dir(mraa.DIR_OUT);
              var LEDSt = true;
              blink();                      
              function blink()
              {
                      BLED.write(LEDSt?1:0);                                            
                      LEDSt = !LEDSt;
                      setTimeout(blink,1000);
              }

              Node.JS comes pre-installed on your Edison by default so you can now simply run the script with the command node YOUR_SCRIPT_NAME.js and you should a blinking LED on your board.

              Let me know if this information helps you.
              Peter.

              • 4. Re: Error when upload the project
                eric_yuan

                Hello,

                 

                Thanks for your help on it

                I think i tried this method before by using the vi and run node blink_led.js.

                And i can also update the mraa by echo src iotkit http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586/ > /etc/opkg/iotkit.conf .since there is a readme if i build a Blink LED demo project from XDK.

                But i don't like coding in vi(maybe it's because i only know little knowledge about vi).

                I also find out i cannot setup wifi by configure_edison --version with the latest Yacto image. I had posted the problem before, it cannot detect the version of firmware by this command

                 

                Eric

                • 5. Re: Error when upload the project
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hi eric_yuan,

                   

                  The command for setting up the Wi-Fi interface is configure_edison --wifi (my bad, edited out). As I mentioned this is just a workaround that you could try while we try to find what's going on with the XDK on your PC. Have you tried to reinstall the XDK already? Did it help?

                   

                  Peter.

                  • 6. Re: Error when upload the project
                    eric_yuan

                    I tried on both Mac and Windows10, Both of them have the same error.

                    I would appreciate if you can take minutes to go through my code,to make sure it's not caused by my code .

                    I have two js files, one file is acted as a library and another is the main file.Maybe my grammar is wrong since it will generate the alarm such as

                    "require is not defined.(W117) var mraa = require('mraa');" or "console is not defined(w117)"

                    • 7. Re: Error when upload the project
                      eric_yuan

                      my spi_drive.js file


                      var lsbmode={};
                      lsbmode.LSB = 0;
                      lsbmode.MSB = 1;
                      var mraa = require('mraa');
                      var spi_drive = function()
                      {
                          var spi = new mraa.Spi(0);
                          spi_drive.prototype.initial = function(x)
                          {
                              spi.lsbmode(false);
                              spi.mode(0);
                              spi.frequency(15000);
                              var lsb = lsbmode.MSB;
                              if(lsb==1)
                                  console.log('use the MSB mode for spi');
                              else
                                  console.log('use the LSB mode for spi');
                              console.log('finish the configuration of spi');
                          };
                          spi_drive.prototype.write = function(date)
                          {  
                              spi.writeByte(date);
                          };
                      };
                      module.exports = spi_drive;
                      


                      And my main.js file


                      var drive_spi = require('./spi_drive.js');
                      loop();
                      function loop()
                      {
                          var spi_ = new drive_spi();
                          console.log('Start the test');
                          spi_.initial();
                      }
                      

                       

                      I find out only the spi_drive.js file will generate those alarms, and there is no alarm for main,js

                      Since i want to build my own library during code.So i think it's important know how to put each function into a separate JS file.

                      • 8. Re: Error when upload the project
                        Intel Corporation
                        This message was posted on behalf of Intel Corporation

                        I was able to upload your code into my Edison using the XDK, I didn't have any issues while doing so. Another thing that could be happening is that the Edison might not be connecting to the XDK, have you had issues when setting up the SSH connection? Did you make sure that your Edison and your PC are both on the same network?
                         
                        Peter.

                        • 9. Re: Error when upload the project
                          eric_yuan

                          Hey That's strange.

                          I'm pretty sure about it.Since i can upload a demo project successfully to edison.

                          I flashed the latest Yacto image yesterday(iot-devkit-prof-dev-image-edison-20160315)

                          And i only updated the mraa and upm through Manage your Daemon-->Update libraries on board.

                          The Daemon version is v0.0.38

                          The npm version is v1.4.28

                          The node version is v0.10.38

                          The mraa version is v0.10.1

                          I cannot find out how to check the version of XDK,but i'm sure it's the latest.

                          I'm not sure it's because some of those versions are not match yours.so that you can upload it successfully or you installed something else that i didnot istall.

                           

                          I just upload the whole project here and i would appreciate if you can import it to XDK and see what's going on.Since those error will show up when i open the spi_driver.js file.

                          So i would think it's even not a problem related with edison. Maybe a grammar issue in my project.

                           

                          safsd.png

                           

                          I cannot find out how can i upload a .zip file?

                          • 10. Re: Error when upload the project
                            eric_yuan

                            Hey

                            I finally get it work but still have those warning in XDK like require is not defined.

                            But for the Error i posted before, I think it's because the spi_driver.js was not uploaded into node_app_slot folder.

                            After i copy the find directly to node_app_slot, and then i can simple run node main.js, and it works.

                            And then, i go back to XDK, and there is no error anymore.

                            I think i still can use XDK IDE to coding now, which i think is much smarter than vi.

                             

                            Thanks for your help on it

                             

                            Eric

                            • 11. Re: Error when upload the project
                              eric_yuan

                              And one small problem is how can i eliminate the warning "require is undefined"

                              • 12. Re: Error when upload the project
                                eric_yuan

                                And i cannot understand why i have three .js file but can only upload the main.js file into node_app_slot folder in edison

                                • 13. Re: Error when upload the project
                                  Intel Corporation
                                  This message was posted on behalf of Intel Corporation

                                  I'm afraid I'm not following you, the error message has disappeared, right? But now you are getting warnings from the XDK, am I right? And lastly, only the main file is being uploaded to your board, right?
                                  If I all of that right then I'd say again that there's something weird about XDK's installation since I just tried it again and both files main.js and spi_drive.js were uploaded correctly into my board. As I mentioned before, I believe the best option is to try to uninstall/reinstall the XDK to try fix any issues it may have. These are the screenshots from what I tried earlier:

                                   

                                  xdk1.jpg

                                  xdk2.jpg

                                  xdk3.jpg

                                   

                                  Peter.

                                  • 14. Re: Error when upload the project
                                    eric_yuan

                                    Hey

                                    I appreciate you help on it. And i will try to uninstall and install again to have a look.

                                    I will give you feedback after that.

                                    Another question that i want to ask is any alarm shows up when you open the spi_drive.js

                                    QQ截图20160412084829.png

                                    As you can see from the picture, there are alarms if i open the spi_drive.js files

                                    And if i click the alarm,it says some thing like "Require is not defined"

                                    safa.png

                                    1 2 Previous Next