Community
cancel
Showing results for 
Search instead for 
Did you mean: 
eyuan2
New Contributor I
1,630 Views

Error when upload the project

Hello

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

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.

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

19 Replies
idata
Community Manager
126 Views

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.
eyuan2
New Contributor I
126 Views

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

idata
Community Manager
126 Views

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 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/ 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 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.
eyuan2
New Contributor I
126 Views

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/ 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

idata
Community Manager
126 Views

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.

eyuan2
New Contributor I
126 Views

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)"

eyuan2
New Contributor I
126 Views

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.

idata
Community Manager
126 Views

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.
eyuan2
New Contributor I
126 Views

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.

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

eyuan2
New Contributor I
126 Views

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

eyuan2
New Contributor I
126 Views

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

eyuan2
New Contributor I
126 Views

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

idata
Community Manager
126 Views

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:

Peter.

eyuan2
New Contributor I
126 Views

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

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"

idata
Community Manager
126 Views

I also get these "warning" messages, as you can see in the screenshot bellow, so far I haven't noticed that they affect the script's functionality. As I've mentioned before, I believe that XDK's installation might be corrupted, try to reinstall it and try again. Also, when running the XDK, remember to open it as administrator, to avoid any issues. Let us know what happens.

 

 

 

 

Peter.
eyuan2
New Contributor I
126 Views

Hey Peter

Yes, I had run the code successfully and now i can drive the OLED and show a picture on it.

I migrate this OLED project from communities and I use SPI interface to drive the OLED.

Actually, I still have a problem but it's more related with javascript language which i need to solve it by myself instead of getting the help from you.

But it would be much better if you can find out the problem without much error on it.

In this project , it have a oled.js file,in which there is a OLED.prototype.drawPixel function.

var OLED = function()

{

OLED.prototype.drawPixel = function(x, y, color) {

}

}

module.exports = OLED;

There is another Adfaruit_GXF.js file in which there is a function of Adafruit_GFX.prototype.drawBitmap

Adafruit_GFX.prototype.drawBitmap = function(x, y, bitmap, w, h, color) {

var i, j, byteWidth = (w + 7) / 8;

for(j=0; j

for(i=0; i

if(pgm_read_byte(bitmap + j * byteWidth + i / 8) & (128 >> (i & 7))) {

this.drawPixel(x+i, y+j, color);

}

}

}

};

I find out the second JS file will invoke the drawPixel function directly, But i find out if i use drawBitmap function in main.js., it will shows no method for drawPixel

Currently i have no idea about what i need to do,since i'm new to javascript. I'm learning that language now, but it would be better if you know where is the problem.

Thanks

Eric

eyuan2
New Contributor I
126 Views

You can find out the project from this link

Eric

idata
Community Manager
126 Views

I'm not an expert in JavaScript but I'll do my best effort. Nevertheless, I was checking the project you sent me and I can see that the original code is much more complex than the lines that you posted. Have you tried to run the code posted there? This might be the best option to start in your project because once you have managed to run the example, you can verify that the physical part of the project is working and then you can focus on the software part.

Also, if you are using the same display as in the example, there is a UPM library available for it and you can find another example in https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/oled_ssd1306.js https://github.com/intel-iot-devkit/upm/blob/master/examples/javascript/oled_ssd1306.js. So it may be a good idea to check how the library works to have a better idea of how to code your script.

 

 

Peter.
eyuan2
New Contributor I
126 Views

Hey Peter

Thanks for your help. I will follow up your suggestion and have a try.

I will give you feedback later.

Eric

Reply