Quantcast
Channel: Intel Communities: Message List
Viewing all articles
Browse latest Browse all 18347

Re: how to read uart'data from edison board

$
0
0

Hi,

I am not able to get the outputs for serialport code. So i tried running a simple File read code in Intel XDK

But the thing is the same code which i am trying to do on edison is working on my linux machine.

Example. Simple file reading code:-

/********************************************CODE*****************************************************/

//Type Node.js Here
var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the Intel XDK console
console.log("Ok to go");

 

console.log("Hello World");
var file_handler = require('fs');
file_handler.open('/home/root/output.txt','r',function(err,fd){
    if (err) throw(err);
    var readBuffer = new Buffer(1024),
                    bufferoffset=0,
                    bufferlength = readBuffer.length,
                    fileposition = 0;
    file_handler.read(fd,readBuffer,bufferoffset,bufferlength,fileposition,
            function(err,readBytes){
                if (err) throw err;
                console.log('just read'+readBytes+'bytes')
                if(readBytes>0){
                    console.log(readBuffer.slice(0,readBytes));
                }
    });
});
/**************************************************************************************************************/

I think there is some mistake which i am doing .

 

 

Ishan  


Viewing all articles
Browse latest Browse all 18347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>