Community
cancel
Showing results for 
Search instead for 
Did you mean: 
KSels
New Contributor II
1,982 Views

Intel Edison sleep/standby/pwr down/reboot mode

Jump to solution

I am wondering how to send commands to the Intel Edison system with javasscript

Like using buttons to Control Intel Edison on index.html webpage and pins on mini breakout Board.

  • Sleep mode
  • Standby mode
  • Power down
  • Reboot

Update!!

Found out we got 4 sleep modes. (https://www.kernel.org/doc/Documentation/power/states.txt External link)

  • Freeze
  • Standby
  • Mem
  • Disk

Only need now to controll these functions true buttons and webpage.

Message was edited by: Kim Selsto

1 Solution
Pedro_M_Intel
Employee
110 Views

Hello KimLorentz,

In any other programming language it wouldn't be that complicated, it would only take a system call, but Node.js per se does not have system calls. Instead they use Child Process. I'd suggest you to read https://nodejs.org/docs/latest/api/child_process.html Child Process Node.js v5.6.0 Manual & Documentation to learn more about how to use Child Process.

Peter.

View solution in original post

6 Replies
Pedro_M_Intel
Employee
111 Views

Hello KimLorentz,

In any other programming language it wouldn't be that complicated, it would only take a system call, but Node.js per se does not have system calls. Instead they use Child Process. I'd suggest you to read https://nodejs.org/docs/latest/api/child_process.html Child Process Node.js v5.6.0 Manual & Documentation to learn more about how to use Child Process.

Peter.

View solution in original post

KSels
New Contributor II
110 Views

Got some parts working.

Here is my code.

var exec = require('child_process').exec

// Set interval

setInterval(systemcommand , 10000);

function systemcommand() {

exec('battery-voltage', function (err, stdout, stderr)

{

console.log(stdout)

//process.exit();

if (stdout.substring(0,17) == 'Battery Voltage =')

{

data_string = stdout.split('/n')[0];

data_volt = data_string.split(' ');

//console.log('Split data: ' + data_volt);

var mV = data_volt[3];

console.log('Raw data: ' + mV);

var volt = mV/1000;

console.log('Battery voltage is: ' + volt + ' Vdc');

}

})

}

The output I got is:

Battery Voltage = 4360 mV

Battery level = 100%

Raw data: 4360

Battery voltage is: 4.36 Vdc

How do I put out the voltage data to the web server.

Still not able to put device in sleep mode and using interrupt pins.

Pedro_M_Intel
Employee
110 Views

Well, you already have the voltage data in a variable, mV, why don't you convert that into a string and put it on the web server. Does that make sense? Or do you want it to be shown in real time?

Peter.

KSels
New Contributor II
110 Views

That is what I want to know how to do.

I only need it to update on the web server every 10-15 minuttes.

Pedro_M_Intel
Employee
110 Views

I have never tried to do something like that in real time, it is directly related to JavaScript so, you might like to check these links:

http://binaryjs.com/ BinaryJS - Realtime binary streaming for the web using websockets

http://stackoverflow.com/questions/4061197/how-do-they-make-real-time-data-live-on-a-web-page http://stackoverflow.com/questions/4061197/how-do-they-make-real-time-data-live-on-a-web-page

https://developers.google.com/google-apps/realtime/realtime-quickstart Google Realtime API Quickstart | Realtime API | Google Developers

http://www.labbookpages.co.uk/web/realtime.html Real-time Updating - The Lab Book Pages

Peter.

idata
Community Manager
110 Views

this is what you can do

1. create a CRON job that runs every 15 min and generates a text file with output of the battery status.

2. Read that text file from your node web server on each page load.

Reply