4 Replies Latest reply on Aug 6, 2016 9:15 AM by MRH123

    How to use node.js to write data into Uart Serial on Intel Edison board with Arduino Board.


      Hello,I am a student from Central South University in China. I am studying using node.js module on Intel Edison board with Arduino.


      I want to use the Uart  Serial on Intel Edison Board,The node.js demo program is as follow:


              var m = require('mraa'); //require mraa


              console.log('MRAA Version: ' + m.getVersion());

             rfid_UART = new m.Uart(0)


             console.log("Note: connect Rx and Tx of UART with a wire before use");


             function sleep(delay) {

             delay += new Date().getTime();

             while (new Date() < delay) { }



             console.log("Set UART parameters");


             re1 = rfid_UART.setTimeout(1000,1000,1000);

             console.log("res1:", "res1"+re1);


             re2 = rfid_UART.setBaudRate(115200);

             console.log("res2:", "res2"+re2);


             re3 = rfid_UART.SetNonBlocking(false);

             console.log("res3:", "res3"+re3);


             re4 = rfid_UART.setFlowcontrol(false,false);

             console.log("res4:", "res4"+re4);


             re5 = rfid_UART.setMode(8,0,1);

             console.log("res5:", "res5"+re5);




             var value = "AA0003000100048E";

             var t = rfid_UART.writeStr(value);


             console.log("res6:", "res6"+ value + t);


             var result = rfid_UART.readStr(16);


             console.log("res7:", "res7"+result);


      But the result is as follow:


      when readStr() it is blocking......!!!


      The first question is:

      Is Edison's Uart(Pin 0 and Pin 1) Index is 0,why and who defind it?(In fact,I use "rfid_UART = new m.Uart("/dev/ttyMFD1");" instantiate the Uart Serial object,the result is same as before.)


      The second question is:

      If the Index is 0 which means I instantite the right Uart Serial,

      why all of the returns of setTimeout(),setBaudRate(),SetNonBlocking(),setFlowcontrol() and setMode() are 0?(console.log as "res#:+res#+return")


      The third question is:

      I want to write a a hexadecimal data into Uart Serial as "AA0003000100048E" ,but the APIs only has write(number) and writeStr(string),

      so I choose writeStr() but readStr() is blocking.Am I right to choose writeStr()?

      If not,how can I write a hexadecimal data as "AA0003000100048E" into Uart Serial。


      The fourth question is:

      Could you tell me if all above is correct configuration why readStr() is blocking?

      I'm sorry to ask your help because this is my first time contact Edison and IoT.




      The mraa APIs document as follow:



      The relative web: